use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class AccepttoMultifactorAuthenticationHandlerTests method verifyOperationApproved.
@Test
public void verifyOperationApproved() throws Exception {
val data = MAPPER.writeValueAsString(CollectionUtils.wrap("device_id", "deviceid-test", "status", "approved"));
try (val webServer = new MockWebServer(5002, new ByteArrayResource(data.getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.OK)) {
webServer.start();
val handler = buildHandler();
val credential = new AccepttoMultifactorTokenCredential("test-channel");
assertTrue(handler.supports(credential));
assertTrue(handler.supports(AccepttoMultifactorTokenCredential.class));
val result = handler.authenticate(credential);
assertNotNull(result.getPrincipal());
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestfulAccountRegistrationProvisionerTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
try (val webServer = new MockWebServer(5002, HttpStatus.OK)) {
webServer.start();
val registrationRequest = new AccountRegistrationRequest(Map.of("username", "casuser"));
val results = accountMgmtRegistrationProvisioner.provision(registrationRequest);
assertTrue(results.isSuccess());
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestfulAccountRegistrationProvisionerTests method verifyOperationFails.
@Test
public void verifyOperationFails() throws Exception {
try (val webServer = new MockWebServer(5002, HttpStatus.INTERNAL_SERVER_ERROR)) {
webServer.start();
val registrationRequest = new AccountRegistrationRequest(Map.of("username", "casuser"));
val results = accountMgmtRegistrationProvisioner.provision(registrationRequest);
assertFalse(results.isSuccess());
}
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class RestfulCloudConfigBootstrapConfigurationTests method setup.
@BeforeAll
public static void setup() throws Exception {
val response = MAPPER.writeValueAsString(Map.of("cas.authn.accept.users", STATIC_AUTHN_USERS));
System.setProperty(RestfulPropertySourceLocator.CAS_CONFIGURATION_PREFIX + '.' + "url", "http://localhost:9345");
SERVER = new MockWebServer(9345, new ByteArrayResource(response.getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.TOO_MANY_REQUESTS);
SERVER.start();
}
use of org.apereo.cas.util.MockWebServer in project cas by apereo.
the class OktaConfigurationFactoryTests method verifyOperation.
@Test
public void verifyOperation() {
try (val webServer = new MockWebServer(8923, HttpStatus.OK)) {
webServer.start();
assertNotNull(OktaConfigurationFactory.buildAuthenticationClient(casProperties.getAuthn().getOkta()));
assertThrows(OAuth2TokenRetrieverException.class, () -> OktaConfigurationFactory.buildClient(casProperties.getAuthn().getAttributeRepository().getOkta()));
}
}
Aggregations