diff --git a/services/src/main/java/org/keycloak/authorization/admin/ResourceServerService.java b/services/src/main/java/org/keycloak/authorization/admin/ResourceServerService.java index c31d393ead..45117b79bd 100644 --- a/services/src/main/java/org/keycloak/authorization/admin/ResourceServerService.java +++ b/services/src/main/java/org/keycloak/authorization/admin/ResourceServerService.java @@ -85,9 +85,9 @@ public class ResourceServerService { if (this.resourceServer == null) { this.resourceServer = RepresentationToModel.createResourceServer(client, session, true); + createDefaultPermission(createDefaultResource(), createDefaultPolicy()); } - createDefaultPermission(createDefaultResource(), createDefaultPolicy()); audit(OperationType.CREATE, session.getContext().getUri(), newClient); return resourceServer; diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authorization/DefaultAuthorizationSettingsTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authorization/DefaultAuthorizationSettingsTest.java index c493b10b11..4628b68d71 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authorization/DefaultAuthorizationSettingsTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authorization/DefaultAuthorizationSettingsTest.java @@ -20,8 +20,12 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import java.util.List; + import org.junit.Test; +import org.keycloak.admin.client.resource.AuthorizationResource; import org.keycloak.representations.adapters.config.PolicyEnforcerConfig; +import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.authorization.PolicyRepresentation; import org.keycloak.representations.idm.authorization.ResourceRepresentation; import org.keycloak.testsuite.console.page.clients.authorization.AuthorizationSettingsForm; @@ -37,6 +41,16 @@ public class DefaultAuthorizationSettingsTest extends AbstractAuthorizationSetti @Test public void testDefaultSettings() { + assertDefaultSettings(); + authorizationPage.tabs().settings(); + clientSettingsPage.form().setName("changed"); + clientSettingsPage.form().save(); + assertAlertSuccess(); + clientSettingsPage.tabs().authorization(); + assertDefaultSettings(); + } + + private void assertDefaultSettings() { AuthorizationSettingsForm settings = authorizationPage.settings(); assertEquals(PolicyEnforcerConfig.EnforcementMode.ENFORCING, settings.getEnforcementMode());