use of org.apache.jackrabbit.api.security.user.Group in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testSyncExternalUsersLastSyncedProperty.
@Test
public void testSyncExternalUsersLastSyncedProperty() throws Exception {
ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_TEST_USER);
String[] externalId = new String[] { externalUser.getExternalId().getString() };
syncMBean.syncExternalUsers(externalId);
UserManager userManager = getUserManager();
User testUser = userManager.getAuthorizable(externalUser.getId(), User.class);
long lastSynced = testUser.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong();
for (ExternalIdentityRef groupRef : externalUser.getDeclaredGroups()) {
Group gr = userManager.getAuthorizable(groupRef.getId(), Group.class);
long groupLastSynced = gr.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong();
assertTrue(lastSynced == groupLastSynced);
}
while (System.currentTimeMillis() <= lastSynced) {
// wait for system time to move
}
// default value for forceGroup sync is defined to be 'true' => verify result
syncMBean.syncExternalUsers(externalId);
userManager = getUserManager();
testUser = userManager.getAuthorizable(externalUser.getId(), User.class);
long lastSynced2 = testUser.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong();
assertTrue("lastSynced: " + lastSynced + ", lastSynced2: " + lastSynced2, lastSynced < lastSynced2);
for (ExternalIdentityRef groupRef : externalUser.getDeclaredGroups()) {
Group gr = userManager.getAuthorizable(groupRef.getId(), Group.class);
long groupLastSynced = gr.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong();
assertTrue(lastSynced2 == groupLastSynced);
}
}
use of org.apache.jackrabbit.api.security.user.Group in project jackrabbit-oak by apache.
the class AbstractPrincipalTest method createTestGroup.
Group createTestGroup() throws Exception {
Group gr = getUserManager(root).createGroup("group" + UUID.randomUUID());
root.commit();
return gr;
}
use of org.apache.jackrabbit.api.security.user.Group in project jackrabbit-oak by apache.
the class UserManagerImpl method createGroup.
@Override
public Group createGroup(String groupID, Principal principal, @Nullable String intermediatePath) throws RepositoryException {
checkValidId(groupID);
checkValidPrincipal(principal, true);
if (intermediatePath != null) {
intermediatePath = namePathMapper.getOakPath(intermediatePath);
}
Tree groupTree = userProvider.createGroup(groupID, intermediatePath);
setPrincipal(groupTree, principal);
Group group = new GroupImpl(groupID, groupTree, this);
onCreate(group);
log.debug("Group created: " + groupID);
return group;
}
use of org.apache.jackrabbit.api.security.user.Group in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testCreateSyncedIdentityEmptyLastSyncedProperty.
@Test
public void testCreateSyncedIdentityEmptyLastSyncedProperty() throws Exception {
Group gr = createTestGroup();
gr.setProperty(DefaultSyncContext.REP_LAST_SYNCED, new Value[0]);
SyncedIdentity si = DefaultSyncContext.createSyncedIdentity(gr);
assertNotNull(si);
assertEquals(-1, si.lastSynced());
}
use of org.apache.jackrabbit.api.security.user.Group in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncByIdUsingExceptionId.
@Test(expected = SyncException.class)
public void testSyncByIdUsingExceptionId() throws Exception {
Group gr = userManager.createGroup(TestIdentityProvider.ID_EXCEPTION);
setExternalID(gr, idp.getName());
syncCtx.sync(TestIdentityProvider.ID_EXCEPTION);
}
Aggregations