use of io.gravitee.am.model.jose.JWK in project gravitee-access-management by gravitee-io.
the class JWKServiceTest method testFilter_AES_256_keys.
@Test
public void testFilter_AES_256_keys() {
TestObserver testObserver = jwkService.filter(JWK_SET, JWKFilter.OCT_KEY_ENCRYPTION(JWEAlgorithm.A256KW)).test();
testObserver.assertNoErrors();
testObserver.assertComplete();
testObserver.assertValue(jwk -> ((JWK) jwk).getKid().equals("octEnc256"));
testObserver = jwkService.filter(JWK_SET, JWKFilter.OCT_KEY_ENCRYPTION(JWEAlgorithm.A256GCMKW)).test();
testObserver.assertNoErrors();
testObserver.assertComplete();
testObserver.assertValue(jwk -> ((JWK) jwk).getKid().equals("octEnc256"));
}
use of io.gravitee.am.model.jose.JWK in project gravitee-access-management by gravitee-io.
the class JWKServiceTest method testFilter_OKP.
@Test
public void testFilter_OKP() {
OKPKey okpEnc = new OKPKey();
okpEnc.setKty("OKP");
okpEnc.setKid("okpEnc");
okpEnc.setCrv("X25519");
OKPKey okpSig = new OKPKey();
okpSig.setKty("OKP");
okpSig.setKid("okpSig");
okpSig.setCrv("Ed25519");
JWKSet okpSet = new JWKSet();
okpSet.setKeys(Arrays.asList(okpEnc, okpSig));
TestObserver testObserver = jwkService.filter(okpSet, JWKFilter.CURVE_KEY_ENCRYPTION()).test();
testObserver.assertNoErrors();
testObserver.assertComplete();
testObserver.assertValue(jwk -> ((JWK) jwk).getKid().equals("okpEnc"));
}
use of io.gravitee.am.model.jose.JWK in project gravitee-access-management by gravitee-io.
the class JWKServiceTest method testGetKey_noKFound.
@Test
public void testGetKey_noKFound() {
JWK jwk = Mockito.mock(JWK.class);
JWKSet jwkSet = new JWKSet();
jwkSet.setKeys(Arrays.asList(jwk));
when(jwk.getKid()).thenReturn("notTheExpectedOne");
TestObserver testObserver = jwkService.getKey(jwkSet, "expectedKid").test();
testObserver.assertNoErrors();
testObserver.assertComplete();
// Expect empty result
testObserver.assertResult();
}
use of io.gravitee.am.model.jose.JWK in project gravitee-access-management by gravitee-io.
the class ProviderJWKSetEndpointHandlerTest method shouldInvokeJWKSetEndpoint.
@Test
public void shouldInvokeJWKSetEndpoint() throws Exception {
JWK jwk = new RSAKey();
jwk.setKty("RSA");
jwk.setKid("my-test-key");
JWKSet jwkSet = new JWKSet();
jwkSet.setKeys(Collections.singletonList(jwk));
when(jwkService.getKeys()).thenReturn(Single.just(jwkSet));
testRequest(HttpMethod.GET, "/.well-known/jwks.json", HttpStatusCode.OK_200, "OK", "{\n" + " \"keys\" : [ {\n" + " \"kty\" : \"RSA\",\n" + " \"kid\" : \"my-test-key\"\n" + " } ]\n" + "}");
}
use of io.gravitee.am.model.jose.JWK in project gravitee-access-management by gravitee-io.
the class JWKServiceTest method testFilter_EC.
@Test
public void testFilter_EC() {
TestObserver testObserver = jwkService.filter(JWK_SET, JWKFilter.CURVE_KEY_ENCRYPTION()).test();
testObserver.assertNoErrors();
testObserver.assertComplete();
testObserver.assertValue(jwk -> ((JWK) jwk).getKid().equals("ecEnc"));
}
Aggregations