Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed May 30, 2022
2 parents 74e70fd + 393b05c commit 82d4e20
Show file tree
Hide file tree
Showing 147 changed files with 2,546 additions and 1,779 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public String getObject() {
ocDef = refinedSchema.findObjectDefinition(getKind(), null);
}
if (ocDef != null) {
return ocDef.getObjectClassDefinition().getTypeName().getLocalPart();
return ocDef.getObjectClassName().getLocalPart();
}
} catch (SchemaException | ConfigurationException e) {
// TODO?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private String getResourceOid(SearchFilterType searchFilterType) {
private ResourceShadowDiscriminator getResourceShadowDiscriminator(SearchFilterType searchFilterType) {
try {
ObjectFilter filter = getPrismContext().getQueryConverter().createObjectFilter(ShadowType.class, searchFilterType);
return ObjectQueryUtil.getCoordinates(filter, getPrismContext());
return ObjectQueryUtil.getCoordinates(filter);
} catch (SchemaException e) {
LOGGER.error("Cannot convert filter: {}", e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import static com.evolveum.midpoint.schema.constants.SchemaConstants.RI_ACCOUNT_OBJECT_CLASS;

import static com.evolveum.midpoint.test.util.MidPointTestConstants.*;

import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.AssertJUnit.*;

Expand Down Expand Up @@ -44,7 +46,6 @@
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.processor.*;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.schema.util.SchemaTestConstants;
import com.evolveum.midpoint.schema.util.ShadowUtil;
import com.evolveum.midpoint.test.util.TestUtil;
Expand Down Expand Up @@ -208,7 +209,7 @@ private void assertAccountEntitlements(ResourceSchema schema, ResourceObjectDefi

ResourceAttributeDefinition<?> entDisplayNameAttributeDef = rEntDef.getDisplayNameAttribute();
assertNotNull("No entitlement displayNameAttribute", entDisplayNameAttributeDef);
assertEquals("Wrong entitlement displayNameAttribute", new QName(MidPointConstants.NS_RI, "cn"), entDisplayNameAttributeDef.getItemName());
assertEquals("Wrong entitlement displayNameAttribute", QNAME_CN, entDisplayNameAttributeDef.getItemName());

assertEquals("Unexpected number of entitlement associations", 1, accountDef.getAssociationDefinitions().size());
}
Expand Down Expand Up @@ -237,7 +238,7 @@ private void assertAccountObjectDefinition(

ResourceAttributeDefinition<?> displayNameAttributeDef = accountDef.getDisplayNameAttribute();
assertNotNull("No account displayNameAttribute", displayNameAttributeDef);
assertEquals("Wrong account displayNameAttribute", new QName(MidPointConstants.NS_RI, "uid"), displayNameAttributeDef.getItemName());
assertEquals("Wrong account displayNameAttribute", QNAME_UID, displayNameAttributeDef.getItemName());

// This is compatibility with PrismContainerDefinition, it should work well
Collection<? extends ItemDefinition<?>> propertyDefinitions = accountDef.getDefinitions();
Expand Down Expand Up @@ -363,9 +364,8 @@ public void test110ApplyAttributeDefinition() throws Exception {
}

private void assertAccountShadow(PrismObject<ShadowType> accObject, PrismObject<ResourceType> resource) throws SchemaException {
QName objectClassQName = new QName(MidPointConstants.NS_RI, "AccountObjectClass");
PrismAsserts.assertPropertyValue(accObject, ShadowType.F_NAME, createPolyString("jack"));
PrismAsserts.assertPropertyValue(accObject, ShadowType.F_OBJECT_CLASS, objectClassQName);
PrismAsserts.assertPropertyValue(accObject, ShadowType.F_OBJECT_CLASS, (QName) RI_ACCOUNT_OBJECT_CLASS);
PrismAsserts.assertPropertyValue(accObject, ShadowType.F_INTENT, SchemaConstants.INTENT_DEFAULT);

PrismContainer<?> attributes = accObject.findOrCreateContainer(SchemaConstants.C_ATTRIBUTES);
Expand All @@ -374,26 +374,26 @@ private void assertAccountShadow(PrismObject<ShadowType> accObject, PrismObject<
assertAttributeDefs(attrDef, null, LayerType.MODEL);

PrismAsserts.assertPropertyValue(attributes, SchemaTestConstants.ICFS_NAME, "uid=jack,ou=People,dc=example,dc=com");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "cn"), "Jack Sparrow");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "givenName"), "Jack");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "sn"), "Sparrow");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "uid"), "jack");
PrismAsserts.assertPropertyValue(attributes, QNAME_CN, "Jack Sparrow");
PrismAsserts.assertPropertyValue(attributes, QNAME_GIVEN_NAME, "Jack");
PrismAsserts.assertPropertyValue(attributes, QNAME_SN, "Sparrow");
PrismAsserts.assertPropertyValue(attributes, QNAME_UID, "jack");

assertEquals("JAXB class name doesn't match (1)", ShadowType.class, accObject.getCompileTimeClass());

accObject.checkConsistence();

ShadowType accObjectType = accObject.asObjectable();
assertEquals("Wrong JAXB name", createPolyStringType("jack"), accObjectType.getName());
assertEquals("Wrong JAXB objectClass", objectClassQName, accObjectType.getObjectClass());
assertEquals("Wrong JAXB objectClass", RI_ACCOUNT_OBJECT_CLASS, accObjectType.getObjectClass());
ShadowAttributesType attributesType = accObjectType.getAttributes();
assertNotNull("null ResourceObjectShadowAttributesType (JAXB)", attributesType);
List<Object> attributeElements = attributesType.getAny();
TestUtil.assertElement(attributeElements, SchemaTestConstants.ICFS_NAME, "uid=jack,ou=People,dc=example,dc=com");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "cn"), "Jack Sparrow");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "givenName"), "Jack");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "sn"), "Sparrow");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "uid"), "jack");
TestUtil.assertElement(attributeElements, QNAME_CN, "Jack Sparrow");
TestUtil.assertElement(attributeElements, QNAME_GIVEN_NAME, "Jack");
TestUtil.assertElement(attributeElements, QNAME_SN, "Sparrow");
TestUtil.assertElement(attributeElements, QNAME_UID, "jack");

String accString = PrismTestUtil.serializeObjectToString(accObjectType.asPrismObject());
System.out.println("Result of JAXB marshalling:\n" + accString);
Expand All @@ -402,7 +402,7 @@ private void assertAccountShadow(PrismObject<ShadowType> accObject, PrismObject<
}

private ItemName getAttrQName(PrismObject<ResourceType> resource, String localPart) {
return new ItemName(ResourceTypeUtil.getResourceNamespace(resource), localPart);
return new ItemName(MidPointConstants.NS_RI, localPart);
}

@Test
Expand Down Expand Up @@ -482,13 +482,13 @@ private void assertRObjectClassDef(ResourceObjectDefinition rAccount, LayerType
false, true, false, // Access: create, read, update
sourceLayer, validationLayer);

assertAttributeDef(attrs, new QName(MidPointConstants.NS_RI, "cn"), DOMUtil.XSD_STRING,
assertAttributeDef(attrs, QNAME_CN, DOMUtil.XSD_STRING,
1, (validationLayer == LayerType.MODEL || validationLayer == LayerType.PRESENTATION) ? 1 : -1, "Common Name", 1,
true, validationLayer == LayerType.PRESENTATION,
true, true, true, // Access: create, read, update
sourceLayer, validationLayer);

assertAttributeDef(attrs, new QName(MidPointConstants.NS_RI, "uid"),
assertAttributeDef(attrs, QNAME_UID,
DOMUtil.XSD_STRING,
validationLayer == LayerType.SCHEMA ? 0 : 1, // minOccurs
validationLayer == LayerType.SCHEMA ? -1 : 1, // maxOccurs
Expand All @@ -497,7 +497,7 @@ private void assertRObjectClassDef(ResourceObjectDefinition rAccount, LayerType
true, true, validationLayer != LayerType.PRESENTATION, // Access: create, read, update
sourceLayer, validationLayer);

assertAttributeDef(attrs, new QName(MidPointConstants.NS_RI, "employeeNumber"),
assertAttributeDef(attrs, QNAME_EMPLOYEE_NUMBER,
DOMUtil.XSD_STRING, 0, 1, null, null,
false, false,
true, true, true, // Access: create, read, update
Expand Down Expand Up @@ -587,31 +587,31 @@ public void test140ParseFromResourcePosix() throws Exception {
Collection<? extends ResourceAttributeDefinition<?>> rAccountAttrs = rAccountDef.getAttributeDefinitions();
assertFalse(rAccountAttrs.isEmpty());

assertAttributeDef(rAccountAttrs, new QName(MidPointConstants.NS_RI, "dn"),
assertAttributeDef(rAccountAttrs, QNAME_DN,
DOMUtil.XSD_STRING, 1, 1, "Distinguished Name", 110,
true, false,
true, true, true, // Access: create, read, update
LayerType.SCHEMA, LayerType.PRESENTATION);

assertAttributeDef(rAccountAttrs, new QName(MidPointConstants.NS_RI, "entryUUID"),
assertAttributeDef(rAccountAttrs, QNAME_ENTRY_UUID,
DOMUtil.XSD_STRING, 0, 1, "entryUUID", 100,
false, false,
false, true, false, // Access: create, read, update
LayerType.SCHEMA, LayerType.PRESENTATION);

assertAttributeDef(rAccountAttrs, new QName(MidPointConstants.NS_RI, "cn"),
assertAttributeDef(rAccountAttrs, QNAME_CN,
DOMUtil.XSD_STRING, 1, -1, "Common Name", 590,
true, false,
true, true, true, // Access: create, read, update
LayerType.SCHEMA, LayerType.PRESENTATION);

assertAttributeDef(rAccountAttrs, new QName(MidPointConstants.NS_RI, "uid"),
assertAttributeDef(rAccountAttrs, QNAME_UID,
DOMUtil.XSD_STRING, 0, -1, "Login Name", 300,
true, false,
true, true, true, // Access: create, read, update
LayerType.SCHEMA, LayerType.PRESENTATION);

assertAttributeDef(rAccountAttrs, new QName(MidPointConstants.NS_RI, "employeeNumber"),
assertAttributeDef(rAccountAttrs, QNAME_EMPLOYEE_NUMBER,
DOMUtil.XSD_STRING, 0, 1, "employeeNumber", 140,
false, false,
true, true, true, // Access: create, read, update
Expand All @@ -633,7 +633,7 @@ public void test140ParseFromResourcePosix() throws Exception {

ResourceAttributeDefinition<?> displayNameAttributeDef = rAccountDef.getDisplayNameAttribute();
assertNotNull("No account displayNameAttribute", displayNameAttributeDef);
assertEquals("Wrong account displayNameAttribute", new QName(MidPointConstants.NS_RI, "dn"),
assertEquals("Wrong account displayNameAttribute", QNAME_DN,
displayNameAttributeDef.getItemName());

// This is compatibility with PrismContainerDefinition, it should work well
Expand All @@ -655,7 +655,7 @@ public void test140ParseFromResourcePosix() throws Exception {

ResourceAttributeDefinition<?> entDisplayNameAttributeDef = rEntDef.getDisplayNameAttribute();
assertNotNull("No entitlement displayNameAttribute", entDisplayNameAttributeDef);
assertEquals("Wrong entitlement displayNameAttribute", new QName(MidPointConstants.NS_RI, "dn"),
assertEquals("Wrong entitlement displayNameAttribute", QNAME_DN,
entDisplayNameAttributeDef.getItemName());

assertEquals("Unexpected number of entitlement associations", 1, rAccountDef.getAssociationDefinitions().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.Objects;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.schema.constants.SchemaConstants;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -140,6 +142,18 @@ public boolean isWildcard() {
return kind == null && objectClass == null;
}

public boolean haveUnknownValuesPresent() {
return kind == ShadowKindType.UNKNOWN
|| SchemaConstants.INTENT_UNKNOWN.equals(intent);
}

public void checkNotUnknown() {
if (haveUnknownValuesPresent()) {
throw new IllegalStateException(
"Unknown kind/intent values are not expected here: " + toHumanReadableDescription(false));
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down

0 comments on commit 82d4e20

Please sign in to comment.