public DisplayTypeAsserter<RA> assertPluralLabel(String expectedOrig) { PrismAsserts.assertEqualsPolyString("Wrong pluralLabel in "+desc(), expectedOrig, displayType.getPluralLabel()); return this; }
public DisplayTypeAsserter<RA> assertLabel(String expectedOrig) { PrismAsserts.assertEqualsPolyString("Wrong label in "+desc(), expectedOrig, displayType.getLabel()); return this; }
protected void assertShadowName(PrismObject<ShadowType> shadow, String expectedName) { PrismAsserts.assertEqualsPolyString("Shadow name is wrong in "+shadow, expectedName, shadow.asObjectable().getName()); }
protected void assertShadowName(PrismObject<ShadowType> shadow, String expectedName) { PrismAsserts.assertEqualsPolyString("Shadow name is wrong in "+shadow, expectedName, shadow.asObjectable().getName()); }
protected void assertUser(PrismObject<UserType> user, String oid, String name, String fullName, String givenName, String familyName, String location) { assertObjectSanity(user); UserType userType = user.asObjectable(); if (oid != null) { assertEquals("Wrong " + user + " OID (prism)", oid, user.getOid()); assertEquals("Wrong " + user + " OID (jaxb)", oid, userType.getOid()); } PrismAsserts.assertEqualsPolyString("Wrong "+user+" name", name, userType.getName()); PrismAsserts.assertEqualsPolyString("Wrong "+user+" fullName", fullName, userType.getFullName()); PrismAsserts.assertEqualsPolyString("Wrong "+user+" givenName", givenName, userType.getGivenName()); PrismAsserts.assertEqualsPolyString("Wrong "+user+" familyName", familyName, userType.getFamilyName()); if (location != null) { PrismAsserts.assertEqualsPolyString("Wrong " + user + " location", location, userType.getLocality()); } }
protected void assertUser(PrismObject<UserType> user, String oid, String name, String fullName, String givenName, String familyName, String location) { assertObject(user); UserType userType = user.asObjectable(); if (oid != null) { assertEquals("Wrong " + user + " OID (prism)", oid, user.getOid()); assertEquals("Wrong " + user + " OID (jaxb)", oid, userType.getOid()); } PrismAsserts.assertEqualsPolyString("Wrong "+user+" name", name, userType.getName()); PrismAsserts.assertEqualsPolyString("Wrong "+user+" fullName", fullName, userType.getFullName()); PrismAsserts.assertEqualsPolyString("Wrong "+user+" givenName", givenName, userType.getGivenName()); PrismAsserts.assertEqualsPolyString("Wrong "+user+" familyName", familyName, userType.getFamilyName()); if (location != null) { PrismAsserts.assertEqualsPolyString("Wrong " + user + " location", location, userType.getLocality()); } }
public PrismObjectAsserter<O,RA> assertName(String expectedOrig) { PrismAsserts.assertEqualsPolyString("Wrong name in "+desc(), expectedOrig, getObject().getName()); return this; }
protected void assertPolyStringProperty(QName propName, String expectedOrig) { PrismProperty<PolyString> prop = getObject().findProperty(ItemName.fromQName(propName)); assertNotNull("No "+propName.getLocalPart()+" in "+desc(), prop); PrismAsserts.assertEqualsPolyString("Wrong "+propName.getLocalPart()+" in "+desc(), expectedOrig, prop.getRealValue()); }
protected void assertUserJack(PrismObject<UserType> user, String name, String fullName, String givenName, String familyName, String locality) { assertUser(user, USER_JACK_OID, name, fullName, givenName, familyName, locality); UserType userType = user.asObjectable(); PrismAsserts.assertEqualsPolyString("Wrong jack honorificPrefix", "Cpt.", userType.getHonorificPrefix()); PrismAsserts.assertEqualsPolyString("Wrong jack honorificSuffix", "PhD.", userType.getHonorificSuffix()); assertEquals("Wrong jack emailAddress", "jack.sparrow@evolveum.com", userType.getEmailAddress()); assertEquals("Wrong jack telephoneNumber", "555-1234", userType.getTelephoneNumber()); assertEquals("Wrong jack employeeNumber", "emp1234", userType.getEmployeeNumber()); assertEquals("Wrong jack employeeType", USER_JACK_SUBTYPE, userType.getSubtype().get(0)); if (locality == null) { assertNull("Locality sneaked to user jack", userType.getLocality()); } else { PrismAsserts.assertEqualsPolyString("Wrong jack locality", locality, userType.getLocality()); } }
@Test public void test100GoodRefImport() throws Exception { final String TEST_NAME = "test100GoodRefImport"; TestUtil.displayTestTitle(this,TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "." +TEST_NAME); FileInputStream stream = new FileInputStream(getFile(IMPORT_REF_FILE_NAME, false)); // WHEN modelService.importObjectsFromStream(stream, getLanguage(), getDefaultImportOptions(), task, result); // THEN result.computeStatus("Failed import."); display("Result after good import", result); TestUtil.assertSuccessOrWarning("Import has failed (result)", result, 2); // EqualsFilter equal = EqualsFilter.createEqual(UserType.F_NAME, UserType.class, PrismTestUtil.getPrismContext(), null, "jack"); // ObjectQuery query = ObjectQuery.createObjectQuery(equal); ObjectQuery query = ObjectQueryUtil.createNameQuery("jack", PrismTestUtil.getPrismContext()); List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result); assertNotNull(users); assertEquals("Search returned unexpected results", 1, users.size()); UserType jack = users.get(0).asObjectable(); assertNotNull(jack); PrismAsserts.assertEqualsPolyString("wrong givenName", "Jack", jack.getGivenName()); PrismAsserts.assertEqualsPolyString("wrong familyName", "Sparrow", jack.getFamilyName()); PrismAsserts.assertEqualsPolyString("wrong fullName", "Cpt. Jack Sparrow", jack.getFullName()); }
private void checkGroupPirates(PrismObject<ShadowType> shadow, OperationResult result) throws SchemaException { checkGroupShadow(shadow, result); PrismAsserts.assertEqualsPolyString("Name not equal.", transformNameFromResource(GROUP_PIRATES_NAME), shadow.getName()); assertEquals("Wrong kind (provisioning)", ShadowKindType.ENTITLEMENT, shadow.asObjectable().getKind()); assertAttribute(shadow, DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION, "Scurvy pirates"); Collection<ResourceAttribute<?>> attributes = ShadowUtil.getAttributes(shadow); assertEquals("Unexpected number of attributes", 3, attributes.size()); assertNull("The _PASSSWORD_ attribute sneaked into shadow", ShadowUtil.getAttributeValues( shadow, new QName(SchemaConstants.NS_ICF_SCHEMA, "password"))); }
protected void assertRolePirate(PrismObject<RoleType> role) { assertObjectSanity(role); assertEquals("Wrong "+role+" OID (prism)", ROLE_PIRATE_OID, role.getOid()); RoleType roleType = role.asObjectable(); assertEquals("Wrong "+role+" OID (jaxb)", ROLE_PIRATE_OID, roleType.getOid()); PrismAsserts.assertEqualsPolyString("Wrong "+role+" name", "Pirate", roleType.getName()); }
@Test public void test121RenameAccountWillOnResource() throws Exception{ String TEST_NAME = "test121RenameAccountWillOnResource"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); openDJController.executeRenameChange(new File(TEST_DIR, "rename.ldif").getPath()); Entry entry = openDJController.fetchEntry("uid=will123,ou=People,dc=example,dc=com"); assertNotNull("Entry with dn uid=will123,ou=People,dc=example,dc=com does not exist", entry); ShadowType repoShadowType = getShadowRepo(ACCOUNT_WILL_OID).asObjectable(); PrismAsserts.assertEqualsPolyString("Name not equal (repo)", "uid=will,ou=People,dc=example,dc=com", repoShadowType.getName()); assertAttribute(repoShadowType, getSecondaryIdentifierQName(), StringUtils.lowerCase(ACCOUNT_WILL_DN)); ShadowType provisioningAccountType = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result).asObjectable(); PrismAsserts.assertEqualsPolyString("Name not equal.", "uid=will123,ou=People,dc=example,dc=com", provisioningAccountType.getName()); assertAttribute(provisioningAccountType, getSecondaryIdentifierQName(), "uid=will123,ou=People,dc=example,dc=com"); repoShadowType = getShadowRepo(ACCOUNT_WILL_OID).asObjectable(); PrismAsserts.assertEqualsPolyString("Name not equal (repo after provisioning)", "uid=will123,ou=People,dc=example,dc=com", repoShadowType.getName()); assertAttribute(repoShadowType, getSecondaryIdentifierQName(), "uid=will123,ou=people,dc=example,dc=com"); assertShadows(1 + getNumberOfBaseContextShadows()); }
@Test public void test120AddAccountWill() throws Exception { final String TEST_NAME = "test120AddAccountWill"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); System.out.println(SchemaDebugUtil.prettyPrint(object)); System.out.println(object.asPrismObject().debugDump()); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); assertEquals(ACCOUNT_WILL_OID, addedObjectOid); ShadowType repoShadowType = getShadowRepo(ACCOUNT_WILL_OID).asObjectable(); PrismAsserts.assertEqualsPolyString("Name not equal (repo)", "uid=will,ou=People,dc=example,dc=com", repoShadowType.getName()); assertAttribute(repoShadowType, getSecondaryIdentifierQName(), StringUtils.lowerCase(ACCOUNT_WILL_DN)); ShadowType provisioningAccountType = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result).asObjectable(); PrismAsserts.assertEqualsPolyString("Name not equal.", "uid=will,ou=People,dc=example,dc=com", provisioningAccountType.getName()); assertShadows(1 + getNumberOfBaseContextShadows()); }
private PrismObject<RoleType> assertMetaRole(String metaroleOid, String metaroleName) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException, SchemaViolationException, ConflictException, InterruptedException { PrismObject<RoleType> role = getObject(RoleType.class, metaroleOid); display("Metarole after", role); assertObjectSanity(role); RoleType roleType = role.asObjectable(); PrismAsserts.assertEqualsPolyString("Wrong "+role+" name", metaroleName, roleType.getName()); assertAssigned(role, ROLE_META_META_WORLD_OID, RoleType.COMPLEX_TYPE); assertAssignments(role, 1); assertRoleMembershipRef(role, ROLE_META_META_WORLD_OID); assertLinks(role, 1); String shadowOid = roleType.getLinkRef().get(0).getOid(); PrismObject<ShadowType> groupShadowModel = getShadowModel(shadowOid); display("Role shadow (model)", groupShadowModel); String groupName = metaroleName.toLowerCase(); DummyGroup dummyGroup = getDummyGroup(null, groupName); assertNotNull("No dummy group "+groupName, dummyGroup); return role; }
private PrismContainer<Containerable> assertResource(PrismObject<ResourceType> resource, String resourceName, String namespace, String connectorOid, boolean fromRepo) { ResourceType resourceType = resource.asObjectable(); assertNotNull(resourceType); PrismAsserts.assertEqualsPolyString("Wrong resource name", resourceName, resourceType.getName()); assertEquals("Wrong namespace of "+resource, namespace, ResourceTypeUtil.getResourceNamespace(resourceType)); assertEquals("Wrong connector OID in "+resource, connectorOid, resourceType.getConnectorRef().getOid()); // The password in the resource configuration should be encrypted after import PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); PrismContainer<Containerable> configurationPropertiesContainer = configurationContainer.findContainer(SchemaTestConstants.ICFC_CONFIGURATION_PROPERTIES); assertNotNull("No configurationProperties in resource", configurationPropertiesContainer); return configurationPropertiesContainer; }
RoleType roleType = role.asObjectable(); PrismAsserts.assertEqualsPolyString("Wrong "+role+" name", ROLE_META_META_WORLD_NAME, roleType.getName());
private PrismObject<RoleType> readAndAssertGroupRole(String roleOid, String metaroleOid, String groupName) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException, SchemaViolationException, ConflictException, InterruptedException { PrismObject<RoleType> role = getObject(RoleType.class, roleOid); display("Role after", role); assertObjectSanity(role); RoleType roleType = role.asObjectable(); PrismAsserts.assertEqualsPolyString("Wrong "+role+" name", groupName, roleType.getName()); assertAssigned(role, metaroleOid, RoleType.COMPLEX_TYPE); assertAssignments(role, 1); assertRoleMembershipRef(role, metaroleOid); DummyGroup dummyGroup = getDummyGroup(null, groupName); assertNotNull("No dummy group "+groupName, dummyGroup); assertLinks(role, 1); String shadowOid = roleType.getLinkRef().get(0).getOid(); PrismObject<ShadowType> groupShadowModel = getShadowModel(shadowOid); display("Role shadow (model)", groupShadowModel); return role; }
@Test public void test414AddGroupCorsairsAssociateUser() throws Exception { final String TEST_NAME = "test414AddGroupCorsairsAssociateUser"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ShadowType object = parseObjectType(GROUP_CORSAIRS_FILE, ShadowType.class); IntegrationTestTools.display("Adding object", object); // WHEN displayWhen(TEST_NAME); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN displayThen(TEST_NAME); assertEquals(GROUP_CORSAIRS_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(GROUP_CORSAIRS_OID).asObjectable(); PrismAsserts.assertEqualsPolyString("Wrong ICF name (repo)", GROUP_CORSAIRS_DN, shadowType.getName()); // Do NOT read provisioning shadow here. We want everything to be "fresh" assertShadows(22); }
@Test(enabled=false) public void test005GetAccount() throws Exception { final String TEST_NAME = "test005GetAccount"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDBTable.class.getName() + "." + TEST_NAME); Task task = taskManager.createTaskInstance(); // WHEN PrismObject<ShadowType> account = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN result.computeStatus(); display(result); TestUtil.assertSuccess(result); PrismAsserts.assertEqualsPolyString("Name not equal.", ACCOUNT_WILL_USERNAME, account.asObjectable().getName()); assertNotNull("No credentials", account.asObjectable().getCredentials()); assertNotNull("No password", account.asObjectable().getCredentials().getPassword()); assertNotNull("No password value", account.asObjectable().getCredentials().getPassword().getValue()); ProtectedStringType password = account.asObjectable().getCredentials().getPassword().getValue(); display("Password", password); String clearPassword = protector.decryptString(password); assertEquals("Wrong password", ACCOUNT_WILL_PASSWORD, clearPassword); }