use of org.apereo.cas.oidc.discovery.webfinger.userinfo.OidcRestfulWebFingerUserInfoRepository in project cas by apereo.
the class OidcRestfulWebFingerUserInfoRepositoryTests method verifyFindByEmail.
@Test
public void verifyFindByEmail() throws Exception {
var data = MAPPER.writeValueAsString(CollectionUtils.wrap("email", "cas@example.org"));
try (val webServer = new MockWebServer(9312, new ByteArrayResource(data.getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
this.webServer = webServer;
this.webServer.start();
assertTrue(this.webServer.isRunning());
val props = new RestEndpointProperties();
props.setUrl("http://localhost:9312");
val repo = new OidcRestfulWebFingerUserInfoRepository(props);
val results = repo.findByEmailAddress("cas@example.org");
assertNotNull(results);
assertTrue(results.containsKey("email"));
assertEquals("cas@example.org", results.get("email"));
}
}
use of org.apereo.cas.oidc.discovery.webfinger.userinfo.OidcRestfulWebFingerUserInfoRepository in project cas by apereo.
the class OidcRestfulWebFingerUserInfoRepositoryTests method verifyBadPayload.
@Test
public void verifyBadPayload() throws Exception {
try (val webServer = new MockWebServer(9312, new ByteArrayResource("-@@-".getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
this.webServer = webServer;
this.webServer.start();
assertTrue(this.webServer.isRunning());
val props = new RestEndpointProperties();
props.setUrl("http://localhost:9312");
val repo = new OidcRestfulWebFingerUserInfoRepository(props);
val results = repo.findByEmailAddress("cas@example.org");
assertTrue(results.isEmpty());
}
}
use of org.apereo.cas.oidc.discovery.webfinger.userinfo.OidcRestfulWebFingerUserInfoRepository in project cas by apereo.
the class OidcRestfulWebFingerUserInfoRepositoryTests method verifyFindByUsername.
@Test
public void verifyFindByUsername() throws Exception {
var data = MAPPER.writeValueAsString(CollectionUtils.wrap("username", "casuser"));
try (val webServer = new MockWebServer(9312, new ByteArrayResource(data.getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
this.webServer = webServer;
this.webServer.start();
assertTrue(this.webServer.isRunning());
val props = new RestEndpointProperties();
props.setUrl("http://localhost:9312");
val repo = new OidcRestfulWebFingerUserInfoRepository(props);
val results = repo.findByUsername("casuser");
assertNotNull(results);
assertTrue(results.containsKey("username"));
assertEquals("casuser", results.get("username"));
}
}
Aggregations