Search in sources :

Example 1 with PublicKeyHelper

use of org.eclipse.vorto.repository.oauth.internal.PublicKeyHelper in project vorto by eclipse.

the class PublicKeyHelperTest method testPublicKeyVerifier.

@Test
public void testPublicKeyVerifier() {
    RestTemplate restTemplate = Mockito.mock(RestTemplate.class);
    Mockito.when(restTemplate.getForObject(CIAM_PUBLIC_KEY_URI, Keys.class)).thenReturn(getCiamKeys());
    Mockito.when(restTemplate.getForObject(KEYCLOAK_PUBLIC_KEY_URI, Keys.class)).thenReturn(getKeyCloakKeys());
    PublicKeyHelper helper = PublicKeyHelper.instance(restTemplate);
    assertFalse(helper.getPublicKey(CIAM_PUBLIC_KEY_URI).isEmpty());
    assertEquals(helper.getPublicKey(CIAM_PUBLIC_KEY_URI).size(), 2);
    assertFalse(helper.getPublicKey(KEYCLOAK_PUBLIC_KEY_URI).isEmpty());
    assertEquals(helper.getPublicKey(KEYCLOAK_PUBLIC_KEY_URI).size(), 1);
}
Also used : PublicKeyHelper(org.eclipse.vorto.repository.oauth.internal.PublicKeyHelper) RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test)

Aggregations

PublicKeyHelper (org.eclipse.vorto.repository.oauth.internal.PublicKeyHelper)1 Test (org.junit.Test)1 RestTemplate (org.springframework.web.client.RestTemplate)1