Search in sources :

Example 46 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class TestMultiResource method test440DavidAndGoliathAssignRoleAndCreateUserInOneStep.

@Test
public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exception {
    getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode();
    getDummyResource(RESOURCE_DUMMY_DAVID_NAME).resetBreakMode();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    // delete user and his roles which were added before
    PrismObject<UserType> userWorld = findUserByUsername(USER_FIELD_NAME);
    AssertJUnit.assertNotNull("User must not be null.", userWorld);
    ObjectDelta<UserType> delta = prismContext.deltaFactory().object().createDeleteDelta(UserType.class, userWorld.getOid());
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
    deltas.add(delta);
    modelService.executeChanges(deltas, null, task, result);
    OperationResult deleteResult = createOperationResult("Check if user was deleted properly.");
    try {
        repositoryService.getObject(UserType.class, userWorld.getOid(), null, deleteResult);
    } catch (ObjectNotFoundException ex) {
    // this is OK, we deleted user before
    }
    // GIVEN
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    PrismObject<UserType> userBefore = createUser(USER_WORLD_NAME, USER_WORLD_FULL_NAME, true);
    userBefore.asObjectable().getOrganizationalUnit().add(PrismTestUtil.createPolyStringType("stone"));
    PrismContainerValue<AssignmentType> cval = prismContext.itemFactory().createContainerValue();
    PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF);
    targetRef.getValue().setOid(ROLE_FIGHT_OID);
    targetRef.getValue().setTargetType(RoleType.COMPLEX_TYPE);
    userBefore.findOrCreateContainer(UserType.F_ASSIGNMENT).add((PrismContainerValue) cval);
    // this should add user and at the sate time assign the role fight..->
    // the result of the operation have to be the same as in test 400
    addObject(userBefore);
    dummyAuditService.clear();
    expect();
    assertSuccess(result);
    assertDavidGoliath(userBefore.getOid(), "stone", USER_WORLD_NAME, true, true, true);
    // Check audit
    displayDumpable("Audit", dummyAuditService);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 47 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class TestMultiResource method test529JackUnassignRoleDarkYellowPeru.

/**
 * MID-4554
 */
@Test
public void test529JackUnassignRoleDarkYellowPeru() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
    display("User before", userBefore);
    AssignmentType currentAssignment = findAssignmentByTargetRequired(userBefore, ROLE_DARK_YELLOW_PERU_OID);
    // WHEN
    when();
    unassign(UserType.class, USER_JACK_OID, currentAssignment.getId(), task, result);
    // THEN
    then();
    assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
    display("User after", userAfter);
    assertAssignments(userAfter, 0);
    assertLiveLinks(userAfter, 2);
    assertDummyAccount(RESOURCE_DUMMY_DARK_YELLOW_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false);
    assertDummyAccount(RESOURCE_DUMMY_DARK_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 48 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method fillinUserAssignmentAccountConstruction.

protected void fillinUserAssignmentAccountConstruction(PrismObject<UserType> user, String resourceOid) {
    AssignmentType assignmentType = new AssignmentType();
    ConstructionType accountConstruntion = new ConstructionType();
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resourceOid);
    resourceRef.setType(ResourceType.COMPLEX_TYPE);
    accountConstruntion.setResourceRef(resourceRef);
    accountConstruntion.setKind(ShadowKindType.ACCOUNT);
    assignmentType.setConstruction(accountConstruntion);
    user.asObjectable().getAssignment().add(assignmentType);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 49 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method determineSingleInducedRuleId.

protected String determineSingleInducedRuleId(String roleOid, OperationResult result) throws CommonException {
    RoleType role = repositoryService.getObject(RoleType.class, roleOid, null, result).asObjectable();
    List<AssignmentType> ruleInducements = role.getInducement().stream().filter(i -> i.getPolicyRule() != null).collect(Collectors.toList());
    assertThat(ruleInducements).as("policy rule inducements in " + role).hasSize(1);
    Long id = ruleInducements.get(0).getId();
    argCheck(id != null, "Policy rule inducement in %s has no PCV ID", roleOid);
    return roleOid + ":" + id;
}
Also used : com.evolveum.midpoint.model.test.asserter(com.evolveum.midpoint.model.test.asserter) StringUtils(org.apache.commons.lang.StringUtils) AuditReferenceValue(com.evolveum.midpoint.audit.api.AuditReferenceValue) Autowired(org.springframework.beans.factory.annotation.Autowired) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) Entry(org.opends.server.types.Entry) com.evolveum.midpoint.test.asserter(com.evolveum.midpoint.test.asserter) PrismTestUtil(com.evolveum.midpoint.prism.util.PrismTestUtil) EvaluatedPolicyRule(com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) MidpointFunctions(com.evolveum.midpoint.model.api.expr.MidpointFunctions) MutableInt(org.apache.commons.lang.mutable.MutableInt) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) TransportService(com.evolveum.midpoint.notifications.api.transports.TransportService) com.evolveum.prism.xml.ns._public.types_3(com.evolveum.prism.xml.ns._public.types_3) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) Task(com.evolveum.midpoint.task.api.Task) TaskUtil(com.evolveum.midpoint.task.api.TaskUtil) PreconditionViolationException(com.evolveum.midpoint.repo.api.PreconditionViolationException) FilterInvocation(org.springframework.security.web.FilterInvocation) ModuleWebSecurityConfiguration(com.evolveum.midpoint.authentication.api.ModuleWebSecurityConfiguration) SystemObjectCache(com.evolveum.midpoint.model.common.SystemObjectCache) QName(javax.xml.namespace.QName) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) FocusValuePolicyOriginResolver(com.evolveum.midpoint.model.common.stringpolicy.FocusValuePolicyOriginResolver) Clock(com.evolveum.midpoint.common.Clock) java.util(java.util) Authorization(com.evolveum.midpoint.security.api.Authorization) AuthenticationModuleNameConstants(com.evolveum.midpoint.authentication.api.util.AuthenticationModuleNameConstants) com.evolveum.midpoint.util(com.evolveum.midpoint.util) AuthenticationModuleState(com.evolveum.midpoint.authentication.api.AuthenticationModuleState) MiscUtil.or0(com.evolveum.midpoint.util.MiscUtil.or0) AuditEventStage(com.evolveum.midpoint.audit.api.AuditEventStage) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) ActivityBasedTaskHandler(com.evolveum.midpoint.repo.common.activity.run.task.ActivityBasedTaskHandler) EquivalenceStrategy(com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy) com.evolveum.midpoint.model.api(com.evolveum.midpoint.model.api) HookRegistry(com.evolveum.midpoint.model.api.hooks.HookRegistry) TestUtil(com.evolveum.midpoint.test.util.TestUtil) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) ConnectException(java.net.ConnectException) AfterClass(org.testng.annotations.AfterClass) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) AuthorizationParameters(com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters) IOException(java.io.IOException) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectResolver(com.evolveum.midpoint.repo.common.ObjectResolver) File(java.io.File) ActivityReportUtil(com.evolveum.midpoint.repo.common.activity.run.reports.ActivityReportUtil) ModelElementContext(com.evolveum.midpoint.model.api.context.ModelElementContext) AtomicLong(java.util.concurrent.atomic.AtomicLong) ReferenceResolver(com.evolveum.midpoint.model.api.util.ReferenceResolver) OpenDJController(com.evolveum.midpoint.test.ldap.OpenDJController) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal) ItemName(com.evolveum.midpoint.prism.path.ItemName) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) MiscUtil.argCheck(com.evolveum.midpoint.util.MiscUtil.argCheck) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AuthorityUtils(org.springframework.security.core.authority.AuthorityUtils) ProvisioningStatistics(com.evolveum.midpoint.schema.statistics.ProvisioningStatistics) TaskDebugUtil(com.evolveum.midpoint.task.api.TaskDebugUtil) com.evolveum.midpoint.schema.util(com.evolveum.midpoint.schema.util) NotificationManager(com.evolveum.midpoint.notifications.api.NotificationManager) CommonTaskBeans(com.evolveum.midpoint.repo.common.activity.run.CommonTaskBeans) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SecurityContextManager(com.evolveum.midpoint.security.api.SecurityContextManager) AuthorizationConstants(com.evolveum.midpoint.security.api.AuthorizationConstants) PerformanceInformation(com.evolveum.midpoint.repo.api.perf.PerformanceInformation) com.evolveum.icf.dummy.resource(com.evolveum.icf.dummy.resource) InternalsConfig(com.evolveum.midpoint.schema.internals.InternalsConfig) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) Collections.singleton(java.util.Collections.singleton) TaskActivityManager(com.evolveum.midpoint.repo.common.activity.TaskActivityManager) InformationSource(com.evolveum.midpoint.schema.util.task.ActivityProgressInformationBuilder.InformationSource) ItemSecurityConstraints(com.evolveum.midpoint.security.enforcer.api.ItemSecurityConstraints) DirectoryException(org.opends.server.types.DirectoryException) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) PrismObject.asObjectableList(com.evolveum.midpoint.prism.PrismObject.asObjectableList) ConfigAttribute(org.springframework.security.access.ConfigAttribute) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) Experimental(com.evolveum.midpoint.util.annotation.Experimental) CompiledGuiProfile(com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile) PrismAsserts(com.evolveum.midpoint.prism.util.PrismAsserts) BeforeMethod(org.testng.annotations.BeforeMethod) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) ValuePolicyProcessor(com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor) PrismObjectAsserter(com.evolveum.midpoint.test.asserter.prism.PrismObjectAsserter) SecurityContext(org.springframework.security.core.context.SecurityContext) ProvisioningService(com.evolveum.midpoint.provisioning.api.ProvisioningService) DashboardService(com.evolveum.midpoint.model.api.interaction.DashboardService) com.evolveum.midpoint.prism.delta(com.evolveum.midpoint.prism.delta) F_TIMESTAMP(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType.F_TIMESTAMP) SecurityConfig(org.springframework.security.access.SecurityConfig) AnonymousAuthenticationToken(org.springframework.security.authentication.AnonymousAuthenticationToken) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) NotNull(org.jetbrains.annotations.NotNull) Authentication(org.springframework.security.core.Authentication) com.evolveum.midpoint.schema(com.evolveum.midpoint.schema) AssertJUnit(org.testng.AssertJUnit) ActivityPath(com.evolveum.midpoint.schema.util.task.ActivityPath) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) GuiProfiledPrincipal(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OrgFilter(com.evolveum.midpoint.prism.query.OrgFilter) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) ModelContext(com.evolveum.midpoint.model.api.context.ModelContext) BucketingConfigurationOverrides(com.evolveum.midpoint.repo.common.activity.run.buckets.BucketingConfigurationOverrides) Objects.requireNonNull(java.util.Objects.requireNonNull) Qualifier(org.springframework.beans.factory.annotation.Qualifier) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) PrismContainerDefinitionAsserter(com.evolveum.midpoint.test.asserter.prism.PrismContainerDefinitionAsserter) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) BucketingManager(com.evolveum.midpoint.repo.common.activity.run.buckets.BucketingManager) GuiProfiledPrincipalManager(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipalManager) ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) SecurityEnforcer(com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer) FileInputStream(java.io.FileInputStream) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Consumer(java.util.function.Consumer) Message(com.evolveum.midpoint.notifications.api.transports.Message) UnusedTestElement(com.evolveum.midpoint.tools.testng.UnusedTestElement) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) com.evolveum.midpoint.schema.processor(com.evolveum.midpoint.schema.processor) com.evolveum.midpoint.test(com.evolveum.midpoint.test) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 50 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method modifyRoleAddInducementTarget.

protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean recomputeMembers, ModelExecuteOptions defaultOptions) throws CommonException {
    OperationResult result = createSubresult("modifyRoleAddInducementTarget");
    AssignmentType inducement = new AssignmentType();
    ObjectReferenceType targetRef = new ObjectReferenceType();
    targetRef.setOid(targetOid);
    inducement.setTargetRef(targetRef);
    ObjectDelta<RoleType> roleDelta = prismContext.deltaFactory().object().createModificationAddContainer(RoleType.class, roleOid, RoleType.F_INDUCEMENT, inducement);
    ModelExecuteOptions options = setRecomputeMembers(defaultOptions, recomputeMembers);
    executeChanges(roleDelta, options, getTestTask(), result);
    result.computeStatus();
    if (recomputeMembers) {
        TestUtil.assertInProgressOrSuccess(result);
    } else {
        TestUtil.assertSuccess(result);
    }
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)121 Test (org.testng.annotations.Test)61 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)55 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)42 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)41 Task (com.evolveum.midpoint.task.api.Task)39 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)33 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)25 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)24 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)21 QName (javax.xml.namespace.QName)20 PrismObject (com.evolveum.midpoint.prism.PrismObject)19 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)17 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)17 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)17 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)17 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)17 ArrayList (java.util.ArrayList)17 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)15 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)14