diff --git a/testsuite/integration-arquillian/test-apps/photoz/photoz-html5-client/src/main/webapp/index.html b/testsuite/integration-arquillian/test-apps/photoz/photoz-html5-client/src/main/webapp/index.html
index bec9faea7b..077f9dcbfb 100755
--- a/testsuite/integration-arquillian/test-apps/photoz/photoz-html5-client/src/main/webapp/index.html
+++ b/testsuite/integration-arquillian/test-apps/photoz/photoz-html5-client/src/main/webapp/index.html
@@ -19,7 +19,12 @@
-
diff --git a/testsuite/integration-arquillian/test-apps/photoz/photoz-html5-client/src/main/webapp/js/app.js b/testsuite/integration-arquillian/test-apps/photoz/photoz-html5-client/src/main/webapp/js/app.js
index e58c5f55d7..bf71b437ad 100755
--- a/testsuite/integration-arquillian/test-apps/photoz/photoz-html5-client/src/main/webapp/js/app.js
+++ b/testsuite/integration-arquillian/test-apps/photoz/photoz-html5-client/src/main/webapp/js/app.js
@@ -62,7 +62,16 @@ module.controller('TokenCtrl', function ($scope, Identity) {
}
$scope.requestEntitlements = function () {
- Identity.authorization.entitlement('photoz-restful-api').then(function (rpt) {});
+ Identity.authorization.entitlement('photoz-restful-api').then(function (rpt) {
+ document.getElementById("output").innerHTML = JSON.stringify(jwt_decode(rpt), null, ' ');
+ });
+ }
+
+ $scope.requestEntitlement = function () {
+ var param={"permissions" : [{"resource_set_name" : "Album Resource"}]};
+ Identity.authorization.entitlement('photoz-restful-api', param).then(function (rpt) {
+ document.getElementById("output").innerHTML = JSON.stringify(jwt_decode(rpt), null, ' ');
+ });
}
$scope.Identity = Identity;
diff --git a/testsuite/integration-arquillian/test-apps/photoz/photoz-restful-api-authz-service.json b/testsuite/integration-arquillian/test-apps/photoz/photoz-restful-api-authz-service.json
index 1ce85dd9dc..3807df7de6 100644
--- a/testsuite/integration-arquillian/test-apps/photoz/photoz-restful-api-authz-service.json
+++ b/testsuite/integration-arquillian/test-apps/photoz/photoz-restful-api-authz-service.json
@@ -47,7 +47,7 @@
"logic": "POSITIVE",
"decisionStrategy": "UNANIMOUS",
"config": {
- "mavenArtifactVersion": "2.1.0-SNAPSHOT",
+ "mavenArtifactVersion": "2.5.0.Final-SNAPSHOT",
"mavenArtifactId": "photoz-authz-policy",
"sessionName": "MainOwnerSession",
"mavenArtifactGroupId": "org.keycloak.testsuite",
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/PhotozClientAuthzTestApp.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/PhotozClientAuthzTestApp.java
index fe98f0d6c6..b721166720 100644
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/PhotozClientAuthzTestApp.java
+++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/PhotozClientAuthzTestApp.java
@@ -54,7 +54,13 @@ public class PhotozClientAuthzTestApp extends AbstractPageWithInjectedUrl {
@FindBy(xpath = "//a[@ng-click = 'Identity.logout()']")
WebElement signOutButton;
-
+
+ @FindBy(id = "entitlement")
+ WebElement entitlement;
+
+ @FindBy(id = "entitlements")
+ WebElement entitlements;
+
public void createAlbum(String name) {
navigateTo();
this.driver.findElement(By.id("create-album")).click();
@@ -85,6 +91,16 @@ public class PhotozClientAuthzTestApp extends AbstractPageWithInjectedUrl {
signOutButton.click(); // Sometimes doesn't work in PhantomJS!
pause(WAIT_AFTER_OPERATION);
}
+
+ public void requestEntitlement() {
+ entitlement.click();
+ pause(WAIT_AFTER_OPERATION);
+ }
+
+ public void requestEntitlements() {
+ entitlements.click();
+ pause(WAIT_AFTER_OPERATION);
+ }
public void login(String username, String password, String... scopes) {
if (scopes.length > 0) {
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractPhotozExampleAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractPhotozExampleAdapterTest.java
index 55eccaad5c..d6f913487e 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractPhotozExampleAdapterTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractPhotozExampleAdapterTest.java
@@ -609,6 +609,27 @@ public abstract class AbstractPhotozExampleAdapterTest extends AbstractExampleAd
this.deployer.undeploy(RESOURCE_SERVER_ID);
}
}
+
+ //KEYCLOAK-3777
+ @Test
+ public void testEntitlementRequest() {
+ try {
+ this.deployer.deploy(RESOURCE_SERVER_ID);
+
+ clientPage.navigateTo();
+ loginToClientPage("admin", "admin");
+
+ clientPage.requestEntitlements();
+ assertTrue(driver.getPageSource().contains("urn:photoz.com:scopes:album:admin:manage"));
+
+ clientPage.requestEntitlement();
+ String pageSource = driver.getPageSource();
+ assertTrue(pageSource.contains("urn:photoz.com:scopes:album:view"));
+ assertFalse(pageSource.contains("urn:photoz.com:scopes:album:admin:manage"));
+ } finally {
+ this.deployer.undeploy(RESOURCE_SERVER_ID);
+ }
+ }
private void importResourceServerSettings() throws FileNotFoundException {
getAuthorizationResource().importSettings(loadJson(new FileInputStream(new File(TEST_APPS_HOME_DIR + "/photoz/photoz-restful-api-authz-service.json")), ResourceServerRepresentation.class));