keycloak-developers

saml mapper tests

3/9/2015 9:02:30 AM

Details

diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/saml/SamlBindingTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/saml/SamlBindingTest.java
index c81dbef..389fd09 100755
--- a/testsuite/integration/src/test/java/org/keycloak/testsuite/saml/SamlBindingTest.java
+++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/saml/SamlBindingTest.java
@@ -271,6 +271,7 @@ public class SamlBindingTest {
                 app.addProtocolMapper(HardcodedAttributeMapper.create("hardcoded-attribute", "hardcoded-attribute", "Basic", null, "hard", false, null));
                 app.addProtocolMapper(HardcodedRole.create("hardcoded-role", "hardcoded-role"));
                 app.addProtocolMapper(SAMLBasicRoleNameMapper.create("renamed-role","manager", "el-jefe"));
+                app.addProtocolMapper(SAMLBasicRoleNameMapper.create("renamed-employee-role","http://localhost:8081/employee/.employee", "pee-on"));
             }
         }, "demo");
 
@@ -295,6 +296,7 @@ public class SamlBindingTest {
             boolean single = false;
             boolean hardcodedRole = false;
             boolean hardcodedAttribute = false;
+            boolean peeOn = false;
             for (AttributeStatementType statement : assertion.getAttributeStatements()) {
                 for (AttributeStatementType.ASTChoiceType choice : statement.getAttributes()) {
                     AttributeType attr = choice.getAttribute();
@@ -305,6 +307,7 @@ public class SamlBindingTest {
                             if (value.equals("el-jefe")) managerRole = true;
                             if (value.equals("user")) userRole = true;
                             if (value.equals("hardcoded-role")) hardcodedRole = true;
+                            if (value.equals("pee-on")) peeOn = true;
                         }
                     } else if (attr.getName().equals("hardcoded-attribute")) {
                         hardcodedAttribute = true;
@@ -317,6 +320,7 @@ public class SamlBindingTest {
             Assert.assertTrue(single);
             Assert.assertTrue(hardcodedAttribute);
             Assert.assertTrue(hardcodedRole);
+            Assert.assertTrue(peeOn);
             Assert.assertTrue(userRole);
             Assert.assertTrue(managerRole);
         }
diff --git a/testsuite/integration/src/test/resources/saml/testsaml.json b/testsuite/integration/src/test/resources/saml/testsaml.json
index 3cd3342..cac873b 100755
--- a/testsuite/integration/src/test/resources/saml/testsaml.json
+++ b/testsuite/integration/src/test/resources/saml/testsaml.json
@@ -27,7 +27,10 @@
             "attributes" : {
                 "phone": "617"
             },
-            "realmRoles": ["manager", "user"]
+            "realmRoles": ["manager", "user"],
+            "applicationRoles": {
+                "http://localhost:8081/employee/": [ "employee" ]
+            }
         }
     ],
     "applications": [
@@ -304,6 +307,14 @@
                 "name": "user",
                 "description": "Have User privileges"
             }
-        ]
+        ],
+        "application" : {
+            "http://localhost:8081/employee/" : [
+                {
+                    "name": "employee",
+                    "description": "Have Employee privileges"
+                }
+            ]
+        }
     }
 }