[KEYCLOAK-8625] - Saving client settings will cause always adding default authorization settings

This commit is contained in:
Pedro Igor 2018-10-19 13:31:03 -03:00
parent f55264499c
commit a2b13715ed
2 changed files with 15 additions and 1 deletions

View file

@ -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;

View file

@ -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());