Skip to content

Commit 690effe

Browse files
committed
Fixing failing Payara test
1 parent a83ccaf commit 690effe

File tree

4 files changed

+46
-56
lines changed

4 files changed

+46
-56
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@
6060
import org.apache.commons.lang3.mutable.Mutable;
6161
import org.apache.commons.lang3.mutable.MutableObject;
6262
import org.apache.commons.lang3.tuple.Pair;
63+
import org.apache.cxf.configuration.jsse.TLSClientParameters;
6364
import org.apache.cxf.jaxrs.client.WebClient;
65+
import org.apache.cxf.transport.http.HTTPConduit;
66+
import org.apache.cxf.transport.https.InsecureTrustManager;
6467
import org.apache.syncope.client.lib.SyncopeAnonymousClient;
6568
import org.apache.syncope.client.lib.SyncopeClient;
6669
import org.apache.syncope.client.lib.SyncopeClientFactoryBean;
@@ -403,6 +406,8 @@ public void initialize(final ConfigurableApplicationContext ctx) {
403406

404407
private static int POP3_PORT;
405408

409+
protected static boolean IS_DEPLOYED_IN_PAYARA = false;
410+
406411
protected static boolean IS_FLOWABLE_ENABLED = false;
407412

408413
protected static boolean IS_EXT_SEARCH_ENABLED = false;
@@ -452,6 +457,25 @@ private static void initExtSearch(
452457
assertEquals(ExecStatus.SUCCESS, ExecStatus.valueOf(exec.getStatus()));
453458
}
454459

460+
@BeforeAll
461+
public static void jakartaEEContainerCheck() throws IOException {
462+
TLSClientParameters tlsParams = new TLSClientParameters();
463+
tlsParams.setTrustManagers(InsecureTrustManager.getNoOpX509TrustManagers());
464+
tlsParams.setDisableCNCheck(true);
465+
466+
WebClient webClient = WebClient.create("https://localhost:8181/");
467+
HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
468+
conduit.getClient().setConnectionTimeout(2000);
469+
conduit.getClient().setReceiveTimeout(2000);
470+
conduit.setTlsClientParameters(tlsParams);
471+
472+
try {
473+
IS_DEPLOYED_IN_PAYARA = webClient.get().readEntity(String.class).contains("Payara");
474+
} catch (Exception e) {
475+
LOG.debug("While checking if Syncope Core is deployed in Payara", e);
476+
}
477+
}
478+
455479
@BeforeAll
456480
public static void anonymousSetup() throws IOException {
457481
try (InputStream propStream = AbstractITCase.class.getResourceAsStream("/core.properties")) {

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

Lines changed: 19 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.syncope.fit.core;
2020

2121
import static org.awaitility.Awaitility.await;
22+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
2223
import static org.junit.jupiter.api.Assertions.assertEquals;
2324
import static org.junit.jupiter.api.Assertions.assertFalse;
2425
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@@ -29,7 +30,6 @@
2930
import static org.junit.jupiter.api.Assumptions.assumeFalse;
3031

3132
import jakarta.ws.rs.HttpMethod;
32-
import jakarta.ws.rs.core.GenericType;
3333
import jakarta.ws.rs.core.MediaType;
3434
import jakarta.ws.rs.core.Response;
3535
import java.io.IOException;
@@ -154,7 +154,6 @@ public void issue186() {
154154
userCR.getPlainAttrs().add(attr("surname", userId));
155155

156156
UserTO userTO = createUser(userCR).getEntity();
157-
assertNotNull(userTO);
158157
assertTrue(userTO.getResources().isEmpty());
159158

160159
// 2. update assigning a resource forcing mandatory constraints: must fail with RequiredValuesMissing
@@ -181,12 +180,11 @@ public void issue186() {
181180

182181
ProvisioningResult<UserTO> result = updateUser(userUR);
183182
assertNotNull(result.getPropagationStatuses().getFirst().getFailureReason());
184-
userTO = result.getEntity();
185183

186184
// 4. update assigning a resource NOT forcing mandatory constraints
187185
// BUT not priority: must succeed
188186
userUR = new UserUR();
189-
userUR.setKey(userTO.getKey());
187+
userUR.setKey(result.getEntity().getKey());
190188
userUR.setPassword(new PasswordPatch.Builder().value("newPassword123456").build());
191189
userUR.getResources().add(new StringPatchItem.Builder().
192190
operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_CSV).build());
@@ -200,7 +198,6 @@ public void issue213() {
200198
userCR.getResources().add(RESOURCE_NAME_TESTDB);
201199

202200
UserTO userTO = createUser(userCR).getEntity();
203-
assertNotNull(userTO);
204201
assertEquals(1, userTO.getResources().size());
205202

206203
JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
@@ -231,15 +228,12 @@ public void issue234() {
231228
inUserTO.getResources().add(RESOURCE_NAME_LDAP);
232229

233230
UserTO userTO = createUser(inUserTO).getEntity();
234-
assertNotNull(userTO);
235231

236232
UserUR userUR = new UserUR();
237-
238233
userUR.setKey(userTO.getKey());
239234
userUR.setUsername(new StringReplacePatchItem.Builder().value('1' + userTO.getUsername()).build());
240235

241236
userTO = updateUser(userUR).getEntity();
242-
assertNotNull(userTO);
243237
assertEquals('1' + inUserTO.getUsername(), userTO.getUsername());
244238
}
245239

@@ -250,7 +244,6 @@ public void issue280() {
250244
userCR.getMemberships().clear();
251245

252246
UserTO userTO = createUser(userCR).getEntity();
253-
assertNotNull(userTO);
254247

255248
UserUR userUR = new UserUR();
256249
userUR.setKey(userTO.getKey());
@@ -317,7 +310,6 @@ public void issueSYNCOPE108() {
317310
userCR.getResources().add(RESOURCE_NAME_CSV);
318311

319312
UserTO userTO = createUser(userCR).getEntity();
320-
assertNotNull(userTO);
321313
assertEquals(2, userTO.getMemberships().size());
322314
assertEquals(1, userTO.getResources().size());
323315

@@ -334,7 +326,6 @@ public void issueSYNCOPE108() {
334326
build();
335327

336328
userTO = updateUser(userUR).getEntity();
337-
assertNotNull(userTO);
338329
assertEquals(1, userTO.getMemberships().size());
339330

340331
connObjectTO = RESOURCE_SERVICE.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
@@ -351,7 +342,6 @@ public void issueSYNCOPE108() {
351342
value(userTO.getResources().iterator().next()).build());
352343

353344
userTO = updateUser(userUR).getEntity();
354-
assertNotNull(userTO);
355345
assertEquals(1, userTO.getMemberships().size());
356346
assertFalse(userTO.getResources().isEmpty());
357347

@@ -368,7 +358,6 @@ public void issueSYNCOPE108() {
368358
build();
369359

370360
userTO = updateUser(userUR).getEntity();
371-
assertNotNull(userTO);
372361
assertTrue(userTO.getMemberships().isEmpty());
373362
assertTrue(userTO.getResources().isEmpty());
374363

@@ -431,7 +420,6 @@ public void issueSYNCOPE266() {
431420
userCR.getResources().clear();
432421

433422
UserTO userTO = createUser(userCR).getEntity();
434-
assertNotNull(userTO);
435423

436424
UserUR userUR = new UserUR();
437425
userUR.setKey(userTO.getKey());
@@ -440,12 +428,14 @@ public void issueSYNCOPE266() {
440428
userUR.getResources().add(new StringPatchItem.Builder().
441429
operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_UPDATE).build());
442430

443-
userTO = updateUser(userUR).getEntity();
444-
assertNotNull(userTO);
431+
assertDoesNotThrow(() -> updateUser(userUR).getEntity());
445432
}
446433

447434
@Test
448435
public void issueSYNCOPE279() {
436+
// see https://github.com/payara/Payara/issues/7203
437+
assumeFalse(IS_DEPLOYED_IN_PAYARA);
438+
449439
UserCR userCR = UserITCase.getUniqueSample("syncope279@apache.org");
450440
userCR.getResources().clear();
451441
userCR.getResources().add(RESOURCE_NAME_TIMEOUT);
@@ -465,7 +455,6 @@ public void issueSYNCOPE122() {
465455
userCR.getResources().add(RESOURCE_NAME_TESTDB2);
466456

467457
UserTO userTO = createUser(userCR).getEntity();
468-
assertNotNull(userTO);
469458
assertTrue(userTO.getResources().contains(RESOURCE_NAME_TESTDB));
470459
assertTrue(userTO.getResources().contains(RESOURCE_NAME_TESTDB2));
471460

@@ -537,7 +526,6 @@ public void issueSYNCOPE136AES() {
537526
userCR.getResources().clear();
538527

539528
userTO = createUser(userCR).getEntity();
540-
assertNotNull(userTO);
541529

542530
// 4. update user, assign a propagation priority resource but don't provide any password
543531
UserUR userUR = new UserUR();
@@ -547,9 +535,6 @@ public void issueSYNCOPE136AES() {
547535
userUR.setPassword(new PasswordPatch.Builder().onSyncope(false).resource(RESOURCE_NAME_LDAP).build());
548536

549537
ProvisioningResult<UserTO> result = updateUser(userUR);
550-
assertNotNull(result);
551-
userTO = result.getEntity();
552-
assertNotNull(userTO);
553538

554539
// 5. verify that propagation was successful
555540
List<PropagationStatus> props = result.getPropagationStatuses();
@@ -575,7 +560,6 @@ public void issueSYNCOPE136Random() {
575560
UserCR userCR = UserITCase.getUniqueSample("syncope136_Random@apache.org");
576561
userCR.getResources().clear();
577562
UserTO userTO = createUser(userCR).getEntity();
578-
assertNotNull(userTO);
579563

580564
// 2. update user, assign a propagation priority resource but don't provide any password
581565
UserUR userUR = new UserUR();
@@ -728,7 +712,6 @@ public void issueSYNCOPE383() {
728712
UserCR userCR = UserITCase.getUniqueSample("syncope383@apache.org");
729713
userCR.getResources().clear();
730714
UserTO userTO = createUser(userCR).getEntity();
731-
assertNotNull(userTO);
732715

733716
// 2. assign resource without specifying a new pwd and check propagation failure
734717
UserUR userUR = new UserUR();
@@ -770,7 +753,6 @@ public void issueSYNCOPE402() {
770753
userCR.getPlainAttrs().add(attr("surname", userId));
771754

772755
UserTO userTO = createUser(userCR).getEntity();
773-
assertNotNull(userTO);
774756
assertTrue(userTO.getResources().isEmpty());
775757

776758
// 2. update assigning a resource NOT forcing mandatory constraints
@@ -836,14 +818,11 @@ public void issueSYNCOPE420() throws IOException {
836818
public void issueSYNCOPE426() {
837819
UserCR userCR = UserITCase.getUniqueSample("syncope426@syncope.apache.org");
838820
UserTO userTO = createUser(userCR).getEntity();
839-
assertNotNull(userTO);
840821

841822
UserUR userUR = new UserUR();
842823
userUR.setKey(userTO.getKey());
843824
userUR.setPassword(new PasswordPatch.Builder().value("anotherPassword123").build());
844-
userTO = USER_SERVICE.update(userUR).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
845-
}).getEntity();
846-
assertNotNull(userTO);
825+
assertDoesNotThrow(() -> updateUser(userUR));
847826
}
848827

849828
@Test
@@ -853,7 +832,6 @@ public void issueSYNCOPE435() {
853832
userCR.setPassword(null);
854833
userCR.setStorePassword(false);
855834
UserTO userTO = createUser(userCR).getEntity();
856-
assertNotNull(userTO);
857835

858836
// 2. try to update user by subscribing a resource - works but propagation is not even attempted
859837
UserUR userUR = new UserUR();
@@ -876,7 +854,6 @@ public void issueSYNCOPE454() {
876854
UserCR userCR = UserITCase.getUniqueSample("syncope454@syncope.apache.org");
877855
userCR.getResources().add(RESOURCE_NAME_LDAP);
878856
UserTO userTO = createUser(userCR).getEntity();
879-
assertNotNull(userTO);
880857

881858
// 2. read resource configuration for LDAP binding
882859
ConnObject connObject =
@@ -948,7 +925,6 @@ public void issueSYNCOPE493() {
948925
userUR.getPlainAttrs().add(attrAddReplacePatch("firstname", "firstnameNew"));
949926

950927
result = updateUser(userUR);
951-
assertNotNull(userTO);
952928
assertEquals(1, result.getPropagationStatuses().size());
953929
assertEquals(ExecStatus.SUCCESS, result.getPropagationStatuses().getFirst().getStatus());
954930
userTO = result.getEntity();
@@ -1078,7 +1054,6 @@ public void issueSYNCOPE391() {
10781054
userCR.setStorePassword(false);
10791055

10801056
UserTO userTO = createUser(userCR).getEntity();
1081-
assertNotNull(userTO);
10821057
assertNull(userTO.getPassword());
10831058

10841059
// 2. create existing user on csv and check that password on Syncope is null and that password on resource
@@ -1097,16 +1072,15 @@ public void issueSYNCOPE391() {
10971072
userCR.getResources().add(RESOURCE_NAME_CSV);
10981073

10991074
userTO = createUser(userCR).getEntity();
1100-
assertNotNull(userTO);
11011075

1102-
ConnObject connObjectTO =
1076+
ConnObject connObject =
11031077
RESOURCE_SERVICE.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
1104-
assertNotNull(connObjectTO);
1078+
assertNotNull(connObject);
11051079

11061080
// check if password has not changed
11071081
assertEquals(
11081082
"password0",
1109-
connObjectTO.getAttr(OperationalAttributes.PASSWORD_NAME).orElseThrow().getValues().getFirst());
1083+
connObject.getAttr(OperationalAttributes.PASSWORD_NAME).orElseThrow().getValues().getFirst());
11101084
assertNull(userTO.getPassword());
11111085

11121086
// 3. create user with not null password and propagate onto resource-csv, specify not to save password on
@@ -1118,16 +1092,15 @@ public void issueSYNCOPE391() {
11181092
userCR.getResources().add(RESOURCE_NAME_CSV);
11191093

11201094
userTO = createUser(userCR).getEntity();
1121-
assertNotNull(userTO);
11221095

1123-
connObjectTO =
1096+
connObject =
11241097
RESOURCE_SERVICE.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
1125-
assertNotNull(connObjectTO);
1098+
assertNotNull(connObject);
11261099

11271100
// check if password has been propagated and that saved userTO's password is null
11281101
assertEquals(
11291102
"passwordTESTNULL1",
1130-
connObjectTO.getAttr(OperationalAttributes.PASSWORD_NAME).orElseThrow().getValues().getFirst());
1103+
connObject.getAttr(OperationalAttributes.PASSWORD_NAME).orElseThrow().getValues().getFirst());
11311104
assertNull(userTO.getPassword());
11321105

11331106
// 4. create user and propagate password on resource-csv and on Syncope local storage
@@ -1138,15 +1111,14 @@ public void issueSYNCOPE391() {
11381111

11391112
// storePassword true by default
11401113
userTO = createUser(userCR).getEntity();
1141-
assertNotNull(userTO);
11421114

1143-
connObjectTO = RESOURCE_SERVICE.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
1144-
assertNotNull(connObjectTO);
1115+
connObject = RESOURCE_SERVICE.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
1116+
assertNotNull(connObject);
11451117

11461118
// check if password has been correctly propagated on Syncope and resource-csv as usual
11471119
assertEquals(
11481120
"passwordTESTNULL1",
1149-
connObjectTO.getAttr(OperationalAttributes.PASSWORD_NAME).orElseThrow().getValues().getFirst());
1121+
connObject.getAttr(OperationalAttributes.PASSWORD_NAME).orElseThrow().getValues().getFirst());
11501122
SyncopeClient.Self self = CLIENT_FACTORY.create(userTO.getUsername(), "passwordTESTNULL1").self();
11511123
assertNotNull(self);
11521124

@@ -1279,7 +1251,6 @@ public void issueSYNCOPE686() {
12791251
userCR.getResources().clear();
12801252

12811253
UserTO userTO = createUser(userCR).getEntity();
1282-
assertNotNull(userTO);
12831254

12841255
// 5. update user with the new group, and don't provide any password
12851256
UserUR userUR = new UserUR();
@@ -1405,7 +1376,6 @@ public void issueSYNCOPE1166() {
14051376

14061377
UserCR userCR = UserITCase.getUniqueSample("syncope1166@apache.org");
14071378
UserTO userTO = createUser(userCR).getEntity();
1408-
assertNotNull(userTO);
14091379

14101380
UserUR userUR = new UserUR();
14111381
userUR.setKey(userTO.getKey());
@@ -1484,7 +1454,6 @@ public void issueSYNCOPE1337() {
14841454
userCR.setPassword("Password123");
14851455
userCR.setRealm("/even/two");
14861456
UserTO userTO = createUser(userCR).getEntity();
1487-
assertNotNull(userTO);
14881457

14891458
// 3. attempt to set the same password value: fails
14901459
UserUR req = new UserUR();
@@ -1500,13 +1469,11 @@ public void issueSYNCOPE1337() {
15001469

15011470
// 4. set another password value: works
15021471
req.setPassword(new PasswordPatch.Builder().onSyncope(true).value("Password124").build());
1503-
userTO = updateUser(req).getEntity();
1504-
assertNotNull(userTO);
1472+
assertDoesNotThrow(() -> updateUser(req).getEntity());
15051473

15061474
// 5. set the original password value: works (history length is 1)
15071475
req.setPassword(new PasswordPatch.Builder().onSyncope(true).value("Password123").build());
1508-
userTO = updateUser(req).getEntity();
1509-
assertNotNull(userTO);
1476+
assertDoesNotThrow(() -> updateUser(req).getEntity());
15101477
} finally {
15111478
// finally revert the cipher algorithm
15121479
confParamOps.set(SyncopeConstants.MASTER_DOMAIN, "password.cipher.algorithm", original);
@@ -1583,8 +1550,7 @@ public void issueSYNCOPE1699() throws Exception {
15831550
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
15841551

15851552
// reading user by its username still works
1586-
userTO = USER_SERVICE.read(req.getUsername().getValue());
1587-
assertNotNull(userTO);
1553+
assertDoesNotThrow(() -> USER_SERVICE.read(req.getUsername().getValue()));
15881554
}
15891555

15901556
@Test

src/main/asciidoc/reference-guide/concepts/routes.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ The received response, after being post-processed by matching route's _filters_,
5050
==== Predicates
5151

5252
Inside Route definition, each predicate will be referring to some Spring Cloud Gateway's
53-
https://docs.spring.io/spring-cloud-gateway/reference/4.3/spring-cloud-gateway-server-webflux/request-predicates-factories.html[Predicate factory^]:
53+
https://docs.spring.io/spring-cloud-gateway/reference/5.0/spring-cloud-gateway-server-webflux/request-predicates-factories.html[Predicate factory^]:
5454

5555
* `AFTER` matches requests that happen after the specified datetime;
5656
* `BEFORE` matches requests that happen before the specified datetime;
@@ -74,7 +74,7 @@ endif::[]
7474
==== Filters
7575

7676
Inside Route definition, each filter will be referring to some Spring Cloud Gateway's
77-
https://docs.spring.io/spring-cloud-gateway/reference/4.3/spring-cloud-gateway-server-webflux/gatewayfilter-factories.html[Filter factory^]:
77+
https://docs.spring.io/spring-cloud-gateway/reference/5.0/spring-cloud-gateway-server-webflux/gatewayfilter-factories.html[Filter factory^]:
7878

7979
* `ADD_REQUEST_HEADER` adds a header to the downstream request's headers;
8080
* `ADD_REQUEST_PARAMETER` adds a parameter too the downstream request's query string;

0 commit comments

Comments
 (0)