Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 6, 2023
2 parents 659d25c + 3116c2e commit 7ce7029
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public PageEmailNonce() {

private boolean alreadyHasNonce() {
UserType user = searchUser();
if (user.getCredentials() == null) {
if (user == null || user.getCredentials() == null) {
return false;
}
NonceType nonceType = user.getCredentials().getNonce();
Expand Down
5 changes: 4 additions & 1 deletion repo/audit-log-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ public void test800ImportSyncTask() throws Exception {

// WHEN
when();
addObject(getSyncTaskFile(), task, result);
getSyncTask().init(AbstractLdapSynchronizationTest.this, task, result);

// THEN
then();
assertSuccess(result);

waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

long tsEnd = System.currentTimeMillis();

assertStepSyncToken(getSyncTaskOid(), 0, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 0, tsStart, tsEnd);
}

@Test
Expand All @@ -123,7 +123,8 @@ public void test801SyncAddAccountHt() throws Exception {

syncWait();

waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);


// THEN
then();
Expand All @@ -137,7 +138,7 @@ public void test801SyncAddAccountHt() throws Exception {
assertNotNull("No user " + ACCOUNT_HT_UID + " created", user);
assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN);

assertStepSyncToken(getSyncTaskOid(), 1, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 1, tsStart, tsEnd);
}

/**
Expand Down Expand Up @@ -166,7 +167,7 @@ public void test802ModifyAccountHtSn() throws Exception {

syncWait();

waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

// THEN
then();
Expand All @@ -178,7 +179,7 @@ public void test802ModifyAccountHtSn() throws Exception {
assertNotNull("No user " + ACCOUNT_HT_UID + " created", user);
assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);

assertStepSyncToken(getSyncTaskOid(), 2, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 2, tsStart, tsEnd);

}

Expand All @@ -200,7 +201,7 @@ public void test810SyncAddGroupMonkeys() throws Exception {

syncWait();

waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

// THEN
then();
Expand All @@ -214,7 +215,7 @@ public void test810SyncAddGroupMonkeys() throws Exception {
PrismAsserts.assertPropertyValue(role, RoleType.F_DESCRIPTION, GROUP_MONKEYS_DESCRIPTION);
assertNotNull("No role " + GROUP_MONKEYS_CN + " created", role);

assertStepSyncToken(getSyncTaskOid(), 3, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 3, tsStart, tsEnd);
}

@Test
Expand Down Expand Up @@ -242,7 +243,7 @@ public void test817RenameAccount() throws Exception {

syncWait();

waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

// THEN
then();
Expand All @@ -255,7 +256,7 @@ public void test817RenameAccount() throws Exception {
assertUser(user, user.getOid(), ACCOUNT_HTM_UID, getAccountHtmCnAfterRename(), ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);
assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID));

assertStepSyncToken(getSyncTaskOid(), 4, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 4, tsStart, tsEnd);

}

Expand Down Expand Up @@ -287,7 +288,7 @@ public void test818DeleteAccountHtm() throws Exception {

syncWait();

waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

// THEN
then();
Expand All @@ -304,7 +305,7 @@ public void test818DeleteAccountHtm() throws Exception {
deleteObject(UserType.class, user.getOid(), task, result);
}

assertStepSyncToken(getSyncTaskOid(), 5, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 5, tsStart, tsEnd);
}

// TODO: sync with "ALL" object class
Expand All @@ -317,11 +318,12 @@ public void test819DeleteSyncTask() throws Exception {

// WHEN
when();
suspendAndDeleteTasks(getSyncTaskOid());
getSyncTask().suspend();
deleteObject(TaskType.class, getSyncTask().oid);

// THEN
then();
assertNoObject(TaskType.class, getSyncTaskOid(), task, result);
assertNoObject(TaskType.class, getSyncTask().oid, task, result);
}

@Test
Expand All @@ -334,20 +336,20 @@ public void test820ImportSyncTaskInetOrgPerson() throws Exception {

// WHEN
when();
addObject(getSyncTaskInetOrgPersonFile(), task, result);
getSyncTaskInetOrgPerson().init(AbstractLdapSynchronizationTest.this, task, result);

// THEN
then();
assertSuccess(result);

waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTaskInetOrgPerson().rerun(result);

long tsEnd = System.currentTimeMillis();

PrismObject<TaskType> syncTask = getTask(getSyncTaskOid());
PrismObject<TaskType> syncTask = getTask(getSyncTaskInetOrgPerson().oid);
display("Sync task after start", syncTask);

assertStepSyncToken(getSyncTaskOid(), 5, tsStart, tsEnd);
assertStepSyncToken(getSyncTaskInetOrgPerson().oid, 5, tsStart, tsEnd);
}

@Test
Expand All @@ -361,7 +363,7 @@ public void test821SyncAddAccountHt() throws Exception {
// WHEN
when();
addLdapAccount(ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN);
waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

// THEN
then();
Expand All @@ -375,7 +377,7 @@ public void test821SyncAddAccountHt() throws Exception {
assertNotNull("No user " + ACCOUNT_HT_UID + " created", user);
assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN);

assertStepSyncToken(getSyncTaskOid(), 6, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 6, tsStart, tsEnd);
}

@Test
Expand All @@ -393,7 +395,7 @@ public void test822ModifyAccountHt() throws Exception {
connection.modify(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN), modCn);
ldapDisconnect(connection);

waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

// THEN
then();
Expand All @@ -405,7 +407,7 @@ public void test822ModifyAccountHt() throws Exception {
assertNotNull("No user " + ACCOUNT_HT_UID + " created", user);
assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);

assertStepSyncToken(getSyncTaskOid(), 7, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 7, tsStart, tsEnd);
}

/**
Expand All @@ -422,7 +424,7 @@ public void test830AddGroupFools() throws Exception {
// WHEN
when();
addLdapGroup(GROUP_FOOLS_CN, GROUP_FOOLS_DESCRIPTION, toGroupDn("nobody"));
waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

// THEN
then();
Expand All @@ -433,7 +435,7 @@ public void test830AddGroupFools() throws Exception {
PrismObject<RoleType> roleFools = findObjectByName(RoleType.class, GROUP_FOOLS_CN);
assertNull("Unexpected role " + roleFools, roleFools);

assertStepSyncToken(getSyncTaskOid(), 8, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 8, tsStart, tsEnd);
}

@Test
Expand All @@ -459,7 +461,7 @@ public void test837RenameAccount() throws Exception {

ldapDisconnect(connection);

waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

// THEN
then();
Expand All @@ -472,7 +474,7 @@ public void test837RenameAccount() throws Exception {
assertUser(user, user.getOid(), ACCOUNT_HTM_UID, getAccountHtmCnAfterRename(), ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);
assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID));

assertStepSyncToken(getSyncTaskOid(), 9, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 9, tsStart, tsEnd);

}

Expand All @@ -492,7 +494,7 @@ public void test838DeleteAccountHtm() throws Exception {
when();
deleteLdapEntry(toAccountDn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN));

waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

// THEN
then();
Expand All @@ -508,7 +510,7 @@ public void test838DeleteAccountHtm() throws Exception {
deleteObject(UserType.class, user.getOid(), task, result);
}

assertStepSyncToken(getSyncTaskOid(), 10, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 10, tsStart, tsEnd);
}

@Test
Expand All @@ -519,13 +521,14 @@ public void test849DeleteSyncTask() throws Exception {

// WHEN
when();
suspendAndDeleteTasks(getSyncTaskOid());
getSyncTask().suspend();
deleteObject(TaskType.class, getSyncTask().oid);

// THEN
then();
assertSuccess(result);

assertNoObject(TaskType.class, getSyncTaskOid(), task, result);
assertNoObject(TaskType.class, getSyncTask().oid, task, result);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import javax.net.ssl.X509TrustManager;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.test.TestTask;

import org.apache.directory.api.ldap.codec.api.DefaultConfigurableBinaryAttributeDetector;
import org.apache.directory.api.ldap.model.cursor.CursorException;
import org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException;
Expand Down Expand Up @@ -139,6 +141,21 @@ public abstract class AbstractLdapTest extends AbstractModelIntegrationTest {

protected Lsof lsof;

private TestTask taskLiveSync;
private TestTask taskLiveSyncInetOrgPerson;

@Override
public void initSystem() throws Exception {
super.initSystem();

taskLiveSync = new TestTask(getBaseDir(), "task-sync.xml", getSyncTaskOid());
taskLiveSyncInetOrgPerson = initTaskLiveSyncInetOrgPerson();
}

protected TestTask initTaskLiveSyncInetOrgPerson() {
return new TestTask(getBaseDir(), "task-sync-inetorgperson.xml", getSyncTaskOid());
}

@Override
protected void startResources() throws Exception {
super.startResources();
Expand Down Expand Up @@ -173,16 +190,16 @@ protected File getResourceFile() {
return new File(getBaseDir(), "resource.xml");
}

protected File getSyncTaskFile() {
return new File(getBaseDir(), "task-sync.xml");
protected TestTask getSyncTask() {
return taskLiveSync;
}

protected String getResourceNamespace() {
return MidPointConstants.NS_RI;
}

protected File getSyncTaskInetOrgPersonFile() {
return new File(getBaseDir(), "task-sync-inetorgperson.xml");
protected final TestTask getSyncTaskInetOrgPerson() {
return taskLiveSyncInetOrgPerson;
}

protected abstract String getSyncTaskOid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2292,17 +2292,17 @@ public void test900ImportSyncTask() throws Exception {

// WHEN
when();
addObject(getSyncTaskFile(), task, result);
getSyncTask().init(AbstractAdLdapMultidomainTest.this, task, result);

// THEN
then();
assertSuccess(result);

waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

long tsEnd = System.currentTimeMillis();

assertStepSyncToken(getSyncTaskOid(), 0, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 0, tsStart, tsEnd);
}

@Test
Expand All @@ -2316,7 +2316,7 @@ public void test901SyncAddAccountHt() throws Exception {
// WHEN
when();
addLdapAccount(ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN);
waitForTaskNextRunAssertSuccess(getSyncTaskOid());
getSyncTask().rerun(result);

// THEN
then();
Expand All @@ -2330,7 +2330,7 @@ public void test901SyncAddAccountHt() throws Exception {
assertNotNull("No user " + ACCOUNT_HT_UID + " created", user);
assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN);

assertStepSyncToken(getSyncTaskOid(), 1, tsStart, tsEnd);
assertStepSyncToken(getSyncTask().oid, 1, tsStart, tsEnd);
}

protected void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition;

import com.evolveum.midpoint.test.TestTask;
import com.evolveum.midpoint.testing.conntest.ad.AdTestMixin;

import com.evolveum.midpoint.util.exception.ConfigurationException;
Expand Down Expand Up @@ -193,9 +194,8 @@ protected boolean allowDuplicateSearchResults() {
return allowDuplicateSearchResults;
}

@Override
protected File getSyncTaskInetOrgPersonFile() {
return new File(getBaseDir(), "task-sync-user.xml");
protected TestTask initTaskLiveSyncInetOrgPerson() {
return new TestTask(getBaseDir(), "task-sync-user.xml", getSyncTaskOid());
}

@Override
Expand Down

0 comments on commit 7ce7029

Please sign in to comment.