Skip to content

Commit

Permalink
Create schema for simplified correlations
Browse files Browse the repository at this point in the history
Here we introduce new correlator named "items" that simply correlates
on given item (or more items). A very, very experimental section
for defining places and abstract items is there to help with
multi-account scenarios.

Simplified versions of respective story tests are there.

(No implementation yet, though.)
  • Loading branch information
mederly committed Feb 27, 2022
1 parent 013fbec commit 14fbd28
Show file tree
Hide file tree
Showing 14 changed files with 925 additions and 29 deletions.
373 changes: 362 additions & 11 deletions infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static boolean canBeStandalone(CorrelatorConfiguration configuration) {
correlatorsBean.getNone().stream(),
correlatorsBean.getFilter().stream(),
correlatorsBean.getExpression().stream(),
correlatorsBean.getItem().stream(),
correlatorsBean.getItems().stream(),
correlatorsBean.getComposite().stream(),
correlatorsBean.getIdMatch().stream())
.flatMap(s -> s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
/**
* Here we test the correlation that uses the internal correlator.
*
* Contrary to {@link TestCorrelationSimple} here we allow a user to have multiple accounts on the source resource (`SIS`).
* Contrary to {@link AbstractSimpleCorrelationTest} here we allow a user to have multiple accounts on the source resource (`SIS`).
* They are mapped into assignments; personal data are kept in those assignments. There is an algorithm to find
* the "authoritative" assignment that provides the authoritative personal data for the user.
*
* The correlation is, however, done against all the assignments; not only to the selected authoritative data.
*/
public class TestCorrelationMultiAccounts extends AbstractCorrelationTest {
public abstract class AbstractMultiAccountsCorrelationTest extends AbstractCorrelationTest {

public static final File TEST_DIR = new File(AbstractCorrelationTest.TEST_DIR, "multi-accounts");

Expand Down Expand Up @@ -67,7 +67,11 @@ public class TestCorrelationMultiAccounts extends AbstractCorrelationTest {
private static final TestResource<OrgType> ORG_PROGRAM_SW_ENG_DOCTORAL =
new TestResource<>(TEST_DIR, "040-org-program-sw-eng-doctoral.xml", "474c95ce-59f0-4104-8a64-f3d0406234f0");

private static final CsvResource RESOURCE_SIS = new CsvResource(TEST_DIR, "resource-sis.xml",
static final CsvResource RESOURCE_SIS = new CsvResource(TEST_DIR, "resource-sis.xml",
"afb142f9-2218-491a-8b99-ce5713ca424d", "resource-sis.csv",
"sisId,firstName,lastName,born,nationalId,studyProgram");

static final CsvResource RESOURCE_SIS_SIMPLIFIED = new CsvResource(TEST_DIR, "resource-sis-simplified.xml",
"afb142f9-2218-491a-8b99-ce5713ca424d", "resource-sis.csv",
"sisId,firstName,lastName,born,nationalId,studyProgram");

Expand All @@ -76,6 +80,8 @@ public class TestCorrelationMultiAccounts extends AbstractCorrelationTest {

private UserType john;

abstract CsvResource getSisResource();

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
Expand All @@ -92,7 +98,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
addObject(ORG_PROGRAM_SW_ENG, initTask, initResult);
addObject(ORG_PROGRAM_SW_ENG_DOCTORAL, initTask, initResult);

RESOURCE_SIS.initializeAndTest(this, initTask, initResult);
getSisResource().initializeAndTest(this, initTask, initResult);

TASK_IMPORT_SIS.initialize(this, initTask, initResult); // importing in closed state
}
Expand All @@ -112,8 +118,8 @@ public void test100ImportNoAmbiguities() throws CommonException, IOException {
given();
OperationResult result = getTestOperationResult();

RESOURCE_SIS.appendLine("1,Mary,Smith,2006-04-10,060410/1993,bioch");
RESOURCE_SIS.appendLine("2,John,Smith,2004-02-06,040206/1328,sw-eng");
getSisResource().appendLine("1,Mary,Smith,2006-04-10,060410/1993,bioch");
getSisResource().appendLine("2,John,Smith,2004-02-06,040206/1328,sw-eng");

when();
TASK_IMPORT_SIS.rerun(result);
Expand Down Expand Up @@ -176,7 +182,7 @@ public void test110ImportJohnSlightlyModified() throws CommonException, IOExcept

// A slight change in the given name. ID Match should automatically assign the same ID.
// National ID should be normalized before contacting ID Match.
RESOURCE_SIS.appendLine("3,Ian,Smith,2004-02-06,040206-1328,math");
getSisResource().appendLine("3,Ian,Smith,2004-02-06,040206-1328,math");

when();
TASK_IMPORT_SIS.rerun(result);
Expand Down Expand Up @@ -234,7 +240,7 @@ public void test120ImportJohnSingleAmbiguity() throws CommonException, IOExcepti
// National ID without the last four digits. The algorithm should stop and ask the operator.
// Here we intentionally use given name of Ian, that is NOT authoritative (i.e. it's present only
// in an assignment).
RESOURCE_SIS.appendLine("4,Ian,Smith,2004-02-06,040206,e-eng");
getSisResource().appendLine("4,Ian,Smith,2004-02-06,040206,e-eng");

dummyAuditService.clear();
dummyTransport.clearMessages();
Expand Down Expand Up @@ -411,7 +417,7 @@ public void test150ImportJohnTwoOptions() throws CommonException, IOException {
OperationResult result = getTestOperationResult();

given("different national ID, same name and date of birth. (To be consulted with operator.)");
RESOURCE_SIS.appendLine("6,John,Smith,2004-02-06,040206/8824,sw-eng-doctoral");
getSisResource().appendLine("6,John,Smith,2004-02-06,040206/8824,sw-eng-doctoral");

when("the task is executed");
TASK_IMPORT_SIS.rerun(result);
Expand Down Expand Up @@ -521,7 +527,7 @@ public void test170ImportMatchingNationalIdOnly() throws CommonException, IOExce
OperationResult result = task.getResult();

given("same national ID, different name");
RESOURCE_SIS.appendLine("7,Jim,Sanchez,2004-02-06,040206/8824,math");
getSisResource().appendLine("7,Jim,Sanchez,2004-02-06,040206/8824,math");

when("the task is executed");
TASK_IMPORT_SIS.rerun(result);
Expand Down Expand Up @@ -578,6 +584,6 @@ public void test170ImportMatchingNationalIdOnly() throws CommonException, IOExce
}

private PrismObject<ShadowType> getShadow(String name, OperationResult result) throws SchemaException {
return findShadowByPrismName(name, RESOURCE_SIS.getObject(), result);
return findShadowByPrismName(name, getSisResource().getObject(), result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* - E-mail addresses are kept in HR for the simplicity. We assume that _some_ of the accounts
* on target may have e-mail addresses or employee numbers present.
*/
public class TestCorrelationSimple extends AbstractCorrelationTest {
public abstract class AbstractSimpleCorrelationTest extends AbstractCorrelationTest {

public static final File TEST_DIR = new File(AbstractCorrelationTest.TEST_DIR, "simple");

Expand All @@ -56,7 +56,10 @@ public class TestCorrelationSimple extends AbstractCorrelationTest {
private static final CsvResource RESOURCE_HR = new CsvResource(TEST_DIR, "resource-hr.xml",
"e09ffb8a-3f16-4b72-a61c-068f0039b876", "resource-hr.csv");

private static final CsvResource RESOURCE_TARGET = new CsvResource(TEST_DIR, "resource-target.xml",
static final CsvResource RESOURCE_TARGET = new CsvResource(TEST_DIR, "resource-target.xml",
"917e846f-39a5-423e-a63a-b00c3595da37", "resource-target.csv");

static final CsvResource RESOURCE_TARGET_SIMPLIFIED = new CsvResource(TEST_DIR, "resource-target-simplified.xml",
"917e846f-39a5-423e-a63a-b00c3595da37", "resource-target.csv");

private static final TestTask TASK_IMPORT_HR = new TestTask(TEST_DIR, "task-import-hr.xml",
Expand All @@ -68,14 +71,16 @@ public class TestCorrelationSimple extends AbstractCorrelationTest {
private static final int HR_ACCOUNTS = 5;
private static final int TARGET_ACCOUNTS = 6;

abstract CsvResource getTargetResource();

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);

addObject(OBJECT_TEMPLATE_USER, initTask, initResult);

RESOURCE_HR.initializeAndTest(this, initTask, initResult);
RESOURCE_TARGET.initializeAndTest(this, initTask, initResult);
getTargetResource().initializeAndTest(this, initTask, initResult);

TASK_IMPORT_HR.initialize(this, initTask, initResult);
TASK_IMPORT_TARGET.initialize(this, initTask, initResult);
Expand Down Expand Up @@ -229,7 +234,7 @@ public void test210ResolveAliceAndBob() throws CommonException {

private @NotNull PrismObject<ShadowType> getTargetShadow(String name, OperationResult result) throws SchemaException {
return Objects.requireNonNull(
findShadowByPrismName(name, RESOURCE_TARGET.getObject(), result),
findShadowByPrismName(name, getTargetResource().getObject(), result),
() -> "no target shadow of '" + name + "' was found");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
public class TestIdMatchReal extends AbstractIdMatchTest {

// No ID Match Service override, so the URL configured in the resource will be used.
// No ID Match Service override here, so the URL configured in the resource will be used.

/**
* Attempt to correlate using wrong credentials.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.testing.story.correlation;

import com.evolveum.midpoint.test.CsvResource;

public class TestMultiAccountsCorrelation extends AbstractMultiAccountsCorrelationTest {

@Override
CsvResource getSisResource() {
return RESOURCE_SIS;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.testing.story.correlation;

import com.evolveum.midpoint.test.CsvResource;

public class TestMultiAccountsCorrelationSimplified extends AbstractMultiAccountsCorrelationTest {

@Override
CsvResource getSisResource() {
return RESOURCE_SIS_SIMPLIFIED;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.testing.story.correlation;

import com.evolveum.midpoint.test.CsvResource;

public class TestSimpleCorrelation extends AbstractSimpleCorrelationTest {

@Override
CsvResource getTargetResource() {
return RESOURCE_TARGET;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.testing.story.correlation;

import com.evolveum.midpoint.test.CsvResource;

public class TestSimpleCorrelationSimplified extends AbstractSimpleCorrelationTest {

@Override
CsvResource getTargetResource() {
return RESOURCE_TARGET_SIMPLIFIED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
setExtensionValue(assignment, 'familyName', familyName)
setExtensionValue(assignment, 'dateOfBirth', dateOfBirth)
setExtensionValue(assignment, 'nationalId', normalizeNationalId(nationalId))
setExtensionValue(assignment, 'correlation', true)

if (targetName != null) {
target = midpoint.getOrgByName(targetName)
Expand Down

0 comments on commit 14fbd28

Please sign in to comment.