Search in sources :

Example 16 with ScopeRepresentation

use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.

the class ScopeManagementTest method createScope.

private ScopeRepresentation createScope() {
    ScopeRepresentation expected = new ScopeRepresentation();
    expected.setName("Test Scope");
    expected.setDisplayName("Test Scope Display Name");
    authorizationPage.authorizationTabs().scopes().create(expected);
    assertAlertSuccess();
    assertScope(expected);
    return expected;
}
Also used : ScopeRepresentation(org.keycloak.representations.idm.authorization.ScopeRepresentation)

Example 17 with ScopeRepresentation

use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.

the class ResourceForm method populate.

public void populate(ResourceRepresentation expected) {
    while (true) {
        try {
            WebElement e = driver.findElement(By.xpath("//button[@data-ng-click='deleteUri($index)']"));
            e.click();
        } catch (NoSuchElementException e) {
            break;
        }
    }
    UIUtils.setTextInputValue(name, expected.getName());
    UIUtils.setTextInputValue(displayName, expected.getDisplayName());
    UIUtils.setTextInputValue(type, expected.getType());
    for (String uri : expected.getUris()) {
        UIUtils.setTextInputValue(newUri, uri);
        addUriButton.click();
    }
    UIUtils.setTextInputValue(iconUri, expected.getIconUri());
    Set<ScopeRepresentation> scopes = expected.getScopes();
    for (ScopeRepresentation scope : scopes) {
        scopesInput.select(scope.getName());
    }
    Set<ScopeRepresentation> selection = scopesInput.getSelected();
    for (ScopeRepresentation selected : selection) {
        boolean isSelected = false;
        for (ScopeRepresentation scope : scopes) {
            if (selected.getName().equals(scope.getName())) {
                isSelected = true;
                break;
            }
        }
        if (!isSelected) {
            scopesInput.unSelect(selected.getName(), driver);
        }
    }
    save();
}
Also used : ScopeRepresentation(org.keycloak.representations.idm.authorization.ScopeRepresentation) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 18 with ScopeRepresentation

use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.

the class ScopeForm method toRepresentation.

public ScopeRepresentation toRepresentation() {
    ScopeRepresentation representation = new ScopeRepresentation();
    representation.setName(UIUtils.getTextInputValue(name));
    representation.setDisplayName(UIUtils.getTextInputValue(displayName));
    representation.setIconUri(UIUtils.getTextInputValue(iconUri));
    return representation;
}
Also used : ScopeRepresentation(org.keycloak.representations.idm.authorization.ScopeRepresentation)

Example 19 with ScopeRepresentation

use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.

the class Scopes method deleteFromList.

public void deleteFromList(String name) {
    for (WebElement row : scopes().rows()) {
        ScopeRepresentation actual = scopes().toRepresentation(row);
        if (actual.getName().equalsIgnoreCase(name)) {
            WebElement td = row.findElements(tagName("td")).get(2);
            td.findElement(By.className("dropdown-toggle")).click();
            WebElement actions = td.findElement(By.className("dropdown-menu"));
            actions.findElement(By.linkText("Delete")).click();
            modalDialog.confirmDeletion();
        }
    }
}
Also used : ScopeRepresentation(org.keycloak.representations.idm.authorization.ScopeRepresentation) WebElement(org.openqa.selenium.WebElement)

Example 20 with ScopeRepresentation

use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.

the class Scopes method name.

public Scope name(String name) {
    for (WebElement row : scopes().rows()) {
        ScopeRepresentation actual = scopes().toRepresentation(row);
        if (actual.getName().equalsIgnoreCase(name)) {
            clickLink(row.findElements(tagName("a")).get(0));
            WaitUtils.waitForPageToLoad();
            return scope;
        }
    }
    return null;
}
Also used : ScopeRepresentation(org.keycloak.representations.idm.authorization.ScopeRepresentation) WebElement(org.openqa.selenium.WebElement)

Aggregations

ScopeRepresentation (org.keycloak.representations.idm.authorization.ScopeRepresentation)48 ResourceRepresentation (org.keycloak.representations.idm.authorization.ResourceRepresentation)27 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)14 List (java.util.List)12 Response (javax.ws.rs.core.Response)11 HashSet (java.util.HashSet)10 AuthorizationResource (org.keycloak.admin.client.resource.AuthorizationResource)10 HashMap (java.util.HashMap)8 Map (java.util.Map)8 Set (java.util.Set)8 AuthzClient (org.keycloak.authorization.client.AuthzClient)8 Arrays (java.util.Arrays)7 AuthorizationRequest (org.keycloak.representations.idm.authorization.AuthorizationRequest)7 PolicyRepresentation (org.keycloak.representations.idm.authorization.PolicyRepresentation)7 Collection (java.util.Collection)6 Collectors (java.util.stream.Collectors)6 ResourceScopesResource (org.keycloak.admin.client.resource.ResourceScopesResource)5 HttpResponseException (org.keycloak.authorization.client.util.HttpResponseException)5 WebElement (org.openqa.selenium.WebElement)5