use of org.apereo.cas.configuration.model.RestEndpointProperties 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"));
}
}
use of org.apereo.cas.configuration.model.RestEndpointProperties in project cas by apereo.
the class RestfulPrincipalFactoryTests method verifyNullPrincipal.
@Test
public void verifyNullPrincipal() throws Exception {
val entity = MAPPER.writeValueAsString(CoreAuthenticationTestUtils.getPrincipal("casuser"));
try (val webServer = new MockWebServer(9156, new ByteArrayResource(entity.getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.EXPECTATION_FAILED)) {
webServer.start();
val props = new RestEndpointProperties();
props.setUrl("http://localhost:9156");
val factory = PrincipalFactoryUtils.newRestfulPrincipalFactory(props);
val p = factory.createPrincipal("casuser", CollectionUtils.wrap("name", List.of("CAS")));
assertNull(p);
}
}
Aggregations