Skip to content
Permalink
Browse files
OAK-9773: DefaultSyncContext#syncMembership() compares external ids c…
…ase-sensitively.

Added test case.
  • Loading branch information
Manfred Baedke committed Jun 10, 2022
1 parent 469ee05 commit 2d3b2d44a0a5646efa54d857d2f59162cd05e984
Showing 2 changed files with 24 additions and 3 deletions.
@@ -90,7 +90,7 @@ public void addUser(TestIdentity user) {
externalUsers.put(user.getId().toLowerCase(), (ExternalUser) user);
}

private void addGroup(TestIdentity group) {
public void addGroup(TestIdentity group) {
externalGroups.put(group.getId().toLowerCase(), (ExternalGroup) group);
}

@@ -221,13 +221,13 @@ public Iterable<ExternalIdentityRef> getDeclaredGroups() throws ExternalIdentity
}

@NotNull
protected TestIdentity withProperty(@NotNull String name, @NotNull Object value) {
public TestIdentity withProperty(@NotNull String name, @NotNull Object value) {
props.put(name, value);
return this;
}

@NotNull
protected TestIdentity withGroups(@NotNull String ... grps) {
public TestIdentity withGroups(@NotNull String ... grps) {
for (String grp: grps) {
groups.add(new ExternalIdentityRef(grp, id.getProviderName()));
}
@@ -20,6 +20,8 @@
import com.google.common.collect.Iterators;
import com.google.common.collect.Sets;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.Group;
import org.apache.jackrabbit.api.security.user.User;
import org.apache.jackrabbit.api.security.user.UserManager;
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity;
@@ -29,6 +31,7 @@
import org.apache.jackrabbit.oak.spi.security.authentication.external.SyncHandler;
import org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult;
import org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity;
import org.apache.jackrabbit.oak.spi.security.authentication.external.TestIdentityProvider;
import org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncConfig;
import org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncContext;
import org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity;
@@ -328,6 +331,24 @@ public void testLastSynced() throws Exception {
root.commit();
}

//OAK-9773
@Test
public void testSyncMembershipCaseMismatch() throws Exception {
UserManager userManager = getUserManager(root);
User user = userManager.createUser("thirduser", "thirduser");
user.setProperty(REP_EXTERNAL_ID, getValueFactory().createValue("thirduser;test"));
Group group = userManager.createGroup("thirdgroup");
group.setProperty(REP_EXTERNAL_ID, getValueFactory().createValue("thirdgroup;test"));
assertTrue(group.addMember(user));
root.commit();
((TestIdentityProvider) idp).addGroup(new TestIdentityProvider.TestGroup("THIRDGROUP", "test"));
((TestIdentityProvider) idp).addUser(
new TestIdentityProvider.TestUser("THIRDUSER", "test").withGroups("THIRDGROUP"));

syncHandler.createContext(idp, userManager, getValueFactory()).sync(user.getID());
assertTrue(group.isMember(user));
}

@Test
public void testActivate() {
DefaultSyncHandler handler = new DefaultSyncHandler();

0 comments on commit 2d3b2d4

Please sign in to comment.