Java Code Examples for io.dropwizard.testing.ConfigOverride#config()

The following examples show how to use io.dropwizard.testing.ConfigOverride#config() . 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 vote down vote up
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 2
Source File: VerifyServiceProviderAppRule.java    From verify-service-provider with MIT License 6 votes vote down vote up
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 3
Source File: NonMatchingVerifyServiceProviderAppRule.java    From verify-service-provider with MIT License 6 votes vote down vote up
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 4
Source File: GrpcServerTests.java    From dropwizard-grpc with Apache License 2.0 6 votes vote down vote up
@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 5
Source File: ConfigOverrideUtils.java    From dropwizard-guicey with MIT License 6 votes vote down vote up
/**
 * @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 6
Source File: NonMatchingVerifyServiceProviderAppRule.java    From verify-service-provider with MIT License 5 votes vote down vote up
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 7
Source File: ApplicationConfigurationFeatureTests.java    From verify-service-provider with MIT License 5 votes vote down vote up
@Before
public void setUp() {
    application = new DropwizardAppRule<>(
        VerifyServiceProviderApplication.class,
            "verify-service-provider.yml",
        ConfigOverride.config("logging.loggers.uk\\.gov", "DEBUG")
    );
}
 
Example 8
Source File: AbstractAppExtension.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
/**
 * 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 9
Source File: SetUpTest.java    From oxd with Apache License 2.0 5 votes vote down vote up
@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.");
    }
}