io.dropwizard.testing.ConfigOverride Java Examples
The following examples show how to use
io.dropwizard.testing.ConfigOverride.
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: ConfigOverrideUtils.java From dropwizard-guicey with MIT License | 6 votes |
/** * @param prefix prefix * @param props overriding properties in "key: value" format * @return parsed configuration override objects */ public static ConfigOverride[] convert(final String prefix, final String... props) { ConfigOverride[] overrides = null; if (props != null && props.length > 0) { overrides = new ConfigOverride[props.length]; int i = 0; for (String value : props) { final int idx = value.indexOf(':'); Preconditions.checkState(idx > 0 && idx < value.length(), "Incorrect configuration override declaration: must be 'key: value', but found '%s'", value); overrides[i++] = ConfigOverride .config(prefix, value.substring(0, idx).trim(), value.substring(idx + 1).trim()); } } return overrides; }
Example #3
Source File: GrpcServerTests.java From dropwizard-grpc with Apache License 2.0 | 6 votes |
@Test public void createsServerWithTls() throws Exception { final DropwizardTestSupport<TestConfiguration> testSupport = new DropwizardTestSupport<>(TestApplication.class, resourceFilePath("grpc-test-config.yaml"), Optional.empty(), ConfigOverride.config("grpcServer.certChainFile", getURIForResource("cert/server.crt")), ConfigOverride.config("grpcServer.privateKeyFile", getURIForResource("cert/server.key"))); ManagedChannel channel = null; try { testSupport.before(); channel = createClientChannelForEncryptedServer(testSupport); final PersonServiceGrpc.PersonServiceBlockingStub client = PersonServiceGrpc.newBlockingStub(channel); final GetPersonResponse resp = client.getPerson(GetPersonRequest.newBuilder().setName(TEST_PERSON_NAME).build()); assertEquals(TEST_PERSON_NAME, resp.getPerson().getName()); } finally { testSupport.after(); shutdownChannel(channel); } }
Example #4
Source File: EndToEndTest.java From dropwizard-pac4j with Apache License 2.0 | 6 votes |
@Test public void grantsAccessToResourcesForm() throws Exception { setup(ConfigOverride.config("pac4j.globalFilters[0].clients", DirectFormClient.class.getSimpleName())); // username == password Form form = new Form(); form.param("username", "rosebud"); form.param("password", "rosebud"); final String dogName = client.target(getUrlPrefix() + "/dogs/pierre") .request(MediaType.APPLICATION_JSON) .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), String.class); assertThat(dogName).isEqualTo("pierre"); }
Example #5
Source File: EndToEndServletTest.java From dropwizard-pac4j with Apache License 2.0 | 6 votes |
@Test public void grantsAccessToResourcesForm() throws Exception { setup(ConfigOverride.config("pac4j.servlet.security[0].clients", DirectFormClient.class.getSimpleName())); // username == password Form form = new Form(); form.param("username", "rosebud"); form.param("password", "rosebud"); final String dogName = client.target(getUrlPrefix() + "/dogs/pierre") .request(MediaType.APPLICATION_JSON) .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), String.class); assertThat(dogName).isEqualTo("pierre"); }
Example #6
Source File: VerifyServiceProviderAppRule.java From verify-service-provider with MIT License | 6 votes |
public VerifyServiceProviderAppRule(String secondaryEncryptionKey, String serviceEntityIdOverride) { super( VerifyServiceProviderApplication.class, "verify-service-provider.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("europeanIdentity.enabled", "false"), ConfigOverride.config("europeanIdentity.hubConnectorEntityId", "dummyEntity"), ConfigOverride.config("europeanIdentity.trustAnchorUri", "http://dummy.com"), ConfigOverride.config("europeanIdentity.metadataSourceUri", "http://dummy.com"), ConfigOverride.config("europeanIdentity.trustStore.path", KEY_STORE_RESOURCE.getAbsolutePath()), ConfigOverride.config("europeanIdentity.trustStore.password", KEY_STORE_RESOURCE.getPassword()) ); }
Example #7
Source File: NonMatchingVerifyServiceProviderAppRule.java From verify-service-provider with MIT License | 6 votes |
public NonMatchingVerifyServiceProviderAppRule() { super( VerifyServiceProviderApplication.class, "configuration/vsp-no-eidas.yml", ConfigOverride.config("serviceEntityIds", TEST_RP), 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("verifyHubConfiguration.metadata.uri", verifyMetadataServer::getUri), ConfigOverride.config("verifyHubConfiguration.metadata.trustStore.path", metadataTrustStore.getAbsolutePath()), ConfigOverride.config("verifyHubConfiguration.metadata.trustStore.password", metadataTrustStore.getPassword()), ConfigOverride.config("samlPrimaryEncryptionKey", TEST_RP_PRIVATE_ENCRYPTION_KEY) ); }
Example #8
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 #9
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 #10
Source File: ConfigOverrideUtils.java From dropwizard-guicey with MIT License | 5 votes |
/** * Adds config override for existing overrides array. * * @param base existing overrides (may be null) * @param addition additional overrides (may be empty) * @return merged overrides */ @SuppressWarnings("checkstyle:ReturnCount") public static ConfigOverride[] merge(final ConfigOverride[] base, final ConfigOverride... addition) { if (addition.length == 0) { return base; } if (base == null) { return addition; } final ConfigOverride[] res = new ConfigOverride[base.length + addition.length]; System.arraycopy(base, 0, res, 0, base.length); System.arraycopy(addition, 0, res, base.length, addition.length); return res; }
Example #11
Source File: TestDropwizardAppExtension.java From dropwizard-guicey with MIT License | 5 votes |
private ConfigOverride[] buildConfigOverrides(final String prefix) { ConfigOverride[] overrides = ConfigOverrideUtils.convert(prefix, config.configOverrides); if (!Strings.isNullOrEmpty(config.restMapping)) { String mapping = PathUtils.leadingSlash(config.restMapping); if (!mapping.endsWith(STAR)) { mapping = PathUtils.trailingSlash(mapping) + STAR; } overrides = ConfigOverrideUtils.merge(overrides, ConfigOverride.config(prefix, "server.rootPath", mapping)); } return overrides; }
Example #12
Source File: GuiceyAppRule.java From dropwizard-guicey with MIT License | 5 votes |
public GuiceyAppRule(final Class<? extends Application<C>> applicationClass, @Nullable final String configPath, final ConfigOverride... configOverrides) { this.applicationClass = applicationClass; this.configPath = configPath; for (ConfigOverride configOverride : configOverrides) { configOverride.addToSystemProperties(); } }
Example #13
Source File: AbstractAppExtension.java From dropwizard-guicey with MIT License | 5 votes |
/** * Utility method to convert configuration overrides from annotation to rule compatible format. * * @param overrides override annotations * @return dropwizard config override objects */ protected ConfigOverride[] convertOverrides( final ru.vyarus.dropwizard.guice.test.spock.ConfigOverride... overrides) { final ConfigOverride[] configOverride = new ConfigOverride[overrides.length]; int i = 0; for (ru.vyarus.dropwizard.guice.test.spock.ConfigOverride override : overrides) { configOverride[i++] = ConfigOverride.config(override.key(), override.value()); } return configOverride; }
Example #14
Source File: DropwizardAppExtension.java From dropwizard-guicey with MIT License | 5 votes |
private ConfigOverride[] buildConfigOverrides(final UseDropwizardApp annotation) { ConfigOverride[] overrides = convertOverrides(annotation.configOverride()); if (!Strings.isNullOrEmpty(annotation.restMapping())) { String mapping = PathUtils.leadingSlash(annotation.restMapping()); if (!mapping.endsWith(STAR)) { mapping = PathUtils.trailingSlash(mapping) + STAR; } overrides = ConfigOverrideUtils.merge(overrides, ConfigOverride.config("server.rootPath", mapping)); } return overrides; }
Example #15
Source File: GuiceyAppExtension.java From dropwizard-guicey with MIT License | 5 votes |
@SuppressWarnings({"unchecked", "checkstyle:Indentation"}) private <C extends Configuration> DropwizardTestSupport<C> create( final Class<? extends Application> app, final String configPath, final ConfigOverride... overrides) { return new DropwizardTestSupport<C>((Class<? extends Application<C>>) app, configPath, (String) null, application -> { command = new TestCommand<>(application); return command; }, overrides); }
Example #16
Source File: EndToEndTest.java From dropwizard-pac4j with Apache License 2.0 | 5 votes |
@Test public void restrictsAccessToResources() throws Exception { setup(ConfigOverride.config("pac4j.globalFilters[0].clients", DirectBasicAuthClient.class.getSimpleName())); final Response response = client.target(getUrlPrefix() + "/dogs/pierre") .request(MediaType.APPLICATION_JSON) // username != password .header(HttpHeaders.AUTHORIZATION, mkAuthField("boy", "howdy")) .get(); assertThat(response.getStatusInfo()) .isEqualTo(Response.Status.UNAUTHORIZED); }
Example #17
Source File: EndToEndTest.java From dropwizard-pac4j with Apache License 2.0 | 5 votes |
@Test public void grantsAccessToResources() throws Exception { setup(ConfigOverride.config("pac4j.globalFilters[0].clients", DirectBasicAuthClient.class.getSimpleName())); final String dogName = client.target(getUrlPrefix() + "/dogs/pierre") .request(MediaType.APPLICATION_JSON) // username == password .header(HttpHeaders.AUTHORIZATION, mkAuthField("rosebud", "rosebud")) .get(String.class); assertThat(dogName).isEqualTo("pierre"); }
Example #18
Source File: NonMatchingVerifyServiceProviderAppRule.java From verify-service-provider with MIT License | 5 votes |
public NonMatchingVerifyServiceProviderAppRule(boolean isEidasEnabled) { super( VerifyServiceProviderApplication.class, "verify-service-provider.yml", ConfigOverride.config("serviceEntityIds", TEST_RP), ConfigOverride.config("hashingEntityId", "some-hashing-entity-id"), ConfigOverride.config("server.connector.port", String.valueOf(0)), ConfigOverride.config("logging.loggers.uk\\.gov", "DEBUG"), ConfigOverride.config("logging.level", "WARN"), ConfigOverride.config("samlSigningKey", TEST_RP_PRIVATE_SIGNING_KEY), ConfigOverride.config("verifyHubConfiguration.environment", "COMPLIANCE_TOOL"), ConfigOverride.config("verifyHubConfiguration.metadata.uri", verifyMetadataServer::getUri), ConfigOverride.config("verifyHubConfiguration.metadata.trustStore.path", metadataTrustStore.getAbsolutePath()), ConfigOverride.config("verifyHubConfiguration.metadata.trustStore.password", metadataTrustStore.getPassword()), ConfigOverride.config("verifyHubConfiguration.metadata.hubTrustStore.path", hubTrustStore.getAbsolutePath()), ConfigOverride.config("verifyHubConfiguration.metadata.hubTrustStore.password", hubTrustStore.getPassword()), ConfigOverride.config("verifyHubConfiguration.metadata.idpTrustStore.path", idpTrustStore.getAbsolutePath()), ConfigOverride.config("verifyHubConfiguration.metadata.idpTrustStore.password", idpTrustStore.getPassword()), ConfigOverride.config("samlPrimaryEncryptionKey", TEST_RP_PRIVATE_ENCRYPTION_KEY), ConfigOverride.config("europeanIdentity.hubConnectorEntityId", HUB_CONNECTOR_ENTITY_ID), ConfigOverride.config("europeanIdentity.enabled", isEidasEnabled ? "true" : "false"), ConfigOverride.config("europeanIdentity.trustAnchorUri", trustAnchorServer::getUri), ConfigOverride.config("europeanIdentity.metadataSourceUri", metadataAggregatorServer::getUri), ConfigOverride.config("europeanIdentity.trustStore.path", countryMetadataTrustStore.getAbsolutePath()), ConfigOverride.config("europeanIdentity.trustStore.password", countryMetadataTrustStore.getPassword()) ); }
Example #19
Source File: EndToEndServletTest.java From dropwizard-pac4j with Apache License 2.0 | 5 votes |
@Test public void restrictsAccessToResources() throws Exception { setup(ConfigOverride.config("pac4j.servlet.security[0].clients", DirectBasicAuthClient.class.getSimpleName())); final Response response = client.target(getUrlPrefix() + "/dogs/pierre") .request(MediaType.APPLICATION_JSON) // username != password .header(HttpHeaders.AUTHORIZATION, mkAuthField("boy", "howdy")) .get(); assertThat(response.getStatusInfo()) .isEqualTo(Response.Status.UNAUTHORIZED); }
Example #20
Source File: EndToEndServletTest.java From dropwizard-pac4j with Apache License 2.0 | 5 votes |
@Test public void grantsAccessToResources() throws Exception { setup(ConfigOverride.config("pac4j.servlet.security[0].clients", DirectBasicAuthClient.class.getSimpleName())); final String dogName = client.target(getUrlPrefix() + "/dogs/pierre") .request(MediaType.APPLICATION_JSON) // username == password .header(HttpHeaders.AUTHORIZATION, mkAuthField("rosebud", "rosebud")) .get(String.class); assertThat(dogName).isEqualTo("pierre"); }
Example #21
Source File: ApplicationConfigurationFeatureTests.java From verify-service-provider with MIT License | 5 votes |
@Before public void setUp() { application = new DropwizardAppRule<>( VerifyServiceProviderApplication.class, "verify-service-provider.yml", ConfigOverride.config("logging.loggers.uk\\.gov", "DEBUG") ); }
Example #22
Source File: EndToEndTest.java From dropwizard-pac4j with Apache License 2.0 | 4 votes |
private void setup(ConfigOverride config) { super.setup(App.class, "end-to-end-test.yaml", config); }
Example #23
Source File: EndToEndServletTest.java From dropwizard-pac4j with Apache License 2.0 | 4 votes |
private void setup(ConfigOverride config) { super.setup(App.class, "end-to-end-servlet-test.yaml", config); }