Merge pull request #3678 from vramik/KEYCLOAK-3777
KEYCLOAK-3777 added missing test
This commit is contained in:
commit
f97a3e0745
5 changed files with 55 additions and 4 deletions
|
@ -19,7 +19,12 @@
|
|||
|
||||
<body data-ng-controller="TokenCtrl">
|
||||
|
||||
<a href data-ng-click="showRpt()">Show Requesting Party Token </a> | <a href data-ng-click="showAccessToken()">Show Access Token </a> | <a href data-ng-click="requestEntitlements()">Request Entitlements</a> | <a href="" ng-click="Identity.logout()">Sign Out</a>
|
||||
<!--<a href data-ng-click="showRpt()">Show Requesting Party Token </a> | <a href data-ng-click="showAccessToken()">Show Access Token </a> | <a href data-ng-click="requestEntitlements()">Request Entitlements</a> | <a href data-ng-click="requestEntitlement()">Request Entitlement</a> |<a href="" ng-click="Identity.logout()">Sign Out</a>-->
|
||||
<a href data-ng-click="showRpt()">Show Requesting Party Token </a> |
|
||||
<a href data-ng-click="showAccessToken()">Show Access Token </a> |
|
||||
<a id="entitlements" href data-ng-click="requestEntitlements()">Request Entitlements</a> |
|
||||
<a id="entitlement" href data-ng-click="requestEntitlement()">Request Entitlement</a> |
|
||||
<a href="" ng-click="Identity.logout()">Sign Out</a>
|
||||
|
||||
<div id="content-area" class="col-md-9" role="main">
|
||||
<div id="content" ng-view/>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -55,6 +55,12 @@ 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();
|
||||
|
@ -86,6 +92,16 @@ public class PhotozClientAuthzTestApp extends AbstractPageWithInjectedUrl {
|
|||
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) {
|
||||
StringBuilder scopesValue = new StringBuilder();
|
||||
|
|
|
@ -610,6 +610,27 @@ public abstract class AbstractPhotozExampleAdapterTest extends AbstractExampleAd
|
|||
}
|
||||
}
|
||||
|
||||
//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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue