-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optionally assign IMS group administrators
This closes #749
- Loading branch information
Showing
6 changed files
with
110 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...l-bundle/src/main/java/biz/netcentric/cq/tools/actool/ims/request/AddGroupMembership.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package biz.netcentric.cq.tools.actool.ims.request; | ||
|
||
/*- | ||
* #%L | ||
* Access Control Tool Bundle | ||
* %% | ||
* Copyright (C) 2015 - 2024 Cognizant Netcentric | ||
* %% | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* #L% | ||
*/ | ||
|
||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
|
||
/** Maintains memberships of users in (admin) groups, to be used with {@link UserActionCommand}. | ||
* @see AddGroupMembers | ||
*/ | ||
@JsonTypeName("add") | ||
@JsonInclude(Include.NON_EMPTY) // neither empty strings nor null values are allowed for the fields | ||
public class AddGroupMembership implements Step { | ||
|
||
public AddGroupMembership(Collection<String> group) { | ||
this.group = new HashSet<>(group); | ||
} | ||
|
||
@JsonProperty("group") | ||
public Set<String> group; | ||
} |
26 changes: 26 additions & 0 deletions
26
...ol-bundle/src/main/java/biz/netcentric/cq/tools/actool/ims/request/UserActionCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package biz.netcentric.cq.tools.actool.ims.request; | ||
|
||
/*- | ||
* #%L | ||
* Access Control Tool Bundle | ||
* %% | ||
* Copyright (C) 2015 - 2024 Cognizant Netcentric | ||
* %% | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* #L% | ||
*/ | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class UserActionCommand extends ActionCommand { | ||
|
||
public UserActionCommand(String user) { | ||
this.user = user; | ||
} | ||
|
||
@JsonProperty("user") | ||
String user; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,7 @@ public HttpClientBuilder newBuilder() { | |
|
||
@Test | ||
void testGroupWithInvalidProductProfileMembership() throws IOException { | ||
properties.put("productProfiles", "Invalid name"); | ||
properties.put("productProfiles", getMandatoryEnvironmentVariable("ACTOOL_IMS_IT_USERID")); | ||
Configuration config = Converters.standardConverter().convert(properties).to(Configuration.class); | ||
IMSUserManagement imsUserManagement = new IMSUserManagement(config, new HttpClientBuilderFactory() { | ||
@Override | ||
|
@@ -116,6 +116,22 @@ public HttpClientBuilder newBuilder() { | |
assertTrue(t.getMessage().contains("error.plc.not_found"), "Exceptions message is supposed to contain 'error.plc.not_found' but was " + t.getMessage()); | ||
} | ||
|
||
@Test | ||
void testGroupWithAdmin() throws IOException { | ||
properties.put("groupAdmins", "[email protected]"); | ||
Configuration config = Converters.standardConverter().convert(properties).to(Configuration.class); | ||
IMSUserManagement imsUserManagement = new IMSUserManagement(config, new HttpClientBuilderFactory() { | ||
@Override | ||
public HttpClientBuilder newBuilder() { | ||
return HttpClientBuilder.create(); | ||
} | ||
}); | ||
AuthorizableConfigBean group = new AuthorizableConfigBean(); | ||
group.setAuthorizableId("testGroup"); | ||
group.setDescription("my description"); | ||
imsUserManagement.updateGroups(Collections.singleton(group)); | ||
} | ||
|
||
private static String getMandatoryEnvironmentVariable(String name) { | ||
String value = System.getenv(name); | ||
if (value == null) { | ||
|