use of org.apereo.cas.services.RegisteredServiceAccessStrategyAuditableEnforcer in project cas by apereo.
the class RegisteredServiceAccessStrategyAuditableEnforcerTests method verifyStRejectedPrincipalAttributes.
@Test
public void verifyStRejectedPrincipalAttributes() {
val service = createRegisteredService(true);
((DefaultRegisteredServiceAccessStrategy) service.getAccessStrategy()).setRejectedAttributes(reject(false));
val context = AuditableContext.builder().registeredService(service).serviceTicket(createServiceTicket()).authenticationResult(createAuthenticationResult()).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 verifyRejectedPrincipalAttributesNoFail.
@Test
public void verifyRejectedPrincipalAttributesNoFail() {
val service = createRegisteredService(true);
((DefaultRegisteredServiceAccessStrategy) service.getAccessStrategy()).setRejectedAttributes(reject(true));
val context = AuditableContext.builder().registeredService(service).service(createService()).authentication(createAuthentication()).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 verifyRejectedPrincipalAttributes.
@Test
public void verifyRejectedPrincipalAttributes() {
val service = createRegisteredService(true);
((DefaultRegisteredServiceAccessStrategy) service.getAccessStrategy()).setRejectedAttributes(reject(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 verifyTgtRejectedPrincipalAttributesNoFail.
@Test
public void verifyTgtRejectedPrincipalAttributesNoFail() {
val service = createRegisteredService(true);
((DefaultRegisteredServiceAccessStrategy) service.getAccessStrategy()).setRejectedAttributes(reject(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 RegisteredServiceAccessStrategyAuditableEnforcerTests method verifyGroovyScriptAccessStrategy.
@Test
public void verifyGroovyScriptAccessStrategy() {
val service = createRegisteredService(true);
val context = AuditableContext.builder().registeredService(service).build();
val props = new CasConfigurationProperties();
props.getAccessStrategy().getGroovy().setLocation(new ClassPathResource("GroovyAccessStrategy.groovy"));
val result = new RegisteredServiceAccessStrategyAuditableEnforcer(props).execute(context);
assertTrue(result.isExecutionFailure());
assertTrue(result.getException().isPresent());
}
Aggregations