| | |
| | | package org.keycloak.protocol.cas; |
| | | |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.NameValuePair; |
| | | import org.apache.http.client.utils.URLEncodedUtils; |
| | | import org.junit.Test; |
| | | import org.keycloak.protocol.cas.utils.LogoutHelper; |
| | | import org.keycloak.saml.common.constants.JBossSAMLURIConstants; |
| | | import org.keycloak.saml.common.util.DocumentUtil; |
| | | import org.w3c.dom.Document; |
| | | import org.w3c.dom.Node; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.junit.Assert.assertEquals; |
| | | import static org.junit.Assert.assertFalse; |
| | |
| | | @Test |
| | | public void testLogoutRequest() throws Exception { |
| | | HttpEntity requestEntity = LogoutHelper.buildSingleLogoutRequest("ST-test"); |
| | | Document doc = DocumentUtil.getDocument(requestEntity.getContent()); |
| | | |
| | | List<NameValuePair> parameters = URLEncodedUtils.parse(requestEntity).stream().filter(parameter -> "logoutRequest".equals(parameter.getName())).collect(Collectors.toList()); |
| | | assertEquals(1, parameters.size()); |
| | | |
| | | String logoutRequest = parameters.get(0).getValue(); |
| | | Document doc = DocumentUtil.getDocument(logoutRequest); |
| | | |
| | | assertEquals("LogoutRequest", doc.getDocumentElement().getLocalName()); |
| | | assertEquals(JBossSAMLURIConstants.PROTOCOL_NSURI.get(), doc.getDocumentElement().getNamespaceURI()); |