use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestfulPasswordlessTokenRepositoryTests method verifyClean.
@Test
public void verifyClean() {
try (val webServer = new MockWebServer(9293, new ByteArrayResource(StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
webServer.start();
passwordlessTokenRepository.clean();
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestfulPasswordlessTokenRepositoryTests method verifyFindTokenFails.
@Test
public void verifyFindTokenFails() {
try (val webServer = new MockWebServer(9306, new ByteArrayResource("token".getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
webServer.start();
val tokens = new CasConfigurationProperties().getAuthn().getPasswordless().getTokens();
tokens.getRest().setUrl("http://localhost:9306");
val passwordless = new RestfulPasswordlessTokenRepository(tokens.getExpireInSeconds(), tokens.getRest(), passwordlessCipherExecutor);
val foundToken = passwordless.findToken("casuser");
assertTrue(foundToken.isEmpty());
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestfulPasswordlessTokenRepositoryTests method verifyDeleteToken.
@Test
public void verifyDeleteToken() {
try (val webServer = new MockWebServer(9293, new ByteArrayResource(StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
webServer.start();
passwordlessTokenRepository.deleteToken("casuser", "123456");
passwordlessTokenRepository.deleteTokens("casuser");
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class ClickatellSmsSenderTests method verifyError.
@Test
public void verifyError() {
val data = '{' + "\"messages\": [" + "]," + "\"error\": \"error message\"," + "\"accepted\": \"false\"" + '}';
try (val webServer = new MockWebServer(8099, new ByteArrayResource(data.getBytes(UTF_8), "Output"), OK)) {
webServer.start();
assertFalse(smsSender.send("123-456-7890", "123-456-7890", "TEST"));
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class SmsModeSmsSenderTests method verifyOperation.
@Test
public void verifyOperation() {
assertNotNull(smsSender);
assertFalse(smsSender.send("123-456-7890", "123-456-7890", "TEST"));
try (val webServer = new MockWebServer(8099, new ByteArrayResource("0".getBytes(UTF_8), "Output"), OK)) {
webServer.start();
assertTrue(smsSender.send("123-456-7890", "123-456-7890", "TEST"));
}
}
Aggregations