diff --git a/services/src/main/java/org/keycloak/services/models/picketlink/ApplicationAdapter.java b/services/src/main/java/org/keycloak/services/models/picketlink/ApplicationAdapter.java index 24fcce40f6..d58ede8095 100755 --- a/services/src/main/java/org/keycloak/services/models/picketlink/ApplicationAdapter.java +++ b/services/src/main/java/org/keycloak/services/models/picketlink/ApplicationAdapter.java @@ -154,6 +154,7 @@ public class ApplicationAdapter implements ApplicationModel { ScopeRelationship scope = new ScopeRelationship(); scope.setClient(((UserAdapter)agent).getUser()); scope.setScope(((RoleAdapter)role).getRole()); + getRelationshipManager().add(scope); } @Override diff --git a/services/src/test/java/org/keycloak/test/ImportTest.java b/services/src/test/java/org/keycloak/test/ImportTest.java index 238d593c79..68cd9edb9a 100755 --- a/services/src/test/java/org/keycloak/test/ImportTest.java +++ b/services/src/test/java/org/keycloak/test/ImportTest.java @@ -87,6 +87,13 @@ public class ImportTest { List realms = identitySession.getRealms(admin); Assert.assertEquals(1, realms.size()); + // Test scope relationship + ApplicationModel application = realm.getResourceNameMap().get("Application"); + UserModel oauthClient = realm.getUser("oauthclient"); + Assert.assertNotNull(application); + Assert.assertNotNull(oauthClient); + Set appScopes = application.getScope(oauthClient); + Assert.assertTrue(appScopes.contains("user")); } @Test