use of com.xebialabs.restito.server.StubServer in project ddf by codice.
the class TestOidc method beforeTest.
@BeforeExam
public void beforeTest() {
try {
getServiceManager().waitForAllBundles();
getServiceManager().waitForHttpEndpoint(WHO_AM_I_URL.getUrl());
getServiceManager().waitForHttpEndpoint(SERVICE_ROOT + "/catalog/query");
oldPolicyManagerProps = getSecurityPolicy().configureWebContextPolicy(OIDC_AUTH_TYPES, OIDC_AUTH_TYPES, null, null);
// start stub server
server = new StubServer(Integer.parseInt(IDP_PORT.getPort())).run();
server.start();
// Generate the RSA key pair
KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
gen.initialize(2048);
KeyPair keyPair = gen.generateKeyPair();
RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
// Convert to JSON Web Key (JWK) format
JWK sigJwk = new RSAKey.Builder(publicKey).privateKey(privateKey).keyUse(KeyUse.SIGNATURE).keyID(UUID.randomUUID().toString()).build();
jwk = "{\"keys\": [" + sigJwk.toPublicJWK().toJSONString() + "] }";
validAlgorithm = Algorithm.RSA256(publicKey, privateKey);
invalidAlgorithm = Algorithm.HMAC256("WRONG");
setUp();
// Configure OIDC Handler
handlerConfig = new Hashtable<>();
handlerConfig.put("idpType", "Keycloak");
handlerConfig.put("clientId", DDF_CLIENT_ID);
handlerConfig.put("realm", "master");
handlerConfig.put(SECRET, DDF_CLIENT_SECRET);
handlerConfig.put("logoutUri", URL_START.toString() + LOGOUT_URL_PATH);
handlerConfig.put("baseUri", URL_START.toString() + "/auth");
handlerConfig.put("discoveryUri", URL_START.toString() + METADATA_PATH);
handlerConfig.put(SCOPE, DDF_SCOPE);
handlerConfig.put("useNonce", true);
handlerConfig.put("responseMode", FORM_POST);
setConfig();
} catch (Exception e) {
LoggingUtils.failWithThrowableStacktrace(e, "Failed in @BeforeExam: ");
}
}
Aggregations