RedshiftConnectionConfig extends AbstractJdbcConnectionConfig { @VisibleForTesting public static RedshiftConnectionConfig configure(SecretProvider secrets, Config params) { return ImmutableRedshiftConnectionConfig.builder() .host(secrets.getSecretOptional("host").or(() -> params.get("host", String.class))) .port(secrets.getSecretOptional("port").transform(Integer::parseInt).or(() -> params.get("port", int.class, 5439))) .user(secrets.getSecretOptional("user").or(() -> params.get("user", String.class))) .password(getPassword(secrets, params)) .database(secrets.getSecretOptional("database").or(() -> params.get("database", String.class))) .ssl(secrets.getSecretOptional("ssl").transform(Boolean::parseBoolean).or(() -> params.get("ssl", boolean.class, false))) .connectTimeout(params.get("connect_timeout", DurationParam.class, DurationParam.of(Duration.ofSeconds(30)))) .socketTimeout(params.get("socket_timeout", DurationParam.class, DurationParam.of(Duration.ofSeconds(1800)))) .schema(secrets.getSecretOptional("schema").or(params.getOptional("schema", String.class))) .build(); }  abstract Optional<String> schema(); @VisibleForTesting static RedshiftConnectionConfig configure(SecretProvider secrets, Config params); @Override String jdbcDriverName(); @Override String jdbcProtocolName(); @Override Properties buildProperties(); @Override String toString();  }
@Test(expected = SecretNotFoundException.class) public void configureWithMissingOverriddenPassword() throws IOException { Map<String, String> configValues = ImmutableMap.<String, String>builder(). put("host", "foobar1.org"). put("port", "6543"). put("user", "user1"). put("password_override", "missing_db_password"). put("database", "database1").build(); RedshiftConnectionConfig.configure( key -> key.equals("password") ? Optional.of("password1") : Optional.absent(), jdbcOpTestHelper.createConfig(configValues) ); }