use of org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties 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.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties 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.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties in project cas by apereo.
the class RestGoogleAuthenticatorTokenCredentialRepositoryTests method verifySave.
@Test
public void verifySave() throws Exception {
val props = new GoogleAuthenticatorMultifactorProperties();
props.getRest().setUrl("http://localhost:8553");
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(8553, new ByteArrayResource(entity.getBytes(UTF_8), "Output"), OK)) {
webServer.start();
assertDoesNotThrow(new Executable() {
@Override
public void execute() {
val toSave = OneTimeTokenAccount.builder().username(account.getUsername()).secretKey(account.getSecretKey()).validationCode(0).scratchCodes(List.of()).name(UUID.randomUUID().toString()).build();
repo.save(toSave);
}
});
}
}
use of org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties in project cas by apereo.
the class RestGoogleAuthenticatorTokenCredentialRepositoryTests method verifySaveFail.
@Test
public void verifySaveFail() {
val props = new GoogleAuthenticatorMultifactorProperties();
props.getRest().setUrl("http://localhost:8554");
val repo = new RestGoogleAuthenticatorTokenCredentialRepository(googleAuthenticatorInstance, props, CipherExecutor.noOpOfStringToString());
val account = repo.create(UUID.randomUUID().toString());
try (val webServer = new MockWebServer(8554, new ByteArrayResource(StringUtils.EMPTY.getBytes(UTF_8), "Output"), HttpStatus.BAD_REQUEST)) {
webServer.start();
assertNull(repo.update(account));
}
}
use of org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties in project cas by apereo.
the class RestGoogleAuthenticatorTokenCredentialRepositoryTests method verifyDelete.
@Test
public void verifyDelete() {
val props = new GoogleAuthenticatorMultifactorProperties();
props.getRest().setUrl("http://localhost:8550");
val repo = new RestGoogleAuthenticatorTokenCredentialRepository(googleAuthenticatorInstance, props, CipherExecutor.noOpOfStringToString());
try (val webServer = new MockWebServer(8550, new ByteArrayResource("1".getBytes(UTF_8), "Output"), OK)) {
webServer.start();
assertDoesNotThrow(new Executable() {
@Override
public void execute() {
repo.delete("casuser");
repo.delete(12345);
repo.deleteAll();
}
});
}
}
Aggregations