use of org.apereo.cas.configuration.model.support.mfa.AccepttoMultifactorAuthenticationProperties in project cas by apereo.
the class AccepttoApiUtilsTests method verifyEmail.
@Test
public void verifyEmail() {
val authentication = CoreAuthenticationTestUtils.getAuthentication(CoreAuthenticationTestUtils.getPrincipal(Map.of("email", List.of("cas@example.org"))));
val properties = new AccepttoMultifactorAuthenticationProperties();
properties.setEmailAttribute("email");
assertNotNull(AccepttoApiUtils.getUserEmail(authentication, properties));
}
use of org.apereo.cas.configuration.model.support.mfa.AccepttoMultifactorAuthenticationProperties in project cas by apereo.
the class AccepttoApiUtilsTests method verifyUserValid.
@Test
public void verifyUserValid() throws Exception {
val properties = new AccepttoMultifactorAuthenticationProperties();
properties.setGroupAttribute("group");
properties.setEmailAttribute("email");
properties.setApplicationId("appid");
properties.setSecret("p@$$w0rd");
properties.setApiUrl("http://localhost:9289");
val principal = CoreAuthenticationTestUtils.getPrincipal(Map.of("email", List.of("cas@example.org"), "group", List.of("staff")));
val authentication = CoreAuthenticationTestUtils.getAuthentication(principal);
val data = MAPPER.writeValueAsString(Map.of("device_paired", "true"));
try (val webServer = new MockWebServer(9289, new ByteArrayResource(data.getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
webServer.start();
val user = AccepttoApiUtils.isUserValid(authentication, properties);
assertFalse(user.isEmpty());
}
}
use of org.apereo.cas.configuration.model.support.mfa.AccepttoMultifactorAuthenticationProperties in project cas by apereo.
the class AccepttoApiUtilsTests method verifyUserDevicePaired.
@Test
public void verifyUserDevicePaired() throws Exception {
val properties = new AccepttoMultifactorAuthenticationProperties();
properties.setGroupAttribute("group");
properties.setEmailAttribute("email");
properties.setApplicationId("appid");
properties.setSecret("p@$$w0rd");
properties.setApiUrl("http://localhost:9288");
val principal = CoreAuthenticationTestUtils.getPrincipal(Map.of("email", List.of("cas@example.org"), "group", List.of("staff")));
val authentication = CoreAuthenticationTestUtils.getAuthentication(principal);
val data = MAPPER.writeValueAsString(Map.of("device_paired", "true"));
try (val webServer = new MockWebServer(9288, new ByteArrayResource(data.getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
webServer.start();
assertTrue(AccepttoApiUtils.isUserDevicePaired(authentication, properties));
}
}
Aggregations