Search in sources :

Example 6 with LogoutWrapper

use of ddf.security.samlp.LogoutWrapper in project ddf by codice.

the class LogoutRequestServiceTest method testGetLogoutRequest.

@Test
public void testGetLogoutRequest() throws Exception {
    SamlSecurity samlSecurity = new SamlSecurity();
    String deflatedSamlRequest = samlSecurity.deflateAndBase64Encode(UNENCODED_SAML_REQUEST);
    doReturn(true).when(simpleSign).validateSignature(anyString(), anyString(), anyString(), any());
    initializeLogoutRequestService();
    insertLogoutRequest();
    LogoutResponse logoutResponse = mock(LogoutResponse.class);
    LogoutWrapper<LogoutResponse> responseLogoutWrapper = new LogoutWrapperImpl<>(logoutResponse);
    when(logoutMessage.buildLogoutResponse(anyString(), anyString(), anyString())).thenReturn(responseLogoutWrapper);
    when(logoutMessage.signSamlGetResponse(any(LogoutWrapper.class), any(URI.class), anyString())).thenReturn(new URI(redirectLogoutUrl));
    logoutRequestService.setLogoutMessage(logoutMessage);
    Response response = logoutRequestService.getLogoutRequest(deflatedSamlRequest, null, relayState, SIGNATURE_ALGORITHM, SIGNATURE);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    assertTrue("Expected logout url of " + redirectLogoutUrl, response.getEntity().toString().contains(redirectLogoutUrl));
}
Also used : LogoutWrapper(ddf.security.samlp.LogoutWrapper) Response(javax.ws.rs.core.Response) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) LogoutWrapperImpl(ddf.security.samlp.impl.LogoutWrapperImpl) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SamlSecurity(org.codice.ddf.security.jaxrs.impl.SamlSecurity) URI(java.net.URI) Test(org.junit.Test)

Aggregations

LogoutWrapper (ddf.security.samlp.LogoutWrapper)6 Response (javax.ws.rs.core.Response)5 Test (org.junit.Test)5 LogoutResponse (org.opensaml.saml.saml2.core.LogoutResponse)5 LogoutWrapperImpl (ddf.security.samlp.impl.LogoutWrapperImpl)4 URI (java.net.URI)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 LogoutRequest (org.opensaml.saml.saml2.core.LogoutRequest)4 SamlSecurity (org.codice.ddf.security.jaxrs.impl.SamlSecurity)3 InputStream (java.io.InputStream)1 HttpSessionInvalidator (org.codice.ddf.platform.session.api.HttpSessionInvalidator)1 SessionIndex (org.opensaml.saml.saml2.core.SessionIndex)1 LogoutRequestBuilder (org.opensaml.saml.saml2.core.impl.LogoutRequestBuilder)1 Signature (org.opensaml.xmlsec.signature.Signature)1 Document (org.w3c.dom.Document)1