use of org.apereo.cas.services.RegisteredServiceAccessStrategyAuditableEnforcer in project cas by apereo.
the class RegisteredServiceAccessStrategyAuditableEnforcerTests method verifyAuthAndServiceAndRegisteredServicePresentButDisabled.
@Test
public void verifyAuthAndServiceAndRegisteredServicePresentButDisabled() {
val service = createRegisteredService(false);
val context = AuditableContext.builder().registeredService(service).service(createService()).authentication(createAuthentication()).build();
val result = new RegisteredServiceAccessStrategyAuditableEnforcer(new CasConfigurationProperties()).execute(context);
assertTrue(result.isExecutionFailure());
assertTrue(result.getException().isPresent());
}
use of org.apereo.cas.services.RegisteredServiceAccessStrategyAuditableEnforcer in project cas by apereo.
the class RegisteredServiceAccessStrategyAuditableEnforcerTests method verifyRegisteredServicePresentAndEnabled.
@Test
public void verifyRegisteredServicePresentAndEnabled() {
val service = createRegisteredService(true);
val context = AuditableContext.builder().registeredService(service).build();
val result = new RegisteredServiceAccessStrategyAuditableEnforcer(new CasConfigurationProperties()).execute(context);
assertFalse(result.isExecutionFailure());
assertFalse(result.getException().isPresent());
}
use of org.apereo.cas.services.RegisteredServiceAccessStrategyAuditableEnforcer in project cas by apereo.
the class RegisteredServiceAccessStrategyAuditableEnforcerTests method verifyServiceAndRegisteredServicePresentButDisabled.
@Test
public void verifyServiceAndRegisteredServicePresentButDisabled() {
val service = createRegisteredService(false);
val context = AuditableContext.builder().registeredService(service).service(createService()).build();
val result = new RegisteredServiceAccessStrategyAuditableEnforcer(new CasConfigurationProperties()).execute(context);
assertTrue(result.isExecutionFailure());
assertTrue(result.getException().isPresent());
}
use of org.apereo.cas.services.RegisteredServiceAccessStrategyAuditableEnforcer in project cas by apereo.
the class RegisteredServiceAccessStrategyAuditableEnforcerTests method verifyTgtAndServiceAndRegisteredServicePresentAndEnabled.
@Test
public void verifyTgtAndServiceAndRegisteredServicePresentAndEnabled() {
val service = createRegisteredService(true);
val context = AuditableContext.builder().registeredService(service).service(createService()).ticketGrantingTicket(createTicketGrantingTicket()).build();
val result = new RegisteredServiceAccessStrategyAuditableEnforcer(new CasConfigurationProperties()).execute(context);
assertFalse(result.isExecutionFailure());
assertFalse(result.getException().isPresent());
}
use of org.apereo.cas.services.RegisteredServiceAccessStrategyAuditableEnforcer in project cas by apereo.
the class RegisteredServiceResponseHeadersEnforcementFilterTests method getFilterForProperty.
private static RegisteredServiceResponseHeadersEnforcementFilter getFilterForProperty(final Pair<RegisteredServiceProperties, String>... properties) {
val appCtx = new StaticApplicationContext();
appCtx.refresh();
val context = ServicesManagerConfigurationContext.builder().serviceRegistry(new InMemoryServiceRegistry(appCtx)).applicationContext(appCtx).environments(new HashSet<>(0)).servicesCache(Caffeine.newBuilder().build()).registeredServiceLocators(List.of(new DefaultServicesManagerRegisteredServiceLocator())).build();
val servicesManager = new DefaultServicesManager(context);
val argumentExtractor = new DefaultArgumentExtractor(new WebApplicationServiceFactory());
val service = RegisteredServiceTestUtils.getRegisteredService("service-0");
val props1 = new LinkedHashMap<String, RegisteredServiceProperty>();
for (val p : properties) {
val prop1 = new DefaultRegisteredServiceProperty();
prop1.addValue(p.getValue());
props1.put(p.getKey().getPropertyName(), prop1);
}
service.setProperties(props1);
servicesManager.save(service);
return new RegisteredServiceResponseHeadersEnforcementFilter(servicesManager, argumentExtractor, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()), new RegisteredServiceAccessStrategyAuditableEnforcer(new CasConfigurationProperties()));
}
Aggregations