Search in sources :

Example 16 with PrismSchema

use of com.evolveum.midpoint.prism.schema.PrismSchema in project midpoint by Evolveum.

the class TestUcfDummy method test000PrismContextSanity.

@Test
public void test000PrismContextSanity() throws Exception {
    final String TEST_NAME = "test000PrismContextSanity";
    TestUtil.displayTestTile(TEST_NAME);
    SchemaRegistry schemaRegistry = PrismTestUtil.getPrismContext().getSchemaRegistry();
    PrismSchema schemaIcfc = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_CONFIGURATION);
    assertNotNull("ICFC schema not found in the context (" + SchemaConstants.NS_ICF_CONFIGURATION + ")", schemaIcfc);
    PrismContainerDefinition<ConnectorConfigurationType> configurationPropertiesDef = schemaIcfc.findContainerDefinitionByElementName(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
    assertNotNull("icfc:configurationProperties not found in icfc schema (" + SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME + ")", configurationPropertiesDef);
    PrismSchema schemaIcfs = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_SCHEMA);
    assertNotNull("ICFS schema not found in the context (" + SchemaConstants.NS_ICF_SCHEMA + ")", schemaIcfs);
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) ConnectorConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test)

Example 17 with PrismSchema

use of com.evolveum.midpoint.prism.schema.PrismSchema in project midpoint by Evolveum.

the class TestRbac method test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment.

@Test
public void test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exception {
    final String TEST_NAME = "test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismContainer<?> extension = getAssignmentExtensionInstance();
    PrismSchema piracySchema = getPiracySchema();
    PrismPropertyDefinition<String> seaPropDef = piracySchema.findPropertyDefinitionByElementName(PIRACY_SEA_QNAME);
    PrismProperty<String> seaProp = seaPropDef.instantiate();
    seaProp.setRealValue("Caribbean");
    extension.add(seaProp);
    // WHEN
    unassignRole(USER_JACK_OID, ROLE_BLACK_SEA_PIRATE_OID, extension, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after", userJack);
    assertAssignments(userJack, 0);
    assertRoleMembershipRef(userJack);
    assertDelegatedRef(userJack);
    assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) Task(com.evolveum.midpoint.task.api.Task) 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 18 with PrismSchema

use of com.evolveum.midpoint.prism.schema.PrismSchema in project midpoint by Evolveum.

the class TestRbac method test132JackUnAssignRolePirateWithSeaInAssignment.

@Test
public void test132JackUnAssignRolePirateWithSeaInAssignment() throws Exception {
    final String TEST_NAME = "test132JackUnAssignRolePirateWithSeaInAssignment";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismContainer<?> extension = getAssignmentExtensionInstance();
    PrismSchema piracySchema = getPiracySchema();
    PrismPropertyDefinition<String> seaPropDef = piracySchema.findPropertyDefinitionByElementName(PIRACY_SEA_QNAME);
    PrismProperty<String> seaProp = seaPropDef.instantiate();
    seaProp.setRealValue("Caribbean");
    extension.add(seaProp);
    // WHEN
    unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, extension, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after", userJack);
    assertAssignments(userJack, 0);
    assertRoleMembershipRef(userJack);
    assertDelegatedRef(userJack);
    assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) Task(com.evolveum.midpoint.task.api.Task) 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 19 with PrismSchema

use of com.evolveum.midpoint.prism.schema.PrismSchema in project midpoint by Evolveum.

the class TestRbac method test137JackAssignRoleAdriaticPirateWithSeaInAssignment.

/**
	 * Even though we assign Adriatic Pirate role which has a sea set in its extension the
	 * sea set in user's extension should override it.
	 */
@Test
public void test137JackAssignRoleAdriaticPirateWithSeaInAssignment() throws Exception {
    final String TEST_NAME = "test137JackAssignRoleAdriaticPirateWithSeaInAssignment";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismContainer<?> extension = getAssignmentExtensionInstance();
    PrismSchema piracySchema = getPiracySchema();
    PrismPropertyDefinition<String> seaPropDef = piracySchema.findPropertyDefinitionByElementName(PIRACY_SEA_QNAME);
    PrismProperty<String> seaProp = seaPropDef.instantiate();
    seaProp.setRealValue("Caribbean");
    extension.add(seaProp);
    // WHEN
    assignRole(USER_JACK_OID, ROLE_ADRIATIC_PIRATE_OID, extension, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
    display("User jack after", userAfter);
    assertAssignedRole(userAfter, ROLE_ADRIATIC_PIRATE_OID, task, result);
    assertRoleMembershipRef(userAfter, ROLE_ADRIATIC_PIRATE_OID, ROLE_PIRATE_OID);
    assertDelegatedRef(userAfter);
    assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
    assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "title", "Bloody Pirate");
    assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "location", "Tortuga");
    // Outbound mapping for weapon is weak, therefore the mapping in role should override it 
    assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "weapon", "cutlass");
    assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, "Jack Sparrow is the best pirate Tortuga has ever seen");
    assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, DUMMY_ACCOUNT_ATTRIBUTE_SEA_NAME, "jack sailed Caribbean, immediately Adriatic, role , with this The Seven Seas while focused on Caribbean (in Pirate)");
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) Task(com.evolveum.midpoint.task.api.Task) 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 20 with PrismSchema

use of com.evolveum.midpoint.prism.schema.PrismSchema in project midpoint by Evolveum.

the class TestRbac method test147JackAssignRoleBlackSeaPirateWithSeaInAssignment.

@Test
public void test147JackAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exception {
    final String TEST_NAME = "test147JackAssignRoleBlackSeaPirateWithSeaInAssignment";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismContainer<?> extension = getAssignmentExtensionInstance();
    PrismSchema piracySchema = getPiracySchema();
    PrismPropertyDefinition<String> seaPropDef = piracySchema.findPropertyDefinitionByElementName(PIRACY_SEA_QNAME);
    PrismProperty<String> seaProp = seaPropDef.instantiate();
    seaProp.setRealValue("Caribbean");
    extension.add(seaProp);
    // WHEN
    assignRole(USER_JACK_OID, ROLE_BLACK_SEA_PIRATE_OID, extension, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
    display("User jack after", userAfter);
    assertAssignedRole(userAfter, ROLE_BLACK_SEA_PIRATE_OID, task, result);
    assertRoleMembershipRef(userAfter, ROLE_BLACK_SEA_PIRATE_OID, ROLE_PIRATE_OID);
    assertDelegatedRef(userAfter);
    assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
    assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "title", "Bloody Pirate");
    assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "location", "Tortuga");
    // Outbound mapping for weapon is weak, therefore the mapping in role should override it 
    assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "weapon", "cutlass");
    assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, "Jack Sparrow is the best pirate Tortuga has ever seen");
    assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, DUMMY_ACCOUNT_ATTRIBUTE_SEA_NAME, "jack sailed Caribbean, immediately Marmara Sea, role Black Sea, with this The Seven Seas while focused on Caribbean (in Pirate)");
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) Task(com.evolveum.midpoint.task.api.Task) 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)

Aggregations

PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)44 Test (org.testng.annotations.Test)20 QName (javax.xml.namespace.QName)10 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)8 Element (org.w3c.dom.Element)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)6 Task (com.evolveum.midpoint.task.api.Task)6 ConnectorConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType)6 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)6 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4 Document (org.w3c.dom.Document)4 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 PrismSchemaImpl (com.evolveum.midpoint.prism.schema.PrismSchemaImpl)3 SchemaRegistryImpl (com.evolveum.midpoint.prism.schema.SchemaRegistryImpl)3