use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.
the class ResourceManagementTest method testUpdate.
@Test
public void testUpdate() {
ResourceRepresentation expected = createResource();
String previousName = expected.getName();
expected.setName("changed");
expected.setDisplayName("changed");
expected.setType("changed");
expected.setUri("changed");
expected.setScopes(Arrays.asList("Scope A", "Scope B", "Scope C").stream().map(name -> new ScopeRepresentation(name)).collect(Collectors.toSet()));
authorizationPage.navigateTo();
Resource resource = authorizationPage.authorizationTabs().resources().name(previousName);
resource.update(expected);
assertAlertSuccess();
assertResource(expected);
expected.setScopes(expected.getScopes().stream().filter(scope -> scope.getName().equals("Scope C")).collect(Collectors.toSet()));
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().resources().update(expected.getName(), expected);
assertAlertSuccess();
assertResource(expected);
}
use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.
the class ResourceManagementTest method configureTest.
@Before
@Override
public void configureTest() {
super.configureTest();
for (String scopeName : Arrays.asList("Scope A", "Scope B", "Scope C")) {
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().scopes().create(new ScopeRepresentation(scopeName));
}
authorizationPage.navigateTo();
}
use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.
the class ResourceManagementTest method assertResource.
private void assertResource(ResourceRepresentation expected) {
authorizationPage.navigateTo();
ResourceRepresentation actual = authorizationPage.authorizationTabs().resources().resources().findByName(expected.getName());
assertEquals(expected.getName(), actual.getName());
assertEquals(expected.getType(), actual.getType());
assertEquals(expected.getUri(), actual.getUri());
assertEquals(expected.getIconUri(), actual.getIconUri());
ResourceRepresentation resource = authorizationPage.authorizationTabs().resources().name(expected.getName()).toRepresentation();
assertEquals(expected.getDisplayName(), resource.getDisplayName());
Set<ScopeRepresentation> associatedScopes = resource.getScopes();
if (expected.getScopes() != null) {
assertNotNull(associatedScopes);
assertEquals(expected.getScopes().size(), associatedScopes.size());
assertEquals(0, resource.getScopes().stream().filter(actualScope -> !expected.getScopes().stream().filter(expectedScope -> actualScope.getName().equals(expectedScope.getName())).findFirst().isPresent()).count());
} else {
assertTrue(associatedScopes.isEmpty());
}
}
Aggregations