use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestMultifactorAuthenticationTrustStorageTests method verifySetAnExpireByKey.
@Test
public void verifySetAnExpireByKey() throws Exception {
val r = MultifactorAuthenticationTrustRecord.newInstance("casuser", "geography", "fingerprint");
val data = MAPPER.writeValueAsString(CollectionUtils.wrap(r));
try (val webServer = new MockWebServer(9297, new ByteArrayResource(data.getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
webServer.start();
mfaTrustEngine.save(r);
val records = mfaTrustEngine.get("casuser");
assertNotNull(records);
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestfulWebAuthnCredentialRepositoryTests method verifyUpdate.
@Test
public void verifyUpdate() {
try (val webServer = new MockWebServer(9559, HttpStatus.OK)) {
webServer.start();
webAuthnCredentialRepository.removeAllRegistrations("casuser");
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestfulWebAuthnCredentialRepositoryTests method assertLoadIsFound.
private void assertLoadIsFound() throws JsonProcessingException {
val records = getCredentialRegistration("casuser");
val results = cipherExecutor.encode(WebAuthnUtils.getObjectMapper().writeValueAsString(CollectionUtils.wrapList(records)));
try (val webServer = new MockWebServer(9559, new ByteArrayResource(results.getBytes(StandardCharsets.UTF_8), "REST Output"), HttpStatus.OK)) {
webServer.start();
val registration = webAuthnCredentialRepository.getRegistrationsByUserHandle(records.getUserIdentity().getId());
assertFalse(registration.isEmpty());
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestfulWebAuthnCredentialRepositoryTests method assertLoadBadInput.
private void assertLoadBadInput() {
val records = getCredentialRegistration("casuser");
try (val webServer = new MockWebServer(9559, new ByteArrayResource("_-@@-_".getBytes(StandardCharsets.UTF_8), "REST Output"), HttpStatus.OK)) {
webServer.start();
val registration = webAuthnCredentialRepository.getRegistrationsByUserHandle(records.getUserIdentity().getId());
assertTrue(registration.isEmpty());
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RemoteEndpointServiceAccessStrategyTests method verifyFails.
@Test
public void verifyFails() {
val strategy = new RemoteEndpointServiceAccessStrategy();
strategy.setEndpointUrl("http://localhost:1234");
strategy.setAcceptableResponseCodes("600");
try (val webServer = new MockWebServer(8756, new ByteArrayResource("OK".getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
webServer.start();
assertFalse(strategy.doPrincipalAttributesAllowServiceAccess("casuser", CoreAuthenticationTestUtils.getAttributes()));
}
}
Aggregations