[KEYCLOAK-8049] - Prevent users from not choosing a group
This commit is contained in:
parent
90b35cc13d
commit
421ec34557
3 changed files with 22 additions and 3 deletions
|
@ -171,8 +171,9 @@ public class GroupPolicyProviderFactory implements PolicyProviderFactory<GroupPo
|
|||
group = authorization.getRealm().getGroupById(definition.getId());
|
||||
}
|
||||
|
||||
if (group == null) {
|
||||
String path = definition.getPath();
|
||||
String path = definition.getPath();
|
||||
|
||||
if (group == null && path != null) {
|
||||
String canonicalPath = path.startsWith("/") ? path.substring(1, path.length()) : path;
|
||||
|
||||
if (canonicalPath != null) {
|
||||
|
|
|
@ -169,6 +169,20 @@ public class GroupPolicyManagementTest extends AbstractAuthorizationSettingsTest
|
|||
assertNull(authorizationPage.authorizationTabs().policies().policies().findByName(expected.getName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveWithInInvalidGroup() throws InterruptedException {
|
||||
authorizationPage.navigateTo();
|
||||
GroupPolicyRepresentation expected = new GroupPolicyRepresentation();
|
||||
|
||||
expected.setName("Test Invalid Group Policy");
|
||||
expected.setDescription("description");
|
||||
expected.addGroupPath("/Groups", true);
|
||||
|
||||
authorizationPage.authorizationTabs().policies().create(expected, false);
|
||||
|
||||
alert.assertDanger("Error! You must choose a group");
|
||||
}
|
||||
|
||||
private GroupPolicyRepresentation createPolicy(GroupPolicyRepresentation expected) {
|
||||
GroupPolicy policy = authorizationPage.authorizationTabs().policies().create(expected);
|
||||
assertAlertSuccess();
|
||||
|
|
|
@ -1772,7 +1772,7 @@ module.controller('ResourceServerPolicyRoleDetailCtrl', function($scope, $route,
|
|||
}
|
||||
});
|
||||
|
||||
module.controller('ResourceServerPolicyGroupDetailCtrl', function($scope, $route, realm, client, Client, Groups, Group, PolicyController) {
|
||||
module.controller('ResourceServerPolicyGroupDetailCtrl', function($scope, $route, realm, client, Client, Groups, Group, PolicyController, Notifications) {
|
||||
PolicyController.onInit({
|
||||
getPolicyType : function() {
|
||||
return "group";
|
||||
|
@ -1821,6 +1821,10 @@ module.controller('ResourceServerPolicyGroupDetailCtrl', function($scope, $route
|
|||
return
|
||||
}
|
||||
}
|
||||
if (group.id == "realm") {
|
||||
Notifications.error("You must choose a group");
|
||||
return;
|
||||
}
|
||||
$scope.selectedGroups.push({id: group.id, path: group.path});
|
||||
$scope.changed = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue