From 60313a310c530d61eb6c7254585bf74f59978a0d Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Mon, 9 Mar 2015 08:02:30 -0400 Subject: [PATCH] saml mapper tests --- .../keycloak/testsuite/saml/SamlBindingTest.java | 4 ++++ .../src/test/resources/saml/testsaml.json | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) 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 c81dbef7d3..389fd09d6c 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 3cd3342b6b..cac873b807 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" + } + ] + } } }