use of org.opensaml.saml2.core.LogoutRequest 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));
}
Aggregations