use of org.apereo.cas.validation.Cas20WithoutProxyingValidationSpecification in project cas by apereo.
the class CentralAuthenticationServiceImplTests method authenticateTwiceWithRenew.
/**
* This test simulates :
* - a first authentication for a default service
* - a second authentication with the renew parameter and the same service (and same credentials)
* - a validation of the second ticket.
* When supplemental authentications were returned with the chained authentications, the validation specification
* failed as it only expects one authentication. Thus supplemental authentications should not be returned in the
* chained authentications. Both concepts are orthogonal.
*/
@Test
public void authenticateTwiceWithRenew() throws AbstractTicketException, AuthenticationException {
final CentralAuthenticationService cas = getCentralAuthenticationService();
final Service svc = getService("testDefault");
final UsernamePasswordCredential goodCredential = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
final TicketGrantingTicket tgtId = cas.createTicketGrantingTicket(ctx);
cas.grantServiceTicket(tgtId.getId(), svc, ctx);
// simulate renew with new good same credentials
final ServiceTicket st2Id = cas.grantServiceTicket(tgtId.getId(), svc, ctx);
final Assertion assertion = cas.validateServiceTicket(st2Id.getId(), svc);
final ValidationSpecification validationSpecification = new Cas20WithoutProxyingValidationSpecification();
assertTrue(validationSpecification.isSatisfiedBy(assertion, new MockHttpServletRequest()));
}
use of org.apereo.cas.validation.Cas20WithoutProxyingValidationSpecification in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyRenewSpecFailsCorrectly.
@Test
public void verifyRenewSpecFailsCorrectly() throws Exception {
this.serviceValidateController.setValidationSpecification(new Cas20WithoutProxyingValidationSpecification(true));
assertFalse(this.serviceValidateController.handleRequestInternal(getHttpServletRequest(), new MockHttpServletResponse()).getView().toString().contains(SUCCESS));
}
use of org.apereo.cas.validation.Cas20WithoutProxyingValidationSpecification in project cas by apereo.
the class AbstractServiceValidateControllerTests method onSetUp.
@Before
public void onSetUp() throws Exception {
final StaticApplicationContext context = new StaticApplicationContext();
context.refresh();
this.serviceValidateController = new ServiceValidateController();
this.serviceValidateController.setCentralAuthenticationService(getCentralAuthenticationService());
this.serviceValidateController.setAuthenticationSystemSupport(getAuthenticationSystemSupport());
final Cas20ProxyHandler proxyHandler = new Cas20ProxyHandler(new SimpleHttpClientFactoryBean().getObject(), new DefaultUniqueTicketIdGenerator());
this.serviceValidateController.setProxyHandler(proxyHandler);
this.serviceValidateController.setApplicationContext(context);
this.serviceValidateController.setArgumentExtractor(getArgumentExtractor());
this.serviceValidateController.setServicesManager(getServicesManager());
this.serviceValidateController.setValidationSpecification(new Cas20WithoutProxyingValidationSpecification());
this.serviceValidateController.setMultifactorTriggerSelectionStrategy(new DefaultMultifactorTriggerSelectionStrategy("", ""));
}
Aggregations