use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestGoogleAuthenticatorTokenCredentialRepositoryTests method verifyCount.
@Test
public void verifyCount() {
val props = new GoogleAuthenticatorMultifactorProperties();
props.getRest().setUrl("http://localhost:8552");
val repo = new RestGoogleAuthenticatorTokenCredentialRepository(googleAuthenticatorInstance, props, CipherExecutor.noOpOfStringToString());
try (val webServer = new MockWebServer(8552, new ByteArrayResource("1".getBytes(UTF_8), "Output"), OK)) {
webServer.start();
assertEquals(1, repo.count());
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestGoogleAuthenticatorTokenCredentialRepositoryTests method verifyCountByUser.
@Test
public void verifyCountByUser() {
val props = new GoogleAuthenticatorMultifactorProperties();
props.getRest().setUrl("http://localhost:8596");
val repo = new RestGoogleAuthenticatorTokenCredentialRepository(googleAuthenticatorInstance, props, CipherExecutor.noOpOfStringToString());
try (val webServer = new MockWebServer(8596, new ByteArrayResource("1".getBytes(UTF_8), "Output"), OK)) {
webServer.start();
assertEquals(1, repo.count("casuser"));
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestGoogleAuthenticatorTokenCredentialRepositoryTests method verifyGetByIdAndUser.
@Test
public void verifyGetByIdAndUser() throws Exception {
val props = new GoogleAuthenticatorMultifactorProperties();
props.getRest().setUrl("http://localhost:8552");
val repo = new RestGoogleAuthenticatorTokenCredentialRepository(googleAuthenticatorInstance, props, CipherExecutor.noOpOfStringToString());
val account = repo.create(UUID.randomUUID().toString());
val entity = MAPPER.writeValueAsString(account);
try (val webServer = new MockWebServer(8552, new ByteArrayResource(entity.getBytes(UTF_8), "Results"), OK)) {
webServer.start();
assertNotNull(repo.get(account.getUsername(), account.getId()));
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestfulPasswordlessUserAccountStoreTests method verifyFailsAction.
@Test
public void verifyFailsAction() {
try (val webServer = new MockWebServer(9291, new ByteArrayResource("###".getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
webServer.start();
val user = passwordlessUserAccountStore.findUser("casuser");
assertTrue(user.isEmpty());
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestAuthenticationHandlerTests method verifyUnauthorized.
@Test
public void verifyUnauthorized() {
try (val webServer = new MockWebServer(8081, HttpStatus.UNAUTHORIZED)) {
webServer.start();
assertThrows(FailedLoginException.class, () -> authenticationHandler.authenticate(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword()));
}
}
Aggregations