Search in sources :

Example 6 with ConsumerManager

use of org.openid4java.consumer.ConsumerManager in project spring-security by spring-projects.

the class OpenID4JavaConsumerTests method failedVerificationReturnsFailedAuthenticationStatus.

@Test
public void failedVerificationReturnsFailedAuthenticationStatus() throws Exception {
    ConsumerManager mgr = mock(ConsumerManager.class);
    OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());
    VerificationResult vr = mock(VerificationResult.class);
    DiscoveryInformation di = mock(DiscoveryInformation.class);
    when(mgr.verify(anyString(), any(ParameterList.class), any(DiscoveryInformation.class))).thenReturn(vr);
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.getSession().setAttribute(DiscoveryInformation.class.getName(), di);
    OpenIDAuthenticationToken auth = consumer.endConsumption(request);
    assertThat(auth.getStatus()).isEqualTo(OpenIDAuthenticationStatus.FAILURE);
}
Also used : ConsumerManager(org.openid4java.consumer.ConsumerManager) VerificationResult(org.openid4java.consumer.VerificationResult) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DiscoveryInformation(org.openid4java.discovery.DiscoveryInformation) ParameterList(org.openid4java.message.ParameterList)

Aggregations

ConsumerManager (org.openid4java.consumer.ConsumerManager)6 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)6 DiscoveryInformation (org.openid4java.discovery.DiscoveryInformation)5 ParameterList (org.openid4java.message.ParameterList)3 VerificationResult (org.openid4java.consumer.VerificationResult)2 DiscoveryException (org.openid4java.discovery.DiscoveryException)2 MessageException (org.openid4java.message.MessageException)2 AssociationException (org.openid4java.association.AssociationException)1 ConsumerException (org.openid4java.consumer.ConsumerException)1 Identifier (org.openid4java.discovery.Identifier)1 AuthRequest (org.openid4java.message.AuthRequest)1 Message (org.openid4java.message.Message)1 AxMessage (org.openid4java.message.ax.AxMessage)1