commit | author | age
|
57a6c1
|
1 |
package org.keycloak.protocol.cas; |
MP |
2 |
|
|
3 |
import org.apache.http.HttpEntity; |
|
4 |
import org.junit.Test; |
|
5 |
import org.keycloak.protocol.cas.utils.LogoutHelper; |
|
6 |
import org.keycloak.saml.common.constants.JBossSAMLURIConstants; |
|
7 |
import org.keycloak.saml.common.util.DocumentUtil; |
|
8 |
import org.w3c.dom.Document; |
|
9 |
import org.w3c.dom.Node; |
|
10 |
|
|
11 |
import static org.junit.Assert.assertEquals; |
|
12 |
import static org.junit.Assert.assertFalse; |
|
13 |
|
|
14 |
public class LogoutHelperTest { |
|
15 |
@Test |
|
16 |
public void testLogoutRequest() throws Exception { |
|
17 |
HttpEntity requestEntity = LogoutHelper.buildSingleLogoutRequest("ST-test"); |
|
18 |
Document doc = DocumentUtil.getDocument(requestEntity.getContent()); |
|
19 |
|
|
20 |
assertEquals("LogoutRequest", doc.getDocumentElement().getLocalName()); |
|
21 |
assertEquals(JBossSAMLURIConstants.PROTOCOL_NSURI.get(), doc.getDocumentElement().getNamespaceURI()); |
|
22 |
assertEquals("2.0", doc.getDocumentElement().getAttribute("Version")); |
|
23 |
assertFalse(doc.getDocumentElement().getAttribute("ID").isEmpty()); |
|
24 |
assertFalse(doc.getDocumentElement().getAttribute("IssueInstant").isEmpty()); |
|
25 |
|
|
26 |
Node nameID = doc.getDocumentElement().getElementsByTagNameNS(JBossSAMLURIConstants.ASSERTION_NSURI.get(), "NameID").item(0); |
|
27 |
assertFalse(nameID.getTextContent() == null || nameID.getTextContent().isEmpty()); |
|
28 |
|
|
29 |
Node sessionIndex = doc.getDocumentElement().getElementsByTagNameNS(JBossSAMLURIConstants.PROTOCOL_NSURI.get(), "SessionIndex").item(0); |
|
30 |
assertEquals("ST-test", sessionIndex.getTextContent()); |
|
31 |
} |
|
32 |
} |