Skip to content

Commit 2e2b869

Browse files
committed
Adding statements to investigate GH actions failures
1 parent 46d4279 commit 2e2b869

File tree

4 files changed

+59
-13
lines changed

4 files changed

+59
-13
lines changed

fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ private static <T> T execOnLDAP(
817817
return execOnLDAP(bindDn, bindPassword, connInstance, function);
818818
}
819819

820-
private static <T> T execOnLDAP(final ThrowingFunction<LDAPConnection, T> function) throws LDAPException {
820+
protected static <T> T execOnLDAP(final ThrowingFunction<LDAPConnection, T> function) throws LDAPException {
821821
ConnInstanceTO connInstance = CONNECTOR_SERVICE.read("74141a3b-0762-4720-a4aa-fc3e374ef3ef", null);
822822

823823
return execOnLDAP(

fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuditITCase.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
import static org.junit.jupiter.api.Assertions.assertTrue;
2828
import static org.junit.jupiter.api.Assertions.fail;
2929

30+
import com.unboundid.ldap.sdk.LDAPException;
31+
import com.unboundid.ldap.sdk.SearchRequest;
32+
import com.unboundid.ldap.sdk.SearchScope;
3033
import jakarta.ws.rs.core.Response;
3134
import java.io.File;
3235
import java.io.IOException;
@@ -576,8 +579,17 @@ public void issueSYNCOPE1695() {
576579
pullTaskTO.setDestinationRealm(SyncopeConstants.ROOT_REALM);
577580
pullTaskTO.setMatchingRule(MatchingRule.UPDATE);
578581
pullTaskTO.setUnmatchingRule(UnmatchingRule.ASSIGN);
579-
RECONCILIATION_SERVICE.pull(new ReconQuery.Builder(AnyTypeKind.USER.name(), RESOURCE_NAME_LDAP).
580-
fiql("uid==pullFromLDAP").build(), pullTaskTO);
582+
try {
583+
RECONCILIATION_SERVICE.pull(new ReconQuery.Builder(AnyTypeKind.USER.name(), RESOURCE_NAME_LDAP).
584+
fiql("uid==pullFromLDAP").build(), pullTaskTO);
585+
} catch (Exception e) {
586+
try {
587+
execOnLDAP(ldapConn -> ldapConn.searchForEntry(
588+
new SearchRequest("uid=pullFromLDAP,ou=people,o=isp", SearchScope.BASE, "objectClass=*")));
589+
} catch (LDAPException ldape) {
590+
fail("While reading pullFromLDAP from LDAP", ldape);
591+
}
592+
}
581593

582594
// update pullTaskTO -> another audit entry
583595
pullFromLDAP = updateUser(new UserUR.Builder(USER_SERVICE.read("pullFromLDAP").getKey()).

fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
import static org.junit.jupiter.api.Assertions.fail;
2929
import static org.junit.jupiter.api.Assumptions.assumeFalse;
3030

31+
import com.unboundid.ldap.sdk.LDAPException;
32+
import com.unboundid.ldap.sdk.SearchRequest;
33+
import com.unboundid.ldap.sdk.SearchScope;
3134
import jakarta.ws.rs.core.Response;
3235
import java.io.IOException;
3336
import java.io.InputStream;
@@ -1285,12 +1288,21 @@ public void issueSYNCOPE313LDAP() throws Exception {
12851288
assertNotNull(self);
12861289

12871290
// 4. Check that the LDAP resource has the old password
1288-
ConnObject connObject =
1289-
RESOURCE_SERVICE.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), user.getKey());
1290-
assertNotNull(getLdapRemoteObject(
1291-
connObject.getAttr(Name.NAME).orElseThrow().getValues().getFirst(),
1292-
oldCleanPassword,
1293-
connObject.getAttr(Name.NAME).orElseThrow().getValues().getFirst()));
1291+
try {
1292+
ConnObject connObject = RESOURCE_SERVICE.readConnObject(
1293+
RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), user.getKey());
1294+
assertNotNull(getLdapRemoteObject(
1295+
connObject.getAttr(Name.NAME).orElseThrow().getValues().getFirst(),
1296+
oldCleanPassword,
1297+
connObject.getAttr(Name.NAME).orElseThrow().getValues().getFirst()));
1298+
} catch (Exception e) {
1299+
try {
1300+
execOnLDAP(ldapConn -> ldapConn.searchForEntry(
1301+
new SearchRequest("uid=pullFromLDAP,ou=people,o=isp", SearchScope.BASE, "objectClass=*")));
1302+
} catch (LDAPException ldape) {
1303+
fail("While reading pullFromLDAP from LDAP", ldape);
1304+
}
1305+
}
12941306

12951307
// 5. Update the LDAP Connector to retrieve passwords
12961308
ResourceTO ldapResource = RESOURCE_SERVICE.read(RESOURCE_NAME_LDAP);
@@ -1402,8 +1414,18 @@ public void issueSYNCOPE1062() {
14021414
group = GROUP_SERVICE.read("testLDAPGroup");
14031415
assertNotNull(group);
14041416

1405-
ConnObject connObject =
1406-
RESOURCE_SERVICE.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), user.getKey());
1417+
ConnObject connObject = null;
1418+
try {
1419+
connObject = RESOURCE_SERVICE.readConnObject(
1420+
RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), user.getKey());
1421+
} catch (Exception e) {
1422+
try {
1423+
execOnLDAP(ldapConn -> ldapConn.searchForEntry(
1424+
new SearchRequest("uid=pullFromLDAP,ou=people,o=isp", SearchScope.BASE, "objectClass=*")));
1425+
} catch (LDAPException ldape) {
1426+
fail("While reading pullFromLDAP from LDAP", ldape);
1427+
}
1428+
}
14071429
assertNotNull(connObject);
14081430
assertEquals(
14091431
"pullFromLDAP@syncope.apache.org",

fit/core-reference/src/test/java/org/apache/syncope/fit/core/PushTaskITCase.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import static org.junit.jupiter.api.Assertions.assertTrue;
2626
import static org.junit.jupiter.api.Assertions.fail;
2727

28+
import com.unboundid.ldap.sdk.LDAPException;
29+
import com.unboundid.ldap.sdk.SearchRequest;
30+
import com.unboundid.ldap.sdk.SearchScope;
2831
import jakarta.ws.rs.core.Response;
2932
import java.util.HashMap;
3033
import java.util.Map;
@@ -129,8 +132,17 @@ public void pushMatchingUnmatchingGroups() {
129132
execSchedTask(
130133
TASK_SERVICE, TaskType.PUSH, "fd905ba5-9d56-4f51-83e2-859096a67b75", MAX_WAIT_SECONDS, false);
131134

132-
assertNotNull(RESOURCE_SERVICE.readConnObject(
133-
RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), "29f96485-729e-4d31-88a1-6fc60e4677f3"));
135+
try {
136+
assertNotNull(RESOURCE_SERVICE.readConnObject(
137+
RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), "29f96485-729e-4d31-88a1-6fc60e4677f3"));
138+
} catch (Exception e) {
139+
try {
140+
execOnLDAP(ldapConn -> ldapConn.searchForEntry(
141+
new SearchRequest("uid=pullFromLDAP,ou=people,o=isp", SearchScope.BASE, "objectClass=*")));
142+
} catch (LDAPException ldape) {
143+
fail("While reading pullFromLDAP from LDAP", ldape);
144+
}
145+
}
134146
assertTrue(GROUP_SERVICE.read("29f96485-729e-4d31-88a1-6fc60e4677f3").
135147
getResources().contains(RESOURCE_NAME_LDAP));
136148
}

0 commit comments

Comments
 (0)