[KEYCLOAK-6623] - Adding test

This commit is contained in:
pedroigor 2018-03-09 16:39:33 -03:00
parent 668b67dcdb
commit 199f289ee3
3 changed files with 62 additions and 0 deletions

View file

@ -107,6 +107,14 @@
{
"name": "Pattern 12",
"uri": "/realm_uri"
},
{
"name": "Pattern 13",
"uri": "/keycloak-6623/*"
},
{
"name": "Pattern 14",
"uri": "/keycloak-6623/sub-resource/*"
}
],
"policies": [
@ -258,6 +266,26 @@
"resources": "[\"Pattern 12\"]",
"applyPolicies": "[\"Default Policy\"]"
}
},
{
"name": "Pattern 13 Permission",
"type": "resource",
"logic": "POSITIVE",
"decisionStrategy": "UNANIMOUS",
"config": {
"resources": "[\"Pattern 13\"]",
"applyPolicies": "[\"Default Policy\"]"
}
},
{
"name": "Pattern 14 Permission",
"type": "resource",
"logic": "POSITIVE",
"decisionStrategy": "UNANIMOUS",
"config": {
"resources": "[\"Pattern 14\"]",
"applyPolicies": "[\"Default Policy\"]"
}
}
],
"scopes": []

View file

@ -60,6 +60,14 @@
{
"name": "Pattern 12",
"path": "/keycloak_json_uri"
},
{
"name": "Pattern 14",
"path": "/keycloak-6623/sub-resource/*"
},
{
"name": "Pattern 13",
"path": "/keycloak-6623/*"
}
]
}

View file

@ -379,6 +379,32 @@ public abstract class AbstractServletPolicyEnforcerTest extends AbstractExampleA
});
}
@Test
public void testPathOrderWithAllPaths() {
performTests(() -> {
login("alice", "alice");
navigateTo("/keycloak-6623");
assertFalse(wasDenied());
navigateTo("/keycloak-6623/sub-resource");
assertFalse(wasDenied());
updatePermissionPolicies("Pattern 13 Permission", "Deny Policy");
login("alice", "alice");
navigateTo("/keycloak-6623");
assertTrue(wasDenied());
navigateTo("/keycloak-6623/sub-resource");
assertFalse(wasDenied());
updatePermissionPolicies("Pattern 14 Permission", "Deny Policy");
login("alice", "alice");
navigateTo("/keycloak-6623");
assertTrue(wasDenied());
navigateTo("/keycloak-6623/sub-resource/resource");
assertTrue(wasDenied());
});
}
private void navigateTo(String path) {
this.driver.navigate().to(getResourceServerUrl() + path);