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()); }
public static String getDisplayName(ShadowType shadow) { String objectName = PolyString.getOrig(shadow.getName()); QName oc = shadow.getObjectClass(); String ocName = oc != null ? oc.getLocalPart() : null; return objectName + " (" + shadow.getKind() + " - " + shadow.getIntent() + " - " + ocName + ")"; }
@Override public void recordIterativeOperationStart(ShadowType shadow) { recordIterativeOperationStart(PolyString.getOrig(shadow.getName()), StatisticsUtil.getDisplayName(shadow), ShadowType.COMPLEX_TYPE, shadow.getOid()); }
@Override public void recordIterativeOperationEnd(ShadowType shadow, long started, Throwable exception) { recordIterativeOperationEnd(PolyString.getOrig(shadow.getName()), StatisticsUtil.getDisplayName(shadow), ShadowType.COMPLEX_TYPE, shadow.getOid(), started, exception); }
public SynchronizationEventInformation(PrismObject<? extends ShadowType> currentShadow, String channel, Task task) { this.channel = channel; started = System.currentTimeMillis(); if (currentShadow != null) { final ShadowType shadow = currentShadow.asObjectable(); objectName = PolyString.getOrig(shadow.getName()); objectDisplayName = StatisticsUtil.getDisplayName(shadow); objectOid = currentShadow.getOid(); } task.recordSynchronizationOperationStart(objectName, objectDisplayName, ShadowType.COMPLEX_TYPE, objectOid); if (SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI.equals(channel)) { // livesync processing is not controlled via model -> so we cannot do this in upper layers task.recordIterativeOperationStart(objectName, objectDisplayName, ShadowType.COMPLEX_TYPE, objectOid); } }
@Override public String getShadowName(PrismObject<? extends ShadowType> shadow) { if (shadow == null) { return null; } else if (shadow.asObjectable().getName() != null) { return shadow.asObjectable().getName().getOrig(); } else { Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil.getSecondaryIdentifiers(shadow); LOGGER.trace("secondary identifiers: {}", secondaryIdentifiers); // first phase = looking for "name" identifier for (ResourceAttribute ra : secondaryIdentifiers) { if (ra.getElementName() != null && ra.getElementName().getLocalPart().contains("name")) { LOGGER.trace("Considering {} as a name", ra); return String.valueOf(ra.getAnyRealValue()); } } // second phase = returning any value ;) if (!secondaryIdentifiers.isEmpty()) { return String.valueOf(secondaryIdentifiers.iterator().next().getAnyRealValue()); } else { return null; } } }
@Override protected void assertShadowName(PrismObject<ShadowType> shadow, String expectedName) { assertEquals("Shadow name is wrong in "+shadow, expectedName.toLowerCase(), shadow.asObjectable().getName().getOrig().toLowerCase()); }
@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()); }
public static void checkRepoShadow(PrismObject<ShadowType> repoShadow, ShadowKindType kind, Integer expectedNumberOfAttributes) { ShadowType repoShadowType = repoShadow.asObjectable(); assertNotNull("No OID in repo shadow "+repoShadow, repoShadowType.getOid()); assertNotNull("No name in repo shadow "+repoShadow, repoShadowType.getName()); assertNotNull("No objectClass in repo shadow "+repoShadow, repoShadowType.getObjectClass()); assertEquals("Wrong kind in repo shadow "+repoShadow, kind, repoShadowType.getKind()); PrismContainer<Containerable> attributesContainer = repoShadow.findContainer(ShadowType.F_ATTRIBUTES); assertNotNull("No attributes in repo shadow "+repoShadow, attributesContainer); List<Item<?,?>> attributes = attributesContainer.getValue().getItems(); assertFalse("Empty attributes in repo shadow "+repoShadow, attributes.isEmpty()); if (expectedNumberOfAttributes != null) { assertEquals("Unexpected number of attributes in repo shadow "+repoShadow, (int)expectedNumberOfAttributes, attributes.size()); } }
@Override public boolean handle(PrismObject<ObjectType> prismObject, OperationResult parentResult) { ObjectType objectType = prismObject.asObjectable(); objects.add(objectType); display("Found object", objectType); assertTrue(objectType instanceof ShadowType); ShadowType shadow = (ShadowType) objectType; assertNotNull(shadow.getOid()); assertNotNull(shadow.getName()); assertEquals(new QName(resourceNamespace, OBJECT_CLASS_INETORGPERSON_NAME), shadow.getObjectClass()); assertEquals(RESOURCE_OPENDJ_OID, shadow.getResourceRef().getOid()); String idPrimaryVal = getAttributeValue(shadow, getPrimaryIdentifierQName()); assertNotNull("No primary identifier ("+getPrimaryIdentifierQName().getLocalPart()+")", idPrimaryVal); String idSecondaryVal = getAttributeValue(shadow, getSecondaryIdentifierQName()); assertNotNull("No secondary ("+getSecondaryIdentifierQName().getLocalPart()+")", idSecondaryVal); assertEquals("Wrong shadow name", idSecondaryVal.toLowerCase(), shadow.getName().getOrig().toLowerCase()); assertNotNull("Missing LDAP uid", getAttributeValue(shadow, new QName(resourceNamespace, "uid"))); assertNotNull("Missing LDAP cn", getAttributeValue(shadow, new QName(resourceNamespace, "cn"))); assertNotNull("Missing LDAP sn", getAttributeValue(shadow, new QName(resourceNamespace, "sn"))); assertNotNull("Missing activation", shadow.getActivation()); assertNotNull("Missing activation status", shadow.getActivation().getAdministrativeStatus()); assertEquals("Not enabled", ActivationStatusType.ENABLED, shadow.getActivation().getAdministrativeStatus()); return true; } };
@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); }
@Override public boolean handle(PrismObject<ShadowType> object, OperationResult parentResult) { foundObjects.add(object); display("Found", object); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); assertTrue(object.canRepresent(ShadowType.class)); try { checkAccountShadow(object, parentResult, true, startTs, endTs); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } assertCachingMetadata(object, false, startTs, endTs); if (object.asObjectable().getName().getOrig().equals("meathook")) { meathookAccountOid = object.getOid(); seenMeathookHolder.setValue(true); try { Integer loot = ShadowUtil.getAttributeValue(object, dummyResourceCtl.getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME)); assertEquals("Wrong meathook's loot", 666, (int) loot); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } } return true; } };
protected ObjectChecker<ShadowType> createShadowChecker(final boolean fullShadow) { return (shadow) -> { String icfName = ShadowUtil.getSingleStringAttributeValue(shadow, SchemaTestConstants.ICFS_NAME); assertNotNull("No ICF NAME", icfName); assertEquals("Wrong shadow name ("+shadow.getName()+")", StringUtils.lowerCase(icfName), StringUtils.lowerCase(shadow.getName().getOrig())); assertNotNull("No kind in "+shadow, shadow.getKind()); if (shadow.getKind() == ShadowKindType.ACCOUNT) { if (fullShadow) { assertNotNull( "Missing fullname attribute", ShadowUtil.getSingleStringAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "fullname"))); if (supportsActivation()) { assertNotNull("no activation", shadow.getActivation()); assertNotNull("no activation status", shadow.getActivation().getAdministrativeStatus()); assertEquals("not enabled", ActivationStatusType.ENABLED, shadow.getActivation().getAdministrativeStatus()); } } assertProvisioningAccountShadow(shadow.asPrismObject(), resourceType, RefinedAttributeDefinition.class); } }; }
private void assertJaxb(ShadowType shadow, boolean isObject) throws SchemaException { if (isObject) { assertEquals("88519fca-3f4a-44ca-91c8-dc9be5bf3d03", shadow.getOid()); } assertEquals("Wrong name", PrismTestUtil.createPolyStringType("hbarbossa"), shadow.getName()); ActivationType activation = shadow.getActivation(); assertNotNull("No activation", activation); assertEquals("User not enabled", ActivationStatusType.ENABLED, activation.getAdministrativeStatus()); ObjectReferenceType resourceRef = shadow.getResourceRef(); assertNotNull("No resourceRef", resourceRef); assertEquals("Wrong resourceRef oid (jaxb)", "10000000-0000-0000-0000-000000000003", resourceRef.getOid()); assertEquals("Wrong resourceRef type (jaxb)", ResourceType.COMPLEX_TYPE, resourceRef.getType()); }
@Test public void test405GetGroupSwashbucklers() throws Exception { final String TEST_NAME = "test405GetGroupSwashbucklers"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN displayWhen(TEST_NAME); PrismObject<ShadowType> provisioningShadow = provisioningService.getObject(ShadowType.class, GROUP_SWASHBUCKLERS_OID, null, task, result); // THEN displayThen(TEST_NAME); ShadowType provisioningShadowType = provisioningShadow.asObjectable(); assertEquals("Wrong ICF name (provisioning)", dnMatchingRule.normalize(GROUP_SWASHBUCKLERS_DN), dnMatchingRule.normalize(provisioningShadowType.getName().getOrig())); String uid = ShadowUtil.getSingleStringAttributeValue(provisioningShadowType, getPrimaryIdentifierQName()); assertNotNull(uid); ResourceAttribute<Object> memberAttr = ShadowUtil.getAttribute(provisioningShadow, new QName(RESOURCE_OPENDJ_NS, GROUP_MEMBER_ATTR_NAME)); assertNull("Member attribute sneaked in", memberAttr); Entry ldapEntry = openDJController.searchAndAssertByEntryUuid(uid); display("LDAP group", ldapEntry); assertNotNull("No LDAP group entry"); String groupDn = ldapEntry.getDN().toString(); assertEquals("Wrong group DN", dnMatchingRule.normalize(GROUP_SWASHBUCKLERS_DN), dnMatchingRule.normalize(groupDn)); assertShadows(19); }
copyObjectInformationFromJAXB(jaxb, repo, repositoryContext, generatorResult); repo.setNameCopy(RPolyString.copyFromJAXB(jaxb.getName())); repo.setObjectClass(RUtil.qnameToString(jaxb.getObjectClass())); repo.setIntent(jaxb.getIntent());
@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); }