Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed May 23, 2014
2 parents df9e4bf + d017e17 commit 59c9e81
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 14 deletions.
Expand Up @@ -152,13 +152,13 @@ public <F extends ObjectType> void project(LensContext<F> context, String activi
// object template and assignments.
focusProcessor.processFocus(context, activityDescription, now, task, result);
context.recomputeFocus();
LensUtil.traceContext(LOGGER, activityDescription,"focus processing", false, context, false);
if (consistencyChecks) context.checkConsistence();

sortProjectionsToWaves(context);
maxWaves = computeMaxWaves(context);
LOGGER.trace("Continuing wave {}, maxWaves={}", context.getProjectionWave(), maxWaves);
LensUtil.traceContext(LOGGER, activityDescription,"assignments", false, context, true);

LensUtil.traceContext(LOGGER, activityDescription,"focus processing", false, context, false);
if (consistencyChecks) context.checkConsistence();
LensUtil.checkContextSanity(context, "focus processing", result);

Expand Down Expand Up @@ -366,12 +366,10 @@ public <F extends ObjectType> int computeMaxWaves(LensContext<F> context) {
// TODO: check for circular dependencies
private <F extends ObjectType> LensProjectionContext determineProjectionWave(LensContext<F> context,
LensProjectionContext projectionContext, ResourceObjectTypeDependencyType inDependency, List<ResourceObjectTypeDependencyType> depPath) throws PolicyViolationException {
LOGGER.trace("DEP1");
if (!projectionContext.isWaveIncomplete()) {
// This was already processed
return projectionContext;
}
LOGGER.trace("DEP2");
if (projectionContext.isDelete()) {
// Ignore dependencies if we are being removed
projectionContext.setWave(0);
Expand All @@ -380,13 +378,12 @@ private <F extends ObjectType> LensProjectionContext determineProjectionWave(Len
if (depPath == null) {
depPath = new ArrayList<ResourceObjectTypeDependencyType>();
}
LOGGER.trace("DEP3");
int determinedWave = 0;
int determinedOrder = 0;
for (ResourceObjectTypeDependencyType outDependency: projectionContext.getDependencies()) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("DEP: {}", outDependency);
}
// if (LOGGER.isTraceEnabled()) {
// LOGGER.trace("DEP: {}", outDependency);
// }
if (inDependency != null && isHigerOrder(outDependency, inDependency)) {
// There is incomming dependency. Deal only with dependencies of this order and lower
// otherwise we can end up in endless loop even for legal dependencies.
Expand All @@ -396,9 +393,9 @@ private <F extends ObjectType> LensProjectionContext determineProjectionWave(Len
depPath.add(outDependency);
ResourceShadowDiscriminator refDiscr = new ResourceShadowDiscriminator(outDependency, projectionContext.getKind());
LensProjectionContext dependencyProjectionContext = findDependencyContext(context, projectionContext, outDependency);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("DEP: {} -> {}", refDiscr, dependencyProjectionContext);
}
// if (LOGGER.isTraceEnabled()) {
// LOGGER.trace("DEP: {} -> {}", refDiscr, dependencyProjectionContext);
// }
if (dependencyProjectionContext == null) {
ResourceObjectTypeDependencyStrictnessType outDependencyStrictness = ResourceTypeUtil.getDependencyStrictness(outDependency);
if (outDependencyStrictness == ResourceObjectTypeDependencyStrictnessType.STRICT) {
Expand Down
Expand Up @@ -158,9 +158,12 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
protected static final String ROLE_CAPTAIN_OID = "12345678-d34d-b33f-f00d-55555555cccc";

// Excludes role "pirate"
protected static final String ROLE_JUDGE_FILENAME = COMMON_DIR_NAME + "/role-judge.xml";
protected static final File ROLE_JUDGE_FILE = new File(COMMON_DIR, "role-judge.xml");
protected static final String ROLE_JUDGE_OID = "12345111-1111-2222-1111-121212111111";

protected static final File ROLE_EMPTY_FILE = new File(COMMON_DIR, "role-empty.xml");
protected static final String ROLE_EMPTY_OID = "12345111-1111-2222-1111-121212111112";

protected static final File USER_JACK_FILE = new File(COMMON_DIR_NAME, "user-jack.xml");
protected static final String USER_JACK_OID = "c0c010c0-d34d-b33f-f00d-111111111111";
protected static final String USER_JACK_USERNAME = "jack";
Expand Down
Expand Up @@ -232,7 +232,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
repoAddObjectFromFile(ROLE_PIRATE_FILE, RoleType.class, initResult);
repoAddObjectFromFile(ROLE_NICE_PIRATE_FILENAME, RoleType.class, initResult);
repoAddObjectFromFile(ROLE_CAPTAIN_FILENAME, RoleType.class, initResult);
repoAddObjectFromFile(ROLE_JUDGE_FILENAME, RoleType.class, initResult);
repoAddObjectFromFile(ROLE_JUDGE_FILE, RoleType.class, initResult);
repoAddObjectFromFile(ROLE_EMPTY_FILE, RoleType.class, initResult);

// Orgstruct
if (doAddOrgstruct()) {
Expand Down
Expand Up @@ -1183,5 +1183,138 @@ public void test703JackModifyJudgeDeleteInducementHonorabilityRecompute() throws
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false);
assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "title", "Bloody Honorable");
}

@Test
public void test709JackUnAssignRoleJudge() throws Exception {
final String TEST_NAME = "test709JackUnAssignRoleJudge";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
display("User jack before", userBefore);

// WHEN
TestUtil.displayWhen(TEST_NAME);
unassignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

assertAssignedNoRole(USER_JACK_OID, task, result);
assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}

@Test
public void test710JackAssignRoleEmpty() throws Exception {
final String TEST_NAME = "test710JackAssignRoleEmpty";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
display("User jack before", userBefore);

// WHEN
TestUtil.displayWhen(TEST_NAME);
assignRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result);
assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}

@Test
public void test712JackModifyEmptyRoleAddInducementPirateRecompute() throws Exception {
final String TEST_NAME = "test712JackModifyEmptyRoleAddInducementPirateRecompute";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
display("User jack before", userBefore);

modifyRoleAddInducementTarget(ROLE_EMPTY_OID, ROLE_PIRATE_OID);

// WHEN
TestUtil.displayWhen(TEST_NAME);
recomputeUser(USER_JACK_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result);

assertDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "title", "Bloody Pirate");
assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "weapon", "cutlass");
}

@Test
public void test714JackModifyEmptyRoleDeleteInducementPirateRecompute() throws Exception {
final String TEST_NAME = "test714JackModifyEmptyRoleDeleteInducementPirateRecompute";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
display("User jack before", userBefore);

modifyRoleDeleteInducementTarget(ROLE_EMPTY_OID, ROLE_PIRATE_OID);

// WHEN
TestUtil.displayWhen(TEST_NAME);
recomputeUser(USER_JACK_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result);

assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}

@Test
public void test719JackUnAssignRoleEmpty() throws Exception {
final String TEST_NAME = "test719JackUnAssignRoleEmpty";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
display("User jack before", userBefore);

// WHEN
TestUtil.displayWhen(TEST_NAME);
unassignRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

assertAssignedNoRole(USER_JACK_OID, task, result);
assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}

}
23 changes: 23 additions & 0 deletions model/model-intest/src/test/resources/common/role-empty.xml
@@ -0,0 +1,23 @@
<!--
~ Copyright (c) 2014 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.
-->
<role oid="12345111-1111-2222-1111-121212111112"
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:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance/10000000-0000-0000-0000-000000000004"
xmlns:piracy="http://midpoint.evolveum.com/xml/ns/samples/piracy">
<name>Empty</name>
</role>
Expand Up @@ -1589,7 +1589,7 @@ private PrismObject<ShadowType> completeShadow(ConnectorInstance connector, Pris
if (resourceAssociationContainer != null) {
RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource);
PrismContainer<ShadowAssociationType> associationContainer = resourceAssociationContainer.clone();
resultShadow.add(associationContainer);
resultShadow.addReplaceExisting(associationContainer);
if (associationContainer != null) {
for (PrismContainerValue<ShadowAssociationType> associationCVal: associationContainer.getValues()) {
ResourceAttributeContainer identifierContainer = ShadowUtil.getAttributesContainer(associationCVal, ShadowAssociationType.F_IDENTIFIERS);
Expand Down

0 comments on commit 59c9e81

Please sign in to comment.