Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GroupsHandler #11

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<groupId>com.exclamationlabs.connid.box</groupId>
<artifactId>connector-box</artifactId>
<version>2.2</version>
<version>2.3</version>
<name>ConnId Box Identity connector</name>
<packaging>jar</packaging>

Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/exclamationlabs/connid/box/GroupsHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,27 @@ public ObjectClassInfo getGroupSchema() {

// description
builder.addAttributeInfo(AttributeInfoBuilder.define(ATTR_DESCRIPTION)
.setReturnedByDefault(STANDARD_ATTRS_SET.contains(ATTR_DESCRIPTION))
.build());

// external_sync_identifier
builder.addAttributeInfo(AttributeInfoBuilder.define(ATTR_EXTERNAL_SYNC_IDENTIFIER)
.setReturnedByDefault(STANDARD_ATTRS_SET.contains(ATTR_EXTERNAL_SYNC_IDENTIFIER))
.build());

// invitability_level
builder.addAttributeInfo(AttributeInfoBuilder.define(ATTR_INVITABILITY_LEVEL)
.setReturnedByDefault(STANDARD_ATTRS_SET.contains(ATTR_INVITABILITY_LEVEL))
.build());

// member_viewability_level
builder.addAttributeInfo(AttributeInfoBuilder.define(ATTR_MEMBER_VIEWABILITY_LEVEL)
.setReturnedByDefault(STANDARD_ATTRS_SET.contains(ATTR_MEMBER_VIEWABILITY_LEVEL))
.build());

// provenance
builder.addAttributeInfo(AttributeInfoBuilder.define(ATTR_PROVENANCE)
.setReturnedByDefault(STANDARD_ATTRS_SET.contains(ATTR_PROVENANCE))
.build());

// Association
Expand Down Expand Up @@ -299,7 +304,7 @@ public Set<AttributeDelta> updateGroup(Uid uid, Set<AttributeDelta> modification
BoxGroup.Info info = group.new Info();

for (AttributeDelta delta : modifications) {
if (delta.getName().equals(ATTR_NAME)) {
if (delta.getName().equals(Name.NAME)) {
info.setName(getStringValue(delta));

} else if (delta.getName().equals(ATTR_PROVENANCE)) {
Expand All @@ -320,7 +325,9 @@ public Set<AttributeDelta> updateGroup(Uid uid, Set<AttributeDelta> modification
}

try {
info.getResource().updateInfo(info);
if (info.getPendingChangesAsJsonObject() != null) {
info.getResource().updateInfo(info);
}

// Box doesn't support to modify group's id
return null;
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/com/exclamationlabs/connid/box/GroupUpdateTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,30 @@ void updateGroup_otherError() {
assertNotNull(e);
assertEquals(2, count.get());
}

@Test
void renameGroup() {
// Given
String groupName = "Tech";

Set<AttributeDelta> modifications = new HashSet<>();
modifications.add(AttributeDeltaBuilder.build(Name.NAME, "Support"));

AtomicReference<BoxAPIRequest> request = new AtomicReference<>();
mockAPI.push(req -> {
request.set(req);

return ok("group-update.json");
});

// When
Set<AttributeDelta> sideEffects = connector.updateDelta(OBJECT_CLASS_GROUP,
new Uid("11446498", new Name(groupName)),
modifications, new OperationOptionsBuilder().build());

// Then
assertNotNull(request.get());
assertEquals("Support", getJsonAttr(request.get(), "name"));
assertNull(sideEffects);
}
}
Loading