ilgrosso commented on code in PR #1623:
URL: https://github.com/apache/syncope/pull/1623#discussion_r4627856689
##########
fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserIssuesITCase.java:
##########
@@ -1637,6 +1639,81 @@ public void issueSYNCOPE1809() throws IOException {
}
}
+ @Test
+ public void issueSYNCOPE2006() {
+ // 1. add a new schema externalKey and update provision accordingly
+ PlainSchemaTO externalKeySchemaTO = new PlainSchemaTO();
+ externalKeySchemaTO.setKey("externalKey");
+ externalKeySchemaTO.setType(AttrSchemaType.String);
+ externalKeySchemaTO.setReadonly(true);
+ SCHEMA_SERVICE.create(SchemaType.PLAIN, externalKeySchemaTO);
+ try {
+ AnyTypeClassTO minimalUser = ANY_TYPE_CLASS_SERVICE.read("minimal
user");
+ minimalUser.getPlainSchemas().add(externalKeySchemaTO.getKey());
+ ANY_TYPE_CLASS_SERVICE.update(minimalUser);
+ ResourceTO restResourceTO =
RESOURCE_SERVICE.read(RESOURCE_NAME_REST);
+ restResourceTO.setPropagationPriority(null);
+ restResourceTO.getProvision(AnyTypeKind.USER.name())
+ .ifPresent(p ->
p.setUidOnCreate(externalKeySchemaTO.getKey()));
+ RESOURCE_SERVICE.update(restResourceTO);
+ UserCR userCR =
UserITCase.getUniqueSample("[email protected]");
+ userCR.getResources().clear();
+ userCR.getResources().add(RESOURCE_NAME_REST);
+
+ // 2. create
+ ProvisioningResult<UserTO> result = createUser(userCR);
+ assertEquals(1, result.getPropagationStatuses().size());
+ assertEquals(ExecStatus.SUCCESS,
result.getPropagationStatuses().getFirst().getStatus());
+ assertEquals(RESOURCE_NAME_REST,
result.getPropagationStatuses().getFirst().getResource());
+ assertEquals("surname",
result.getEntity().getPlainAttr("surname").orElseThrow().getValues().getFirst());
+ // externalKey is going to be populated on create
+
assertTrue(result.getEntity().getPlainAttr("externalKey").isPresent());
+ String entityKey = result.getEntity().getKey();
+ assertEquals(entityKey,
+
result.getEntity().getPlainAttr("externalKey").orElseThrow().getValues().getFirst());
+ // 3. delete user from the resource with null-priority-async
header set to true
+ // externalKey is going to be removed with the user itself
+ result = SyncopeClient.nullPriorityAsync(
+ CLIENT_FACTORY.create(ADMIN_UNAME,
ADMIN_PWD).getService(UserService.class), true)
+ .delete(entityKey)
+ .readEntity(new GenericType<>() {
+ });
+
+ // user has been remotely deleted
+ try {
+ RESOURCE_SERVICE.readConnObject(RESOURCE_NAME_REST,
AnyTypeKind.USER.name(), entityKey);
+ Assertions.fail("Should not arrive here");
Review Comment:
Remove `Assertions.` as the rest of the codebase does
##########
fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserIssuesITCase.java:
##########
@@ -1637,6 +1639,81 @@ public void issueSYNCOPE1809() throws IOException {
}
}
+ @Test
+ public void issueSYNCOPE2006() {
+ // 1. add a new schema externalKey and update provision accordingly
+ PlainSchemaTO externalKeySchemaTO = new PlainSchemaTO();
+ externalKeySchemaTO.setKey("externalKey");
+ externalKeySchemaTO.setType(AttrSchemaType.String);
+ externalKeySchemaTO.setReadonly(true);
+ SCHEMA_SERVICE.create(SchemaType.PLAIN, externalKeySchemaTO);
+ try {
+ AnyTypeClassTO minimalUser = ANY_TYPE_CLASS_SERVICE.read("minimal
user");
+ minimalUser.getPlainSchemas().add(externalKeySchemaTO.getKey());
+ ANY_TYPE_CLASS_SERVICE.update(minimalUser);
+ ResourceTO restResourceTO =
RESOURCE_SERVICE.read(RESOURCE_NAME_REST);
+ restResourceTO.setPropagationPriority(null);
+ restResourceTO.getProvision(AnyTypeKind.USER.name())
+ .ifPresent(p ->
p.setUidOnCreate(externalKeySchemaTO.getKey()));
+ RESOURCE_SERVICE.update(restResourceTO);
+ UserCR userCR =
UserITCase.getUniqueSample("[email protected]");
+ userCR.getResources().clear();
+ userCR.getResources().add(RESOURCE_NAME_REST);
+
+ // 2. create
+ ProvisioningResult<UserTO> result = createUser(userCR);
+ assertEquals(1, result.getPropagationStatuses().size());
+ assertEquals(ExecStatus.SUCCESS,
result.getPropagationStatuses().getFirst().getStatus());
+ assertEquals(RESOURCE_NAME_REST,
result.getPropagationStatuses().getFirst().getResource());
+ assertEquals("surname",
result.getEntity().getPlainAttr("surname").orElseThrow().getValues().getFirst());
+ // externalKey is going to be populated on create
+
assertTrue(result.getEntity().getPlainAttr("externalKey").isPresent());
+ String entityKey = result.getEntity().getKey();
+ assertEquals(entityKey,
+
result.getEntity().getPlainAttr("externalKey").orElseThrow().getValues().getFirst());
+ // 3. delete user from the resource with null-priority-async
header set to true
+ // externalKey is going to be removed with the user itself
+ result = SyncopeClient.nullPriorityAsync(
+ CLIENT_FACTORY.create(ADMIN_UNAME,
ADMIN_PWD).getService(UserService.class), true)
+ .delete(entityKey)
+ .readEntity(new GenericType<>() {
+ });
+
+ // user has been remotely deleted
+ try {
+ RESOURCE_SERVICE.readConnObject(RESOURCE_NAME_REST,
AnyTypeKind.USER.name(), entityKey);
+ Assertions.fail("Should not arrive here");
+ } catch (SyncopeClientException sce) {
+ assertEquals(ClientExceptionType.NotFound, sce.getType());
Review Comment:
Use `assertThrows()` not the old-fashioned `try / fail / catch`
##########
fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserIssuesITCase.java:
##########
@@ -1637,6 +1639,81 @@ public void issueSYNCOPE1809() throws IOException {
}
}
+ @Test
+ public void issueSYNCOPE2006() {
+ // 1. add a new schema externalKey and update provision accordingly
+ PlainSchemaTO externalKeySchemaTO = new PlainSchemaTO();
+ externalKeySchemaTO.setKey("externalKey");
+ externalKeySchemaTO.setType(AttrSchemaType.String);
+ externalKeySchemaTO.setReadonly(true);
+ SCHEMA_SERVICE.create(SchemaType.PLAIN, externalKeySchemaTO);
+ try {
+ AnyTypeClassTO minimalUser = ANY_TYPE_CLASS_SERVICE.read("minimal
user");
+ minimalUser.getPlainSchemas().add(externalKeySchemaTO.getKey());
+ ANY_TYPE_CLASS_SERVICE.update(minimalUser);
+ ResourceTO restResourceTO =
RESOURCE_SERVICE.read(RESOURCE_NAME_REST);
+ restResourceTO.setPropagationPriority(null);
+ restResourceTO.getProvision(AnyTypeKind.USER.name())
Review Comment:
it's test code, replace `ifPreset()` with `orElseThrow()` and save 1 level
of complexity
##########
fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserIssuesITCase.java:
##########
@@ -1637,6 +1639,81 @@ public void issueSYNCOPE1809() throws IOException {
}
}
+ @Test
+ public void issueSYNCOPE2006() {
+ // 1. add a new schema externalKey and update provision accordingly
+ PlainSchemaTO externalKeySchemaTO = new PlainSchemaTO();
+ externalKeySchemaTO.setKey("externalKey");
+ externalKeySchemaTO.setType(AttrSchemaType.String);
+ externalKeySchemaTO.setReadonly(true);
+ SCHEMA_SERVICE.create(SchemaType.PLAIN, externalKeySchemaTO);
+ try {
+ AnyTypeClassTO minimalUser = ANY_TYPE_CLASS_SERVICE.read("minimal
user");
+ minimalUser.getPlainSchemas().add(externalKeySchemaTO.getKey());
+ ANY_TYPE_CLASS_SERVICE.update(minimalUser);
+ ResourceTO restResourceTO =
RESOURCE_SERVICE.read(RESOURCE_NAME_REST);
+ restResourceTO.setPropagationPriority(null);
+ restResourceTO.getProvision(AnyTypeKind.USER.name())
+ .ifPresent(p ->
p.setUidOnCreate(externalKeySchemaTO.getKey()));
+ RESOURCE_SERVICE.update(restResourceTO);
+ UserCR userCR =
UserITCase.getUniqueSample("[email protected]");
+ userCR.getResources().clear();
+ userCR.getResources().add(RESOURCE_NAME_REST);
+
+ // 2. create
+ ProvisioningResult<UserTO> result = createUser(userCR);
+ assertEquals(1, result.getPropagationStatuses().size());
+ assertEquals(ExecStatus.SUCCESS,
result.getPropagationStatuses().getFirst().getStatus());
+ assertEquals(RESOURCE_NAME_REST,
result.getPropagationStatuses().getFirst().getResource());
+ assertEquals("surname",
result.getEntity().getPlainAttr("surname").orElseThrow().getValues().getFirst());
+ // externalKey is going to be populated on create
+
assertTrue(result.getEntity().getPlainAttr("externalKey").isPresent());
+ String entityKey = result.getEntity().getKey();
+ assertEquals(entityKey,
+
result.getEntity().getPlainAttr("externalKey").orElseThrow().getValues().getFirst());
+ // 3. delete user from the resource with null-priority-async
header set to true
+ // externalKey is going to be removed with the user itself
+ result = SyncopeClient.nullPriorityAsync(
+ CLIENT_FACTORY.create(ADMIN_UNAME,
ADMIN_PWD).getService(UserService.class), true)
+ .delete(entityKey)
+ .readEntity(new GenericType<>() {
+ });
+
+ // user has been remotely deleted
+ try {
+ RESOURCE_SERVICE.readConnObject(RESOURCE_NAME_REST,
AnyTypeKind.USER.name(), entityKey);
+ Assertions.fail("Should not arrive here");
+ } catch (SyncopeClientException sce) {
+ assertEquals(ClientExceptionType.NotFound, sce.getType());
+ }
+
+ // the DELETE propagation task has successfully been executed
+ await().atMost(30, TimeUnit.SECONDS).pollInterval(5,
TimeUnit.SECONDS).until(() -> {
+ List<PropagationTaskTO> deleteTasks = TASK_SERVICE.search(
+ new
TaskQuery.Builder(TaskType.PROPAGATION).resource(RESOURCE_NAME_REST)
+ .anyTypeKind(AnyTypeKind.USER)
+ .entityKey(entityKey)
+ .build())
+ .getResult()
+ .stream()
+ .map(PropagationTaskTO.class::cast)
+ .filter(task -> ResourceOperation.DELETE ==
task.getOperation())
+ .collect(Collectors.toList());
Review Comment:
why not `toList()`?
##########
src/main/resources/org/apache/syncope/checkstyle.xml:
##########
@@ -71,7 +71,16 @@ under the License.
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
- <module name="FileLength"/>
+ <module name="FileLength">
+ <property name="id" value="standardFileLength"/>
+ <property name="max" value="2000"/>
+ </module>
+
+ <!-- Esclude i test IT soltanto dal limite ordinario -->
Review Comment:
Remove this italian comment
##########
fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserIssuesITCase.java:
##########
@@ -1637,6 +1639,81 @@ public void issueSYNCOPE1809() throws IOException {
}
}
+ @Test
+ public void issueSYNCOPE2006() {
+ // 1. add a new schema externalKey and update provision accordingly
+ PlainSchemaTO externalKeySchemaTO = new PlainSchemaTO();
+ externalKeySchemaTO.setKey("externalKey");
+ externalKeySchemaTO.setType(AttrSchemaType.String);
+ externalKeySchemaTO.setReadonly(true);
+ SCHEMA_SERVICE.create(SchemaType.PLAIN, externalKeySchemaTO);
+ try {
+ AnyTypeClassTO minimalUser = ANY_TYPE_CLASS_SERVICE.read("minimal
user");
+ minimalUser.getPlainSchemas().add(externalKeySchemaTO.getKey());
+ ANY_TYPE_CLASS_SERVICE.update(minimalUser);
+ ResourceTO restResourceTO =
RESOURCE_SERVICE.read(RESOURCE_NAME_REST);
+ restResourceTO.setPropagationPriority(null);
+ restResourceTO.getProvision(AnyTypeKind.USER.name())
+ .ifPresent(p ->
p.setUidOnCreate(externalKeySchemaTO.getKey()));
+ RESOURCE_SERVICE.update(restResourceTO);
+ UserCR userCR =
UserITCase.getUniqueSample("[email protected]");
+ userCR.getResources().clear();
+ userCR.getResources().add(RESOURCE_NAME_REST);
+
+ // 2. create
+ ProvisioningResult<UserTO> result = createUser(userCR);
+ assertEquals(1, result.getPropagationStatuses().size());
+ assertEquals(ExecStatus.SUCCESS,
result.getPropagationStatuses().getFirst().getStatus());
+ assertEquals(RESOURCE_NAME_REST,
result.getPropagationStatuses().getFirst().getResource());
+ assertEquals("surname",
result.getEntity().getPlainAttr("surname").orElseThrow().getValues().getFirst());
+ // externalKey is going to be populated on create
+
assertTrue(result.getEntity().getPlainAttr("externalKey").isPresent());
+ String entityKey = result.getEntity().getKey();
+ assertEquals(entityKey,
+
result.getEntity().getPlainAttr("externalKey").orElseThrow().getValues().getFirst());
+ // 3. delete user from the resource with null-priority-async
header set to true
+ // externalKey is going to be removed with the user itself
+ result = SyncopeClient.nullPriorityAsync(
+ CLIENT_FACTORY.create(ADMIN_UNAME,
ADMIN_PWD).getService(UserService.class), true)
+ .delete(entityKey)
+ .readEntity(new GenericType<>() {
+ });
+
+ // user has been remotely deleted
+ try {
+ RESOURCE_SERVICE.readConnObject(RESOURCE_NAME_REST,
AnyTypeKind.USER.name(), entityKey);
+ Assertions.fail("Should not arrive here");
+ } catch (SyncopeClientException sce) {
+ assertEquals(ClientExceptionType.NotFound, sce.getType());
+ }
+
+ // the DELETE propagation task has successfully been executed
+ await().atMost(30, TimeUnit.SECONDS).pollInterval(5,
TimeUnit.SECONDS).until(() -> {
Review Comment:
Use `MAX_WAIT_SECONDS` as the rest of the code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]