Search in sources :

Example 11 with LogoutResponse

use of org.opensaml.saml.saml2.core.LogoutResponse 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

LogoutResponse (org.opensaml.saml.saml2.core.LogoutResponse)11 Test (org.junit.Test)6 LogoutRequest (org.opensaml.saml.saml2.core.LogoutRequest)5 ValidationException (ddf.security.samlp.ValidationException)4 Response (javax.ws.rs.core.Response)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 Matchers.anyString (org.mockito.Matchers.anyString)4 IOException (java.io.IOException)3 DateTime (org.joda.time.DateTime)3 Cookie (javax.servlet.http.Cookie)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 NewCookie (javax.ws.rs.core.NewCookie)2 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)2 Issuer (org.opensaml.saml.saml2.core.Issuer)2 SamlValidator (ddf.security.samlp.impl.SamlValidator)1 Produces (javax.ws.rs.Produces)1 LogoutResponseBuilder (org.opensaml.saml.saml2.core.impl.LogoutResponseBuilder)1