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));
}
Aggregations