use of org.apereo.cas.services.RegisteredServiceAccessStrategyAuditableEnforcer in project cas by apereo.
the class OAuth20IdTokenAndTokenResponseTypeAuthorizationRequestValidatorTests method verifySupports.
@Test
public void verifySupports() throws Exception {
val serviceManager = mock(ServicesManager.class);
val service = new OAuthRegisteredService();
service.setName("OAuth");
service.setClientId("client");
service.setClientSecret("secret");
service.setServiceId("https://callback.example.org");
when(serviceManager.getAllServices()).thenReturn((Collection) CollectionUtils.toCollection(service));
when(serviceManager.getAllServicesOfType(any())).thenReturn((Collection) CollectionUtils.toCollection(service));
val v = new OAuth20IdTokenAndTokenResponseTypeAuthorizationRequestValidator(serviceManager, new WebApplicationServiceFactory(), new RegisteredServiceAccessStrategyAuditableEnforcer(new CasConfigurationProperties()));
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val context = new JEEContext(request, response);
request.setParameter(OAuth20Constants.RESPONSE_TYPE, OAuth20ResponseTypes.CODE.getType());
request.setParameter(OAuth20Constants.CLIENT_ID, "client");
request.setParameter(OAuth20Constants.REDIRECT_URI, service.getServiceId());
assertFalse(v.supports(context));
request.setParameter(OAuth20Constants.RESPONSE_TYPE, OAuth20ResponseTypes.IDTOKEN_TOKEN.getType());
assertTrue(v.supports(context));
}
use of org.apereo.cas.services.RegisteredServiceAccessStrategyAuditableEnforcer in project cas by apereo.
the class RegisteredServiceAccessStrategyAuditableEnforcerTests method verifyStAndServiceAndRegisteredServicePresentButDisabled.
@Test
public void verifyStAndServiceAndRegisteredServicePresentButDisabled() {
val service = createRegisteredService(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 verifyServiceAndRegisteredServicePresentAndEnabled.
@Test
public void verifyServiceAndRegisteredServicePresentAndEnabled() {
val service = createRegisteredService(true);
val context = AuditableContext.builder().registeredService(service).service(createService()).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 verifyStAndServiceAndRegisteredServicePresentAndEnabled.
@Test
public void verifyStAndServiceAndRegisteredServicePresentAndEnabled() {
val service = createRegisteredService(true);
val context = AuditableContext.builder().registeredService(service).serviceTicket(createServiceTicket()).authenticationResult(createAuthenticationResult()).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 verifyStRejectedPrincipalAttributesNoFail.
@Test
public void verifyStRejectedPrincipalAttributesNoFail() {
val service = createRegisteredService(true);
((DefaultRegisteredServiceAccessStrategy) service.getAccessStrategy()).setRejectedAttributes(reject(true));
val context = AuditableContext.builder().registeredService(service).serviceTicket(createServiceTicket()).authenticationResult(createAuthenticationResult()).build();
val result = new RegisteredServiceAccessStrategyAuditableEnforcer(new CasConfigurationProperties()).execute(context);
assertFalse(result.isExecutionFailure());
assertFalse(result.getException().isPresent());
}
Aggregations