use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestParseMetarole method assertMetaroleJaxb.
private void assertMetaroleJaxb(RoleType roleType, boolean isObject) throws SchemaException {
assertEquals("Wrong name", PrismTestUtil.createPolyStringType("Generic Metarole"), roleType.getName());
boolean found = false;
for (AssignmentType inducement : roleType.getInducement()) {
if (inducement.getId() == 2L) {
found = true;
PolicyRuleType rule = inducement.getPolicyRule();
assertNotNull("No constraints", rule.getPolicyConstraints());
assertEquals("Wrong # of assignment constraints", 1, rule.getPolicyConstraints().getAssignment().size());
assertTrue("Wrong (not empty) assignment constraints", rule.getPolicyConstraints().getAssignment().get(0).asPrismContainerValue().isEmpty());
break;
}
}
assertTrue("Assignment number 2 was not found", found);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestSchemaDelta method testSubtractAssignmentFromModifyDelta.
@Test
public void testSubtractAssignmentFromModifyDelta() throws Exception {
final String TEST_NAME = "testSubtractAssignmentFromModifyDelta";
displayTestTile(TEST_NAME);
// GIVEN
PrismObject<UserType> user = PrismTestUtil.parseObject(USER_BILL_FILE);
user.asObjectable().getAssignment().get(0).setId(9999L);
AssignmentType assignment9999 = new AssignmentType();
assignment9999.setId(9999L);
ObjectDelta<UserType> delta = (ObjectDelta<UserType>) DeltaBuilder.deltaFor(UserType.class, getPrismContext()).item(UserType.F_ASSIGNMENT).delete(assignment9999).asObjectDelta(user.getOid());
// WHEN
PrismContainerDefinition<AssignmentType> assignmentDef = PrismTestUtil.getSchemaRegistry().findContainerDefinitionByCompileTimeClass(AssignmentType.class).clone();
((PrismContainerDefinitionImpl) assignmentDef).setMaxOccurs(1);
PrismContainer<AssignmentType> assignmentContainer = assignmentDef.instantiate();
PrismContainerValue<AssignmentType> assignmentValue = ObjectTypeUtil.createAssignmentTo("00000001-d34d-b33f-f00d-000000000002", ObjectTypes.ROLE, getPrismContext()).asPrismContainerValue();
assignmentValue.setId(9999L);
assignmentContainer.add(assignmentValue);
System.out.println("Delta before operation:\n" + delta.debugDump() + "\n");
System.out.println("Assignment to subtract:\n" + assignmentValue.debugDump() + "\n");
boolean removed = delta.subtract(SchemaConstants.PATH_ASSIGNMENT, assignmentValue, true, false);
// THEN
System.out.println("Delta after operation:\n" + delta.debugDump() + "\n");
System.out.println("Removed: " + removed + "\n");
assertTrue("Not removed", removed);
assertTrue("Remaining delta is not a MODIFY delta", delta.isModify());
assertEquals("Wrong # of remaining modifications", 0, delta.getModifications().size());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestSchemaDelta method testDeleteInducementConstructionSameNullIdApplyToObject.
@Test
public void testDeleteInducementConstructionSameNullIdApplyToObject() throws Exception {
final String TEST_NAME = "testDeleteInducementConstructionSameNullIdApplyToObject";
displayTestTile(TEST_NAME);
// GIVEN
PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE);
//Delta
ConstructionType construction = new ConstructionType();
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(ROLE_CONSTRUCTION_RESOURCE_OID);
resourceRef.setType(ObjectTypes.RESOURCE.getTypeQName());
construction.setResourceRef(resourceRef);
// No container ID
ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationDeleteContainer(RoleType.class, ROLE_CONSTRUCTION_OID, new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT), new IdItemPathSegment(ROLE_CONSTRUCTION_INDUCEMENT_ID), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION)), getPrismContext(), construction);
// WHEN
roleDelta.applyTo(role);
// THEN
System.out.println("Role after delta application:");
System.out.println(role.debugDump());
assertEquals("Wrong OID", ROLE_CONSTRUCTION_OID, role.getOid());
PrismAsserts.assertPropertyValue(role, UserType.F_NAME, PrismTestUtil.createPolyString("Construction"));
PrismContainer<AssignmentType> inducementContainer = role.findContainer(RoleType.F_INDUCEMENT);
assertNotNull("No inducement", inducementContainer);
assertEquals("Unexpected number of inducement values", 1, inducementContainer.size());
PrismContainerValue<AssignmentType> inducementValue = inducementContainer.getValues().iterator().next();
AssignmentType inducement = inducementValue.asContainerable();
ConstructionType constructionAfter = inducement.getConstruction();
// construction should be gone (the error is that it is empty and not gone)
assertNull("Construction is not gone", constructionAfter);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestSecurityBasic method test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta.
/**
* MID-3136
*/
@Test
public void test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta() throws Exception {
final String TEST_NAME = "test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
cleanupAutzTest(USER_JACK_OID);
assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
login(USER_JACK_USERNAME);
// WHEN
TestUtil.displayWhen(TEST_NAME);
assertReadAllow(NUMBER_OF_ALL_USERS + 1);
assertAddDeny();
assertModifyDeny();
assertDeleteDeny();
PrismObject<UserType> user = getUser(USER_JACK_OID);
assertAssignments(user, 2);
assertAssignedRole(user, ROLE_ASSIGN_REQUESTABLE_ROLES_OID);
assertAllow("assign business role to jack", (task, result) -> assignPrametricRole(USER_JACK_OID, ROLE_BUSINESS_1_OID, ORG_MINISTRY_OF_RUM_OID, null, task, result));
user = getUser(USER_JACK_OID);
assertAssignments(user, 3);
assertAssignedRole(user, ROLE_BUSINESS_1_OID);
assertDeny("assign application role to jack", (task, result) -> {
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
ContainerDelta<AssignmentType> assignmentDelta1 = ContainerDelta.createDelta(UserType.F_ASSIGNMENT, getUserDefinition());
PrismContainerValue<AssignmentType> cval = new PrismContainerValue<AssignmentType>(prismContext);
assignmentDelta1.addValueToAdd(cval);
PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF);
targetRef.getValue().setOid(ROLE_BUSINESS_2_OID);
targetRef.getValue().setTargetType(RoleType.COMPLEX_TYPE);
targetRef.getValue().setRelation(null);
cval.setId(123L);
ContainerDelta<AssignmentType> assignmentDelta = assignmentDelta1;
modifications.add(assignmentDelta);
ObjectDelta<UserType> userDelta1 = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext);
ObjectDelta<UserType> userDelta = userDelta1;
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
modelService.executeChanges(deltas, null, task, result);
});
assertAllow("unassign business role from jack", (task, result) -> unassignPrametricRole(USER_JACK_OID, ROLE_BUSINESS_1_OID, ORG_MINISTRY_OF_RUM_OID, null, task, result));
user = getUser(USER_JACK_OID);
display("user after (expected 2 assignments)", user);
assertAssignments(user, 2);
RoleSelectionSpecification spec = getAssignableRoleSpecification(getUser(USER_JACK_OID));
assertRoleTypes(spec);
assertFilter(spec.getFilter(), TypeFilter.class);
assertGlobalStateUntouched();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestAssignmentErrors method setupUserAssignAccountDeletedShadowRecompute.
private PrismObject<UserType> setupUserAssignAccountDeletedShadowRecompute(final String TEST_NAME, String dummyResourceOid, String dummyResourceName, String userName, String userFullName) throws Exception {
// GIVEN
Task task = taskManager.createTaskInstance(TestAssignmentErrors.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
getDummyResource().resetBreakMode();
PrismObject<UserType> user = createUser(userName, userFullName);
AssignmentType assignmentType = createConstructionAssignment(dummyResourceOid, ShadowKindType.ACCOUNT, null);
user.asObjectable().getAssignment().add(assignmentType);
ActivationType activationType = new ActivationType();
activationType.setAdministrativeStatus(ActivationStatusType.ENABLED);
user.asObjectable().setActivation(activationType);
addObject(user);
// precondition
assertDummyAccount(dummyResourceName, userName, userFullName, true);
// Re-read user to get the links
user = getUser(user.getOid());
display("User before", user);
String shadowOidBefore = getSingleLinkOid(user);
// precondition
PrismObject<ShadowType> shadowBefore = repositoryService.getObject(ShadowType.class, shadowOidBefore, null, result);
display("Shadow before", shadowBefore);
// delete just the shadow, not the account
repositoryService.deleteObject(ShadowType.class, shadowOidBefore, result);
result.computeStatus();
TestUtil.assertSuccess(result);
assertNoRepoCache();
dummyAuditService.clear();
return user;
}
Aggregations