Fix referential integrity plugin silently bypassing check-references for modify operations
Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/294a922f-c00a-410a-bc78-529db303e337
Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
| | |
| | | } |
| | | |
| | | final List<Modification> mods = modifyOperation.getModifications(); |
| | | final Entry entry = modifyOperation.getModifiedEntry(); |
| | | |
| | | /* Make sure the entry belongs to one of the configured naming contexts. */ |
| | | DN entryDN = entry.getName(); |
| | | DN entryDN = modifyOperation.getEntryDN(); |
| | | DN entryBaseDN = getEntryBaseDN(entryDN); |
| | | if (entryBaseDN == null) |
| | | { |
| | |
| | | if (modType != ModificationType.ADD |
| | | && modType != ModificationType.REPLACE) |
| | | { |
| | | break; |
| | | continue; |
| | | } |
| | | |
| | | Attribute modifiedAttribute = entry.getAttribute(mod.getAttribute().getAttributeDescription()); |
| | | if (modifiedAttribute != null) |
| | | Attribute modifiedAttribute = mod.getAttribute(); |
| | | if (modifiedAttribute != null && !modifiedAttribute.isEmpty()) |
| | | { |
| | | PluginResult.PreOperation result = |
| | | isIntegrityMaintained(modifiedAttribute, entryDN, entryBaseDN); |
| | |
| | | "member", "uid=user.1,ou=people,ou=dept,o=test"); |
| | | assertEquals(modOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | @Test |
| | | public void testEnforceIntegrityModifyGroupAddMissingUniqueMember() throws Exception |
| | | { |
| | | replaceAttrEntry(configDN, "ds-cfg-enabled", "false"); |
| | | replaceAttrEntry(configDN, dsConfigPluginType, |
| | | "postoperationdelete", |
| | | "postoperationmodifydn", |
| | | "subordinatemodifydn", |
| | | "subordinatedelete", |
| | | "preoperationadd", |
| | | "preoperationmodify"); |
| | | addAttrEntry(configDN, dsConfigBaseDN, "dc=example,dc=com"); |
| | | replaceAttrEntry(configDN, dsConfigEnforceIntegrity, "true"); |
| | | replaceAttrEntry(configDN, dsConfigAttrType, "uniquemember"); |
| | | addAttrEntry(configDN, dsConfigAttrFiltMapping, |
| | | "uniquemember:(objectclass=person)"); |
| | | replaceAttrEntry(configDN, "ds-cfg-enabled", "true"); |
| | | |
| | | ModifyOperation modOperation = addAttrEntry(DN.valueOf(ugroup), |
| | | "uniquemember", "uid=user.100,ou=people,ou=dept,dc=example,dc=com"); |
| | | assertEquals(modOperation.getResultCode(), ResultCode.CONSTRAINT_VIOLATION); |
| | | } |
| | | } |