use of org.commonjava.indy.subsys.http.conf.IndyHttpConfig in project indy by Commonjava.
the class IndySiteConfigLookupTest method checkHttpConfigLoad.
@Test
public void checkHttpConfigLoad() throws Exception {
File pemFile = testFolder.newFile("keycloak.pem");
final String _URI = "http://site.com";
final String _PROXY_HOST = "http://proxy.com";
final String _PROXY_PORT = "8001";
final String _PEM = "AAAAFFFFFSDADFADSFASDFASDFASDFASDFASDF";
final String _KEY_PASSWORD = "testme";
final String _KEYCLOAK_URI = "http://keycloak.com";
final String _KEYCLOAK_PEM_PATH = pemFile.getAbsolutePath();
IOUtils.write(_PEM, new FileOutputStream(pemFile));
final class TestIndyHttpConfig extends IndyHttpConfig {
@Override
public Map<String, String> getConfiguration() {
Map<String, String> parameters = new HashMap<>();
parameters.put("uri", _URI);
parameters.put("proxy.host", _PROXY_HOST);
parameters.put("proxy.port", _PROXY_PORT);
parameters.put("key.cert.pem", _PEM);
parameters.put("key.password", _KEY_PASSWORD);
parameters.put("keycloak_yourdomain_com.uri", _KEYCLOAK_URI);
parameters.put("keycloak_yourdomain_com.key.cert.pem.path", _KEYCLOAK_PEM_PATH);
return parameters;
}
}
IndyHttpConfig config = new TestIndyHttpConfig();
config.sectionComplete("http");
IndySiteConfigLookup lookup = new IndySiteConfigLookup(null, config);
SiteConfig siteConfig = lookup.lookup(DEFAULT_SITE);
assertThat(siteConfig.getUri(), equalTo(_URI));
assertThat(siteConfig.getProxyHost(), equalTo(_PROXY_HOST));
assertThat(siteConfig.getProxyPort(), equalTo(Integer.parseInt(_PROXY_PORT)));
assertThat(siteConfig.getKeyCertPem(), equalTo(_PEM));
assertThat(siteConfig.getAttribute(PASSWORD_PREFIX + PasswordType.KEY.name()), equalTo(_KEY_PASSWORD));
SiteConfig keycloakConfig = lookup.lookup("keycloak.yourdomain.com");
assertThat(keycloakConfig.getUri(), equalTo(_KEYCLOAK_URI));
assertThat(keycloakConfig.getKeyCertPem(), equalTo(_PEM));
}
Aggregations