Repository navigation
[#212] Write an attribute given in another case under the schema's name, and refuse one given twice, in create and update - #217
Merged
maximthomas merged 5 commits intoNov 2, 2026
Conversation
…nder the schema's name in create and update
…is given more than once, in any case
… the XSD makes __NAME__ optional
…e first, so an XSD with two names that differ only in case keeps both apart
…ate's empty-name check; note how create refuses a valueless second name
vharseko
approved these changes
Nov 2, 2026
vharseko
left a comment
Member
There was a problem hiding this comment.
Reviewed at e22ced1. I found no new issues in the changes.
create and update resolve supplied names to the schema spelling before applying them, and reject repeated attributes before changing the document. The exact-name lookup also preserves the distinction between schema attributes whose names differ only in case.
The remaining case-sensitive filter behavior and the treatment of elements previously written under another spelling are documented in the PR description and tracked in #218.
I did not run the tests locally. CodeQL passed; the Maven CI jobs were still pending when I checked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #212.
The framework compares attribute names without regard to case, and
checkAttribute(#192) looks a given attribute up in the schema the same way. Everything after that lookup used the caller's spelling, while the XSD and the file name attributes exactly:createkept the checked values under the given spelling. Its required-attribute pass and its write go through the schema's attributes, so they missedLastName: a required attribute failed withNo values provided for required attribute: lastname, an optional one was written as an empty element. Its__NAME__check was an exactcontainsKey, so__name__alone got__NAME__ must be defined.updateremoved and wrote elements under the given spelling.LastName=Xleft<ri:lastname>as it was and appended<ri:LastName>X</ri:LastName>.__password__appended an element and left the password unchanged.__name__skipped the taken-name check and left the entry's name unchanged.Now
checkAttributereturns the attribute under the schema's name,CheckedAttribute(attributeInfo.getName(), values), and every later step uses that name: the__NAME__rules, the messages,create's required pass and write, andupdate's taken-name check, removal and write. It looks the given name up exactly first, and without regard to case only when the schema has no attribute of exactly that name. An XSD may declare two names that differ only in case, such aslastnameandLastName, and the framework's case-insensitive map holds one of the two for both names; the exact lookup keeps them apart.Data field: X is not supported.keeps the given spelling, as the schema has none.createfinds__NAME__withAttributeUtil.find, which ignores case, and takes the name from the checked values. It no longer callsAttributeUtil.getNameFromAttributes, which casts the attribute toName; only an exact__NAME__is aName, so__name__would throwClassCastExceptionthere.A new
checkAttributesrunscheckAttributeover the given set, in order, and refuses a schema attribute given more than once in any spelling:Data field: lastname is given more than once, as lastname and as LastName.ASet<Attribute>can hold such a pair, becauseAttribute.hashCodeignores case whileequalscompares the values too; it can even hold exactly one name twice with different values. Neither value is surely the one meant, so the pair is refused rather than resolved by the order of the set. The framework'sCreateImplrefuses only exactly one name given twice, andUpdateImplneither. Both operations use the helper, so the refusal comes before any change to the document.Changes in behaviour
createand inupdate.createwithLastNameand nolastnamesucceeds.__name__renames the entry and is checked for a clash.__password__replaces the stored password.checkAttributeexceptData field: X is not supported.names the attribute as the schema spells it. For example,IS-DELETED=trueinupdatenow getsis-deleted is not updatable., notIS-DELETED is not updatable.IllegalArgumentExceptionwith the message above, and nothing changes. Before,createeither kept one of the values or, for[LastName, lastname], refused the request as missinglastname;updateapplied both attributes, in order.updatechecks whether a new__NAME__is taken only after every given attribute has passed its checks, ascreatedoes. A taken name together with a bad attribute now gets theIllegalArgumentExceptionabout the attribute instead ofAlreadyExistsException.Data field: lastname is given more than once, as lastname and as lastname.OpenIDM's provisioner turns each operation into its own attribute, so tworeplaceoperations on/lastnamereachupdateaslastnamegiven twice. Before, the last one won: of tworeplaceoperations the second was written, and of twoaddoperations on a multi-valued attribute the first new value was lost. This was traced through OpenIDM's and the framework's code, not run.creategiven both writes each value into its own element. Before, it wrote the second value into the element spelled like the first name given, and left the other element empty.Tests
XMLHandlerReloadTests#createWritesAnAttributeUnderTheSchemaNameand#updateWritesAnAttributeUnderTheSchemaNamegiveLastName,FirstName,__name__and a guarded__password__, and check the file: the schema's element holds the value, and no element has the given spelling. Reads skip empty elements, so a search would not show a stray or empty element.createrefusesLastName(No values provided for required attribute: lastname),__name__(__NAME__ must be defined.) and__password__(No values provided for required attribute: __PASSWORD__), and writes an emptyfirstname.updateleaveslastname,firstname,__NAME__and__PASSWORD__as they were.XMLHandlerReloadTests#renameIntoATakenNameLeavesTheEntryAndTheFileAloneruns with__NAME__and with__name__. On master the__name__row is not refused.XMLHandlerReloadTests#renameIntoATakenNameWithABadAttributeIsRefusedForTheAttributegivesupdatea taken__NAME__first and an attribute the schema does not have second. It expectsData field: no-such-attribute is not supported.and an unchanged file. On master it getsAlreadyExistsException.XMLHandlerReloadTests#createAndUpdateRefuseAnAttributeAlikegets four rows in another case: a valuelessLastName, a blankLASTNAME,LastName=["A", "B"]and a blank__name__. Each expects the message in the schema's spelling from both operations. On master the messages nameLastNameorLASTNAME, andcreaterefuses the blank__name__with__NAME__ must be defined.The row's attribute now replaces the new account's attribute of the same name in any case, not only in exactly the same case.XMLHandlerReloadTests#rejectedUpdateLeavesTheEntryAndTheFileAlonegets anIS-DELETED=truerow that expectsis-deleted is not updatable.XMLHandlerReloadTests#createRefusesAttributesWithoutANamegivescreatenull, then a set whose only name is a valueless__name__, then one whose only name is__name__with an empty list. All three expect__NAME__ must be defined.All three pass on master. Without the null check on the value of the attribute thatAttributeUtil.findreturns, the second gets aNullPointerException; without theisEmptycheck, the third getsNo values provided for required attribute: __NAME__.XMLHandlerIndexTests#attributesWhoseNamesDifferOnlyInCaseAreWrittenApartcopies the test XSD with an optionalLastNamenext to the requiredlastname. It creates an account with both and updates another with both, and expects each value in its own element. Without the exact lookup, both operations refuse the pair as given twice. On mastercreatewritesOther-carolinto<ri:lastname>and leaves<ri:LastName>empty.XMLHandlerIndexTests#clearingAnOptionalNameIsRefusednow also clears the name with__name__, on a schema where__NAME__is optional, and expectsParameter '__NAME__' must not be blank.On master nothing is thrown. The test also fails ifcheckAttributecompares the given name instead of the schema's with__NAME__.XMLHandlerReloadTests#createAndUpdateRefuseAnAttributeGivenTwicegives[lastname, LastName],[LastName, lastname],[email=a, email=b]and[__NAME__, __name__]tocreate, inside a valid new account, and toupdate. It expects the duplicate message from both, with the file and the entry in memory unchanged. On mastercreateaccepts three of the pairs and refuses[LastName, lastname]as missinglastname, andupdateaccepts all four.createKeepsOneOfTwoSameNamedAttributes:createkeptemail=bofemail=aandemail=b.repeatedAttributeKeepsTheLastValue:updateappliedlastname=A, thenlastname=B.LASTNAMErow ofcreateRefusesAMissingRequiredAttribute.XMLFilterTranslatorTests.setUpClassgave its first accountemailas two attributes, whichcreatenow refuses. It now gives oneemailattribute with both values. No test of the class reads them.These tests were run against master's
XMLHandlerImpl: 21 runs fail, all of them named above. The module runs 386 tests with no failures, 366 on master.Not covered
<ri:LastName>that the old code wrote into existing files stay there, asupdateremoves only the element the schema spells. Reads skip them. A filter, though, names the element as it spells the attribute, soLastName=Xstill finds an entry by its stray<ri:LastName>X</ri:LastName>, and finds none by thelastnamethe new code writes. A filter in another case than the schema's misses schema-spelled elements on master too: XML connector: a filter on an attribute name in another case than the schema's finds nothing #218.LASTNAMEnext tolastnameandLastName, goes to whichever of the two the framework's case-insensitive map holds. Reads return only one of the two, as before.