saml mapper tests

This commit is contained in:
Bill Burke 2015-03-09 08:02:30 -04:00
parent d4468913dd
commit 60313a310c
2 changed files with 17 additions and 2 deletions

View file

@ -271,6 +271,7 @@ public class SamlBindingTest {
app.addProtocolMapper(HardcodedAttributeMapper.create("hardcoded-attribute", "hardcoded-attribute", "Basic", null, "hard", false, null)); app.addProtocolMapper(HardcodedAttributeMapper.create("hardcoded-attribute", "hardcoded-attribute", "Basic", null, "hard", false, null));
app.addProtocolMapper(HardcodedRole.create("hardcoded-role", "hardcoded-role")); app.addProtocolMapper(HardcodedRole.create("hardcoded-role", "hardcoded-role"));
app.addProtocolMapper(SAMLBasicRoleNameMapper.create("renamed-role","manager", "el-jefe")); app.addProtocolMapper(SAMLBasicRoleNameMapper.create("renamed-role","manager", "el-jefe"));
app.addProtocolMapper(SAMLBasicRoleNameMapper.create("renamed-employee-role","http://localhost:8081/employee/.employee", "pee-on"));
} }
}, "demo"); }, "demo");
@ -295,6 +296,7 @@ public class SamlBindingTest {
boolean single = false; boolean single = false;
boolean hardcodedRole = false; boolean hardcodedRole = false;
boolean hardcodedAttribute = false; boolean hardcodedAttribute = false;
boolean peeOn = false;
for (AttributeStatementType statement : assertion.getAttributeStatements()) { for (AttributeStatementType statement : assertion.getAttributeStatements()) {
for (AttributeStatementType.ASTChoiceType choice : statement.getAttributes()) { for (AttributeStatementType.ASTChoiceType choice : statement.getAttributes()) {
AttributeType attr = choice.getAttribute(); AttributeType attr = choice.getAttribute();
@ -305,6 +307,7 @@ public class SamlBindingTest {
if (value.equals("el-jefe")) managerRole = true; if (value.equals("el-jefe")) managerRole = true;
if (value.equals("user")) userRole = true; if (value.equals("user")) userRole = true;
if (value.equals("hardcoded-role")) hardcodedRole = true; if (value.equals("hardcoded-role")) hardcodedRole = true;
if (value.equals("pee-on")) peeOn = true;
} }
} else if (attr.getName().equals("hardcoded-attribute")) { } else if (attr.getName().equals("hardcoded-attribute")) {
hardcodedAttribute = true; hardcodedAttribute = true;
@ -317,6 +320,7 @@ public class SamlBindingTest {
Assert.assertTrue(single); Assert.assertTrue(single);
Assert.assertTrue(hardcodedAttribute); Assert.assertTrue(hardcodedAttribute);
Assert.assertTrue(hardcodedRole); Assert.assertTrue(hardcodedRole);
Assert.assertTrue(peeOn);
Assert.assertTrue(userRole); Assert.assertTrue(userRole);
Assert.assertTrue(managerRole); Assert.assertTrue(managerRole);
} }

View file

@ -27,7 +27,10 @@
"attributes" : { "attributes" : {
"phone": "617" "phone": "617"
}, },
"realmRoles": ["manager", "user"] "realmRoles": ["manager", "user"],
"applicationRoles": {
"http://localhost:8081/employee/": [ "employee" ]
}
} }
], ],
"applications": [ "applications": [
@ -304,6 +307,14 @@
"name": "user", "name": "user",
"description": "Have User privileges" "description": "Have User privileges"
} }
],
"application" : {
"http://localhost:8081/employee/" : [
{
"name": "employee",
"description": "Have Employee privileges"
}
] ]
} }
} }
}