Search in sources :

Example 1 with LogoutResponseBuilder

use of org.opensaml.saml.saml2.core.impl.LogoutResponseBuilder in project ddf by codice.

the class LogoutRequestServiceTest method getPostLogoutRequest.

@Test
public void getPostLogoutRequest() throws Exception {
    String relayState = UUID.randomUUID().toString();
    String encodedSamlRequest = "encodedSamlRequest";
    String issuerStr = "issuer";
    LogoutRequest logoutRequest = mock(LogoutRequest.class);
    Issuer issuer = mock(Issuer.class);
    OpenSAMLUtil.initSamlEngine();
    LogoutResponse logoutResponse = new LogoutResponseBuilder().buildObject();
    when(logoutMessage.extractSamlLogoutRequest(any(String.class))).thenReturn(logoutRequest);
    when(logoutRequest.getIssuer()).thenReturn(issuer);
    when(logoutRequest.getIssueInstant()).thenReturn(new DateTime());
    when(logoutRequest.getVersion()).thenReturn(SAMLVersion.VERSION_20);
    when(logoutRequest.getID()).thenReturn("id");
    when(issuer.getValue()).thenReturn(issuerStr);
    when(logoutMessage.buildLogoutResponse(eq(issuerStr), eq(StatusCode.SUCCESS), anyString())).thenReturn(logoutResponse);
    when(idpMetadata.getSingleLogoutBinding()).thenReturn(SamlProtocol.POST_BINDING);
    when(idpMetadata.getSingleLogoutLocation()).thenReturn(postLogoutUrl);
    Response response = logoutRequestService.postLogoutRequest(encodedSamlRequest, null, relayState);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    assertTrue("Expected logout url of " + postLogoutUrl, response.getEntity().toString().contains(postLogoutUrl));
}
Also used : LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) Response(javax.ws.rs.core.Response) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) LogoutResponseBuilder(org.opensaml.saml.saml2.core.impl.LogoutResponseBuilder) Issuer(org.opensaml.saml.saml2.core.Issuer) LogoutRequest(org.opensaml.saml.saml2.core.LogoutRequest) Matchers.anyString(org.mockito.Matchers.anyString) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

Response (javax.ws.rs.core.Response)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Issuer (org.opensaml.saml.saml2.core.Issuer)1 LogoutRequest (org.opensaml.saml.saml2.core.LogoutRequest)1 LogoutResponse (org.opensaml.saml.saml2.core.LogoutResponse)1 LogoutResponseBuilder (org.opensaml.saml.saml2.core.impl.LogoutResponseBuilder)1