use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestAuthenticationHandlerTests method verifyConditionFail.
@Test
public void verifyConditionFail() {
try (val webServer = new MockWebServer(8081, HttpStatus.PRECONDITION_FAILED)) {
webServer.start();
assertThrows(AccountExpiredException.class, () -> authenticationHandler.authenticate(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword()));
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestAuthenticationHandlerTests method verifyLocked.
@Test
public void verifyLocked() {
try (val webServer = new MockWebServer(8081, HttpStatus.LOCKED)) {
webServer.start();
assertThrows(AccountLockedException.class, () -> authenticationHandler.authenticate(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword()));
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestAuthenticationHandlerTests method verifyConditionReq.
@Test
public void verifyConditionReq() {
try (val webServer = new MockWebServer(8081, HttpStatus.PRECONDITION_REQUIRED)) {
webServer.start();
assertThrows(AccountPasswordMustChangeException.class, () -> authenticationHandler.authenticate(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword()));
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestAuthenticationHandlerTests method verifyDisabledAccount.
@Test
public void verifyDisabledAccount() {
try (val webServer = new MockWebServer(8081, HttpStatus.FORBIDDEN)) {
webServer.start();
assertThrows(AccountDisabledException.class, () -> authenticationHandler.authenticate(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword()));
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class SwivelTuringImageGeneratorControllerTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
val bytes = IOUtils.toByteArray(new ClassPathResource("logo.png").getInputStream());
try (val webServer = new MockWebServer(9991, new ByteArrayResource(bytes, "Output"), OK)) {
webServer.start();
val request = new MockHttpServletRequest();
request.addParameter("principal", "casuser");
val response = new MockHttpServletResponse();
assertDoesNotThrow(new Executable() {
@Override
public void execute() throws Throwable {
controller.generate(response, request);
}
});
}
}
Aggregations