Skip to content

Commit

Permalink
Fixed intolerance for legacy consistency items (MID-5076)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jan 25, 2019
1 parent c51cce9 commit 928af02
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 10 deletions.
Expand Up @@ -307,14 +307,6 @@ public PrismObject<ShadowType> getShadow(String oid, PrismObject<ShadowType> rep

resourceManager.modifyResourceAvailabilityStatus(resource.asPrismObject(),
AvailabilityStatusType.UP, parentResult);
// try to apply changes to the account only if the resource if UP
if (isCompensate(rootOptions) && repositoryShadow.asObjectable().getObjectChange() != null
&& repositoryShadow.asObjectable().getFailedOperationType() != null
&& resource.getOperationalState() != null && resource.getOperationalState()
.getLastAvailabilityStatus() == AvailabilityStatusType.UP) {
throw new GenericConnectorException(
"Found changes that have been not applied to the resource object yet. Trying to apply them now.");
}

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Shadow from repository:\n{}", repositoryShadow.debugDump(1));
Expand Down
Expand Up @@ -114,7 +114,7 @@ public abstract class AbstractDummyTest extends AbstractProvisioningIntegrationT
protected static final File ACCOUNT_LECHUCK_FILE = new File(TEST_DIR, "account-lechuck.xml");
protected static final String ACCOUNT_LECHUCK_OID = "c0c010c0-d34d-b44f-f11d-444400009aa9";
protected static final String ACCOUNT_LECHUCK_NAME = "lechuck";

protected static final File GROUP_PIRATES_FILE = new File(TEST_DIR, "group-pirates.xml");
protected static final String GROUP_PIRATES_OID = "c0c010c0-d34d-b44f-f11d-3332eeee0000";
protected static final String GROUP_PIRATES_NAME = "pirates";
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -97,6 +97,11 @@ public class TestDummyConsistency extends AbstractDummyTest {
private static final String ACCOUNT_BETTY_FULLNAME = "Betty Rubble";
private static final String ACCOUNT_ELIZABETH2_FULLNAME = "Her Majesty Queen Elizabeth II";

protected static final File ACCOUNT_SHADOW_MURRAY_LEGACY_FILE = new File(TEST_DIR, "account-shadow-murray-legacy.xml");
protected static final String ACCOUNT_SHADOW_MURRAY_LEGACY_OID = "34132742-2085-11e9-a956-17770b09881b";
private static final String ACCOUNT_MURRAY_USERNAME = "murray";
private static final String ACCOUNT_MURRAY_FULL_NAME = "Murray";

private XMLGregorianCalendar lastRequestStartTs;
private XMLGregorianCalendar lastRequestEndTs;
private XMLGregorianCalendar lastAttemptStartTs;
Expand Down Expand Up @@ -2125,6 +2130,38 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception

// TODO: test no discovery options

/**
* Legacy consistency items.
* MID-5076
*/
@Test
public void test900GetAccountMurrayLegacy() throws Exception {
final String TEST_NAME = "test900GetAccountMurrayLegacy";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
dummyResource.resetBreakMode();

dummyResourceCtl.addAccount(ACCOUNT_MURRAY_USERNAME, ACCOUNT_MURRAY_FULL_NAME);
repoAddObjectFromFile(ACCOUNT_SHADOW_MURRAY_LEGACY_FILE, result);

// WHEN
displayWhen(TEST_NAME);
PrismObject<ShadowType> accountMurray = provisioningService.getObject(ShadowType.class, ACCOUNT_SHADOW_MURRAY_LEGACY_OID, null, task, result);

// THEN
displayThen(TEST_NAME);
display("Result", result);
assertSuccess(result);
accountMurray.checkConsistence();

// TODO: assert Murray

assertSteadyResources();
}

private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception {

assertRepoShadow(shadowMorganOid)
Expand Down
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!-- MID-5076 -->
<account oid="34132742-2085-11e9-a956-17770b09881b"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance/ef2bc95b-76e0-59e2-86d6-9999dddddddd">
<name>murray</name>
<resourceRef oid="ef2bc95b-76e0-59e2-86d6-9999dddddddd" />
<objectClass>ri:AccountObjectClass</objectClass>
<kind>account</kind>

<!-- Legacy consistency items -->
<objectChange>
<t:changeType>modify</t:changeType>
<t:objectType>c:ShadowType</t:objectType>
<t:oid>34132742-2085-11e9-a956-17770b09881b</t:oid>
<t:itemDelta>
<t:modificationType>add</t:modificationType>
<t:path>c:attributes/ri:fullname</t:path>
<t:value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">Evil Devil Murray</t:value>
</t:itemDelta>
</objectChange>
<attemptNumber>0</attemptNumber>
<failedOperationType>modify</failedOperationType>

<attributes>
<icfs:name>murray</icfs:name>
<icfs:uid>murray</icfs:uid>
</attributes>
</account>

0 comments on commit 928af02

Please sign in to comment.