io.dropwizard.testing.ResourceHelpers Java Examples
The following examples show how to use
io.dropwizard.testing.ResourceHelpers.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VerifyServiceProviderAppRule.java From verify-service-provider with MIT License | 6 votes |
public VerifyServiceProviderAppRule(boolean isEidasEnabled, MockMsaServer msaServer, String secondaryEncryptionKey, String serviceEntityIdOverride) { super( VerifyServiceProviderApplication.class, ResourceHelpers.resourceFilePath("verify-service-provider-with-msa.yml"), ConfigOverride.config("serviceEntityIds", serviceEntityIdOverride), ConfigOverride.config("hashingEntityId", "some-hashing-entity-id"), ConfigOverride.config("server.connector.port", String.valueOf(0)), ConfigOverride.config("logging.loggers.uk\\.gov", "DEBUG"), ConfigOverride.config("samlSigningKey", TEST_RP_PRIVATE_SIGNING_KEY), ConfigOverride.config("verifyHubConfiguration.environment", "COMPLIANCE_TOOL"), ConfigOverride.config("samlPrimaryEncryptionKey", TEST_RP_PRIVATE_ENCRYPTION_KEY), ConfigOverride.config("samlSecondaryEncryptionKey", secondaryEncryptionKey), ConfigOverride.config("msaMetadata.uri", () -> { IdaSamlBootstrap.bootstrap(); msaServer.serveDefaultMetadata(); return msaServer.getUri(); }), ConfigOverride.config("msaMetadata.expectedEntityId", MockMsaServer.MSA_ENTITY_ID) ); }
Example #2
Source File: VerifyServiceProviderConfigurationTest.java From verify-service-provider with MIT License | 5 votes |
@Test public void shouldNotComplainWhenConfiguredCorrectly() throws Exception { environmentHelper.setEnv(new HashMap<String, String>() {{ put("PORT", "50555"); put("LOG_LEVEL", "ERROR"); put("VERIFY_ENVIRONMENT", "COMPLIANCE_TOOL"); put("MSA_METADATA_URL", "some-msa-metadata-url"); put("MSA_ENTITY_ID", "some-msa-entity-id"); put("SERVICE_ENTITY_IDS", "[\"http://some-service-entity-id\"]"); put("SAML_SIGNING_KEY", TEST_RP_PRIVATE_SIGNING_KEY); put("SAML_PRIMARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY); put("SAML_SECONDARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY); put("CLOCK_SKEW", "PT30s"); put("EUROPEAN_IDENTITY_ENABLED", "false"); put("HUB_CONNECTOR_ENTITY_ID", "etc"); put("TRUST_ANCHOR_URI", "etc"); put("METADATA_SOURCE_URI", "etc"); put("TRUSTSTORE_PATH", "etc"); put("TRUSTSTORE_PASSWORD", "etc"); }}); factory.build( new SubstitutingSourceProvider( new FileConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false) ), ResourceHelpers.resourceFilePath("verify-service-provider-with-msa.yml") ); environmentHelper.cleanEnv(); }
Example #3
Source File: VerifyServiceProviderConfigurationTest.java From verify-service-provider with MIT License | 5 votes |
@Test public void shouldNotAllowMsaAndEidasConfigTogether() throws Exception { Map<String, String> map = ImmutableMap.<String,String>builder() .put("PORT", "50555") .put("LOG_LEVEL", "ERROR") .put("VERIFY_ENVIRONMENT", "COMPLIANCE_TOOL") .put("MSA_METADATA_URL", "some-msa-metadata-url") .put("MSA_ENTITY_ID", "some-msa-entity-id") .put("SERVICE_ENTITY_IDS", "[\"http://some-service-entity-id\"]") .put("SAML_SIGNING_KEY", TEST_RP_PRIVATE_SIGNING_KEY) .put("SAML_PRIMARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY) .put("SAML_SECONDARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY) .put("CLOCK_SKEW", "PT30s") .put("EUROPEAN_IDENTITY_ENABLED", "false") .put("HUB_CONNECTOR_ENTITY_ID", "etc") .put("TRUST_ANCHOR_URI", "etc") .put("METADATA_SOURCE_URI", "etc") .put("TRUSTSTORE_PATH", "etc") .put("TRUSTSTORE_PASSWORD", "etc") .build(); String newErrorMessage = "eIDAS and MSA support cannot be set together." + " The VSP's eIDAS support is only available when it operates without the MSA"; assertThatThrownBy(() -> { factory.build( new SubstitutingSourceProvider( new FileConfigurationSourceProvider(), new StrSubstitutor(map) ), ResourceHelpers.resourceFilePath("verify-service-provider-with-msa-and-eidas.yml") ); }).isInstanceOf(ConfigurationException.class).hasMessageContaining(newErrorMessage); }
Example #4
Source File: AbstractApplicationTest.java From dropwizard-pac4j with Apache License 2.0 | 5 votes |
public void setup( Class<? extends Application<TestConfiguration>> applicationClass, String configPath, ConfigOverride... configOverrides) { dropwizardTestSupport = new DropwizardTestSupport<>(applicationClass, ResourceHelpers.resourceFilePath(configPath), configOverrides); dropwizardTestSupport.before(); }
Example #5
Source File: SundialBundleITBase.java From dropwizard-sundial with Apache License 2.0 | 5 votes |
public static DropwizardAppExtension<TestConfiguration> buildApp( String configFile, final Before before ) { return new DropwizardAppExtension<TestConfiguration>( new DropwizardTestSupport<TestConfiguration>( TestApp.class, ResourceHelpers.resourceFilePath(configFile) ) { @Override public void before() throws Exception { super.before(); before.before(getEnvironment()); } } ); }
Example #6
Source File: SetUpTest.java From oxd with Apache License 2.0 | 5 votes |
@Parameters({"host", "opHost", "redirectUrls"}) @BeforeSuite public static void beforeSuite(String host, String opHost, String redirectUrls) { try { LOG.debug("Running beforeSuite ..."); ServerLauncher.setSetUpSuite(true); SUPPORT = new DropwizardTestSupport<OxdServerConfiguration>(OxdServerApplication.class, ResourceHelpers.resourceFilePath("oxd-server-jenkins.yml"), ConfigOverride.config("server.applicationConnectors[0].port", "0") // Optional, if not using a separate testing-specific configuration file, use a randomly selected port ); SUPPORT.before(); LOG.debug("HTTP server started."); removeExistingRps(); LOG.debug("Existing RPs are removed."); RegisterSiteResponse setupClient = SetupClientTest.setupClient(Tester.newClient(host), opHost, redirectUrls); Tester.setSetupClient(setupClient, host, opHost); LOG.debug("SETUP_CLIENT is set in Tester."); Preconditions.checkNotNull(Tester.getAuthorization()); LOG.debug("Tester's authorization is set."); setupSwaggerSuite(Tester.getTargetHost(host), opHost, redirectUrls); LOG.debug("Finished beforeSuite!"); } catch (Exception e) { LOG.error("Failed to start suite.", e); throw new AssertionError("Failed to start suite."); } }
Example #7
Source File: RpSyncServiceTest.java From oxd with Apache License 2.0 | 5 votes |
@BeforeClass public void setUp() throws IOException, ConfigurationException { configurationService.setConfiguration(TestUtils.parseConfiguration(ResourceHelpers.resourceFilePath("oxd-server-jenkins.yml"))); persistenceService.create(); rpService.removeAllRps(); rpService.load(); }
Example #8
Source File: RpServiceTest.java From oxd with Apache License 2.0 | 5 votes |
@BeforeClass public void setUp() throws IOException, ConfigurationException { configurationService.setConfiguration(TestUtils.parseConfiguration(ResourceHelpers.resourceFilePath("oxd-server-jenkins.yml"))); persistenceService.create(); service.removeAllRps(); service.load(); }
Example #9
Source File: MsaMetadataFeatureTest.java From verify-service-provider with MIT License | 4 votes |
@Before public void setUp() { IdaSamlBootstrap.bootstrap(); wireMockServer.start(); hubServer.serveDefaultMetadata(); KeyStoreResource metadataTrustStore = aKeyStoreResource() .withCertificate("VERIFY-FEDERATION", aCertificate().withCertificate(METADATA_SIGNING_A_PUBLIC_CERT).build().getCertificate()) .build(); KeyStoreResource hubTrustStore = aKeyStoreResource() .withCertificate("VERIFY-HUB", aCertificate().withCertificate(TEST_CORE_CA).build().getCertificate()) .build(); KeyStoreResource idpTrustStore = aKeyStoreResource() .withCertificate("VERIFY-IDP", aCertificate().withCertificate(TEST_IDP_CA).build().getCertificate()) .build(); metadataTrustStore.create(); hubTrustStore.create(); idpTrustStore.create(); this.applicationTestSupport = new DropwizardTestSupport<>( VerifyServiceProviderApplication.class, ResourceHelpers.resourceFilePath("verify-service-provider-with-msa.yml"), config("server.connector.port", "0"), config("verifyHubConfiguration.metadata.uri", format("http://localhost:%s/SAML2/metadata", hubServer.port())), config("msaMetadata.uri", getMsaMetadataUrl()), config("verifyHubConfiguration.metadata.expectedEntityId", HUB_ENTITY_ID), config("msaMetadata.expectedEntityId", MockMsaServer.MSA_ENTITY_ID), config("verifyHubConfiguration.metadata.trustStore.path", metadataTrustStore.getAbsolutePath()), config("verifyHubConfiguration.metadata.trustStore.password", metadataTrustStore.getPassword()), config("verifyHubConfiguration.metadata.hubTrustStore.path", hubTrustStore.getAbsolutePath()), config("verifyHubConfiguration.metadata.hubTrustStore.password", hubTrustStore.getPassword()), config("verifyHubConfiguration.metadata.idpTrustStore.path", idpTrustStore.getAbsolutePath()), config("verifyHubConfiguration.metadata.idpTrustStore.password", idpTrustStore.getPassword()) ); environmentHelper.setEnv(new HashMap<String, String>() {{ put("VERIFY_ENVIRONMENT", "COMPLIANCE_TOOL"); put("MSA_METADATA_URL", "some-msa-metadata-url"); put("MSA_ENTITY_ID", "some-msa-entity-id"); put("SERVICE_ENTITY_IDS", "[\"http://some-service-entity-id\"]"); put("SAML_SIGNING_KEY", TEST_RP_PRIVATE_SIGNING_KEY); put("SAML_PRIMARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY); }}); }
Example #10
Source File: RsProtectTest.java From oxd with Apache License 2.0 | 4 votes |
@BeforeClass public void setUp() throws IOException, ConfigurationException { configurationService.setConfiguration(TestUtils.parseConfiguration(ResourceHelpers.resourceFilePath("oxd-server-jenkins.yml"))); persistenceService.create(); }