Skip to content

Commit

Permalink
Attempt to reproduce "unsupported" error criticality issue (MID-5129)…
Browse files Browse the repository at this point in the history
…: cannot reproduce
  • Loading branch information
semancik committed Mar 7, 2019
1 parent ec5d485 commit 7cb47ad
Show file tree
Hide file tree
Showing 2 changed files with 289 additions and 5 deletions.
Expand Up @@ -53,8 +53,13 @@ public class TestLimitedResources extends AbstractStoryTest {
protected static final File RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_FILE = new File(TEST_DIR, "resource-dummy-no-attribute-add-delete.xml");
protected static final String RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID = "5098fa64-8386-11e8-b2e2-83ada4418787";
protected static final String RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_NAME = "no-attribute-add-delete";
private static final String RESOURCE_DUMMY_NS = MidPointConstants.NS_RI;
private static final String RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_SHIP_PREFIX = "Spirit of ";

protected static final File RESOURCE_DUMMY_NO_CREATE_FILE = new File(TEST_DIR, "resource-dummy-no-create.xml");
protected static final String RESOURCE_DUMMY_NO_CREATE_OID = "dbaf45c6-40fb-11e9-85b4-5f58a76d12e0";
protected static final String RESOURCE_DUMMY_NO_CREATE_NAME = "no-create";

private static final String RESOURCE_DUMMY_NS = MidPointConstants.NS_RI;

private static final String OU_TREASURE_HUNT = "Treasure Hunt";
private static final String OU_LOOTING = "Looting";
Expand All @@ -66,6 +71,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
super.initSystem(initTask, initResult);

initDummyResourcePirate(RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_NAME, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_FILE, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, initTask, initResult);
initDummyResourcePirate(RESOURCE_DUMMY_NO_CREATE_NAME, RESOURCE_DUMMY_NO_CREATE_FILE, RESOURCE_DUMMY_NO_CREATE_OID, initTask, initResult);
}

@Test
Expand Down Expand Up @@ -104,14 +110,13 @@ public void test100AssignJackAccountNoAttributeAddDelete() throws Exception {
displayWhen(TEST_NAME);
assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, null, task, result);


// THEN
displayThen(TEST_NAME);
assertSuccess(result);

PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User after", userAfter);
getSingleLinkOid(userAfter);
assertUserAfter(USER_JACK_OID)
.links()
.single();

assertAADWeapon(USER_JACK_USERNAME /* no value */);
}
Expand Down Expand Up @@ -215,6 +220,82 @@ public void test108DeleteJackOrganizationalUnitTreasureHuntSailing() throws Exce
assertAADWeapon(USER_JACK_USERNAME /* no values */);
}

@Test
public void test109UnassignJackAccountNoAttributeAddDelete() throws Exception {
final String TEST_NAME = "test109UnassignJackAccountNoAttributeAddDelete";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
displayWhen(TEST_NAME);
unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, null, task, result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);

assertUserAfter(USER_JACK_OID)
.assignments()
.assertNone()
.end()
.links()
.assertNone();
}

/**
* MID-5129
*/
@Test
public void test110AssignJackAccountNoCreate() throws Exception {
final String TEST_NAME = "test110AssignJackAccountNoCreate";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
displayWhen(TEST_NAME);
assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_NO_CREATE_OID, null, task, result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);

assertUserAfter(USER_JACK_OID)
.links()
.assertNone();

assertNoDummyAccount(RESOURCE_DUMMY_NO_CREATE_NAME, USER_JACK_USERNAME);
}

@Test
public void test119UnassignJackAccountNoCreate() throws Exception {
final String TEST_NAME = "test119UnassignJackAccountNoCreate";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
displayWhen(TEST_NAME);
unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_NO_CREATE_OID, null, task, result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);

assertUserAfter(USER_JACK_OID)
.assignments()
.assertNone()
.end()
.links()
.assertNone();

assertNoDummyAccount(RESOURCE_DUMMY_NO_CREATE_NAME, USER_JACK_USERNAME);
}

private void assertAADWeapon(String username, String... ous) throws SchemaViolationException, ConflictException, InterruptedException {
assertDummyAccount(RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_NAME, username);
Object[] weapons = new String[ous.length];
Expand Down
@@ -0,0 +1,203 @@
<?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-5129 -->

<resource oid="dbaf45c6-40fb-11e9-85b4-5f58a76d12e0"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
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-3"
xmlns:mr="http://prism.evolveum.com/xml/ns/public/matching-rule-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3"
xmlns:piracy="http://midpoint.evolveum.com/xml/ns/samples/piracy"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<name>Dummy Resource: No create</name>
<connectorRef type="ConnectorType">
<filter>
<q:and>
<q:equal>
<q:path>connectorType</q:path>
<q:value>com.evolveum.icf.dummy.connector.DummyConnector</q:value>
</q:equal>
<q:equal>
<q:path>connectorVersion</q:path>
<q:value>2.0</q:value>
</q:equal>
</q:and>
</filter>
</connectorRef>
<connectorConfiguration xmlns:icfi="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"
xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">

<icfc:configurationProperties>
<icfi:instanceId>no-create</icfi:instanceId>
<icfi:uselessGuardedString>
<clearValue>whatever</clearValue>
</icfi:uselessGuardedString>
<icfi:uselessString>USEless</icfi:uselessString>
</icfc:configurationProperties>

<icfc:resultsHandlerConfiguration>
<icfc:enableNormalizingResultsHandler>false</icfc:enableNormalizingResultsHandler>
<icfc:enableFilteredResultsHandler>false</icfc:enableFilteredResultsHandler>
<icfc:enableAttributesToGetSearchResultsHandler>false</icfc:enableAttributesToGetSearchResultsHandler>
</icfc:resultsHandlerConfiguration>

</connectorConfiguration>

<schemaHandling>
<objectType>
<kind>account</kind>
<intent>default</intent>
<default>true</default>
<objectClass>ri:AccountObjectClass</objectClass>
<attribute>
<ref>icfs:name</ref>
<displayName>Username</displayName>
<outbound>
<strength>strong</strength>
<source>
<path>$user/name</path>
</source>
<expression>
<script>
<code>
name + iterationToken
</code>
</script>
</expression>
</outbound>
</attribute>
<attribute>
<ref>icfs:uid</ref>
</attribute>
<attribute>
<ref>ri:fullname</ref>
<outbound>
<source>
<path>$user/fullName</path>
</source>
</outbound>
</attribute>
<attribute>
<ref>ri:title</ref>
<tolerant>true</tolerant>
</attribute>
<attribute>
<ref>ri:location</ref>
<displayName>Location</displayName>
<outbound>
<strength>strong</strength>
<source>
<path>
$user/locality
</path>
</source>
</outbound>
</attribute>
<attribute>
<ref>ri:ship</ref>
<displayName>Ship</displayName>
</attribute>
<attribute>
<ref>ri:weapon</ref>
<displayName>Weapon</displayName>
<!-- MID-4607 -->
<outbound>
<strength>strong</strength>
<source>
<path>$focus/organizationalUnit</path>
</source>
<expression>
<allowEmptyValues>true</allowEmptyValues>
<script>
<code>
if (organizationalUnit != null)
return "Spirit of " + organizationalUnit
return null;
</code>
</script>
</expression>
</outbound>
</attribute>
<attribute>
<ref>ri:drink</ref>
<displayName>Drink</displayName>
<tolerant>false</tolerant>
</attribute>
<attribute>
<ref>ri:quote</ref>
<displayName>Quote</displayName>
<tolerant>false</tolerant>
</attribute>
<attribute>
<ref>ri:gossip</ref>
<displayName>Gossip</displayName>
<tolerant>true</tolerant>
</attribute>
<attribute>
<ref>ri:water</ref>
<limitations>
<ignore>true</ignore>
</limitations>
</attribute>

<iteration>
<maxIterations>5</maxIterations>
</iteration>

<activation>
<existence>
<outbound/>
</existence>
<administrativeStatus>
<outbound/>
</administrativeStatus>
<lockoutStatus>
<outbound/>
</lockoutStatus>
</activation>

<credentials>
<password>
<outbound/>
</password>
</credentials>

</objectType>

</schemaHandling>

<capabilities>
<configured>
<cap:create>
<cap:enabled>false</cap:enabled>
</cap:create>
</configured>
</capabilities>

<consistency>
<connectorErrorCriticality>
<unsupported>ignore</unsupported>
</connectorErrorCriticality>
</consistency>

</resource>

0 comments on commit 7cb47ad

Please sign in to comment.