use of org.apereo.cas.configuration.model.core.authentication.AdaptiveAuthenticationProperties in project cas by apereo.
the class BlackDotIPAddressIntelligenceServiceTests method verifyBadResponse.
@Test
public void verifyBadResponse() {
try (val webServer = new MockWebServer(9319, new ByteArrayResource("${bad-json$".getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.OK)) {
webServer.start();
val props = new AdaptiveAuthenticationProperties();
props.getIpIntel().getBlackDot().setUrl("http://localhost:9319?ip=%s");
props.getIpIntel().getBlackDot().setMode("DYNA_CHECK");
props.getIpIntel().getBlackDot().setEmailAddress("cas@apereo.org");
val service = new BlackDotIPAddressIntelligenceService(props);
val response = service.examine(new MockRequestContext(), "37.58.59.181");
assertTrue(response.isBanned());
}
}
use of org.apereo.cas.configuration.model.core.authentication.AdaptiveAuthenticationProperties in project cas by apereo.
the class GroovyIPAddressIntelligenceServiceTests method verifyOperation.
@Test
public void verifyOperation() {
val script = new ClassPathResource("GroovyIPAddressIntelligenceService.groovy");
val props = new AdaptiveAuthenticationProperties();
props.getIpIntel().getGroovy().setLocation(script);
val service = new GroovyIPAddressIntelligenceService(props);
val response = service.examine(new MockRequestContext(), "1.2.3.4");
assertTrue(response.isBanned());
}
Aggregations