use of org.apereo.cas.support.openid.authentication.principal.OpenIdServiceFactory in project cas by apereo.
the class OpenIdSingleSignOnActionTests method verifySuccessfulServiceTicket.
@Test
public void verifySuccessfulServiceTicket() throws Exception {
final MockRequestContext context = new MockRequestContext();
final MockHttpServletRequest request = new MockHttpServletRequest();
final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("scootman28");
final TicketGrantingTicket t = new TicketGrantingTicketImpl("TGT-11", authentication, new NeverExpiresExpirationPolicy());
this.ticketRegistry.addTicket(t);
request.setParameter(OpenIdProtocolConstants.OPENID_IDENTITY, "http://openid.aol.com/scootman28");
request.setParameter(OpenIdProtocolConstants.OPENID_RETURNTO, "http://www.cnn.com");
final OpenIdService service = new OpenIdServiceFactory("").createService(request);
context.getFlowScope().put("service", service);
context.getFlowScope().put("ticketGrantingTicketId", t.getId());
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
assertEquals("success", this.action.execute(context).getId());
}
use of org.apereo.cas.support.openid.authentication.principal.OpenIdServiceFactory in project cas by apereo.
the class OpenIdSingleSignOnActionTests method verifyBadUsername.
@Test
public void verifyBadUsername() throws Exception {
final MockRequestContext context = new MockRequestContext();
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setParameter(OpenIdProtocolConstants.OPENID_IDENTITY, "fablah");
request.setParameter(OpenIdProtocolConstants.OPENID_RETURNTO, "http://www.cnn.com");
final OpenIdServiceFactory factory = new OpenIdServiceFactory("");
final OpenIdService service = factory.createService(request);
context.getFlowScope().put("service", service);
context.getFlowScope().put("ticketGrantingTicketId", "tgtId");
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
assertEquals("error", this.action.execute(context).getId());
}
Aggregations