Repository navigation
[#192] Check the attributes given to create and update with one method, so create refuses an attribute the schema does not have - #216
Merged
maximthomas merged 4 commits intoOct 30, 2026
Conversation
…ge that names the attribute
… that create can share
…pdate does, and refuse one the schema does not have
…ly for __UID__, and say how create keeps names that differ in case
- findAttributeValue refuses a Map value with "X contains values of illegal type",
as valuesAreExpectedClass did for an attribute typed java.util.Map: the value is
written as {k=v} text and createInstantiatedObject reads that back as null.
- create picks a random uid only when the schema has an attribute named exactly
__UID__, the only element the write loop puts the uid into. objAttributes is
now case-insensitive, so containsKey matched a schema element __uid__.
- The comment in create and the javadoc of createKeepsOneOfTwoSameNamedAttributes
say how AttributeUtil.toMap keeps two names that differ only in case (OpenIdentityPlatform#212).
- findAttributeValueRefusesANullValue gets a FirstName=[null] row that pins the
schema's spelling in the message.
maximthomas
marked this pull request as ready for review
October 30, 2026 08:52
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 #192.
Closes #190.
XMLHandlerImpl.createwent through the attributes of the schema, andupdatewent through the attributes it was given. Each had its own copy of the attribute checks, and the copies had drifted apart in order and in wording.createalso never looked at a given attribute that the schema does not have, so it dropped that attribute silently and returned a uid. The check on the value type was another split:updateof an optional attribute usedvaluesAreExpectedClass, which callsgetClass()on each value, so a[null]value failed with aNullPointerException(#190). On the other pathsfindAttributeValuerefused the same[null]with<name> contains invalid type. Value(s) should be of type java.lang.String.Now both operations check each given attribute with one method,
checkAttribute(attribute, objAttributes, change). TheChangeargument,CREATEorUPDATE, decides only the operation's own schema rule. The checks run in this order, and the first that fails throwsIllegalArgumentException:Data field: X is not supported.X is not a creatable field.oncreate,X is not updatable.onupdate.AttributeTypeUtil.findAttributeValuereads the values once, so a guarded value is decrypted once. It now refuses a null value, first or not, withX contains a null value, before the type check. A value of the wrong type still getsX contains invalid type. Value(s) should be of type <class>.__NAME__whatever the XSD says: no values giveNo values provided for required attribute: X, and a blank value givesParameter 'X' must not be blank.Data field: X is not multivalued can not have more than one value. The double space is in the existingupdatemessage, andcreatenow uses the same text.createchecks every attribute in the map thatAttributeUtil.toMapbuilds from its input. That map is case-insensitive: of two names that differ only in case it keeps the first spelling and the last attribute's values.createthen refuses a required schema attribute that was not given, withNo values provided for required attribute: X. Only after both passes does it look up the name withentryExists. It writes the values the checks returned, in schema order, as before.valuesAreExpectedClassis removed.AttributeBuilderaccepts only values whose class is exactly one ofFrameworkUtil's supported types, or anyMap. For a non-null value that is not aMap, the exact-class test was therefore the same asfindAttributeValue'sisInstancetest.findAttributeValuenow refuses aMapvalue with the oldX contains values of illegal type: the connector writes it as{k=v}text and reads that text back as null. Apart fromMap, the two tests differed only on null.Changes in behaviour
createrefuses an attribute that the schema does not have, withData field: X is not supported.Before, it dropped the attribute and created the entry.createrequest that carries a property the provisioner's objectTypes list as creatable but the XSD lacks now fails this way. Before, the property was lost. Remove the property from the provisioner or add it to the XSD.createuses theupdatemessages:Missing required field: XbecomesNo values provided for required attribute: X.Attribute field: X is not multivalued and can not contain more than one valuebecomes theData field: …message above.updateof an optional attribute with a value of the wrong type:X contains values of illegal typebecomesX contains invalid type. Value(s) should be of type <class>.[null]value getsX contains a null valueon every path. Before, it got aNullPointerExceptionon an optional-attributeupdate, and the type message everywhere else.createwith a blank__NAME__:Uid value must not be blank!becomesParameter '__NAME__' must not be blank.createchecks the attributes before it looks up the name. A taken name together with a bad or missing attribute now gets theIllegalArgumentExceptionabout the attribute instead ofAlreadyExistsException. With no data file, a bad attribute gets thatIllegalArgumentExceptionbeforeData file does not exists.createreports the first one in the order of aHashMap, not the first in schema order.Mapclass such asjava.util.HashMapgetsX contains values of illegal typeoncreateandupdate. Before, aHashMapvalue was written as text that reads back as null. An attribute typedjava.util.Mapgot the same message before.createignored it. For example,IS-DELETED=truenow getsIS-DELETED is not a creatable field., andFirstName=[null]now getsfirstname contains a null value. Such an attribute is still not written (XML connector: create and update accept an attribute name in another case, then lose its value #212).Tests
AttributeTypeUtilTest#findAttributeValueRefusesANullValuehas three rows,firstname=[null],firstname=["a", null]andFirstName=[null], for the schema attributefirstname. All three expectfirstname contains a null value, in the schema's spelling. On master all three getfirstname contains invalid type. Value(s) should be of type java.lang.String.AttributeTypeUtilTest#findAttributeValueRefusesAMapValuegives aHashMapvalue to an attribute typedjava.util.Mapand to one typedjava.util.HashMap. Both expectsettings contains values of illegal type. On masterfindAttributeValuereturns{k=v}for both.XMLHandlerReloadTests#rejectedUpdateLeavesTheEntryAndTheFileAlonegets three new rows:lastname=[null],firstname=[null]andemail=["a@example.com", null]. On master the first gets the type message and the other two aNullPointerException. Theage="12"row now expectsage contains invalid type. Value(s) should be of type java.lang.Integer.XMLHandlerReloadTests#createAndUpdateRefuseAnAttributeAlikehas nine rows: an unknown attribute, a valuelesslastname, a blanklastname, a blank__NAME__,lastname=5,age="12",firstname=[null],email=["a@example.com", null]andlastname=["A", "B"].create, where the row's attribute replaces the same-named attribute of a valid new account.updateof an existing entry.create: the unknown attribute is accepted, the valuelesslastnamegetsMissing required field: lastname, the blank__NAME__getsUid value must not be blank!, and the twolastnamevalues get theAttribute field: …message.XMLHandlerReloadTests#eachOperationAppliesItsOwnRule:createrefusesavg-wage(not creatable) and acceptsaccount-created-timestamp.updaterefusesaccount-created-timestamp(not updatable) and acceptsavg-wage.XMLHandlerReloadTests#createRefusesAMissingRequiredAttributecreates the taken namealicewith nolastname, and then withLASTNAMEin place oflastname. Both expectNo values provided for required attribute: lastname, and the file must be unchanged. On master both getAlreadyExistsException.XMLHandlerReloadTests#createKeepsOneOfTwoSameNamedAttributes:createwithemail=aandemail=bwrites onlyb. The test calls the handler; the framework'sCreateImplrefuses this pair before it reaches the connector. The test passes on master.XMLHandlerIndexTests#clearingTheOptionalNameOfAnEntryWithoutUidIsRefusednow also creates a uid-less__GROUP__with a blank__NAME__,""and" ", on a schema where__NAME__is optional. It expectsParameter '__NAME__' must not be blank.On master it getsUid value must not be blank!.CreateEntryTests#twoSecretPinValuesAreRefusedAsNotMultivaluedexpects the new message. The commented-out expected messages inCreateEntryTestsandUpdateEntryTestsare updated to the new texts; those tests check only the exception class.Each of these mutants fails at least one test:
isInstance;Mapcheck removed;isCreateableandisUpdateableswapped inChange;entryExistsmoved between the two check passes ofcreate;|| Name.NAMEdropped;__NAME__kept forupdateonly.createKeepsOneOfTwoSameNamedAttributespins the last-wins result. It does not catch a check loop that goes through the given set instead of the map, because that loop also keeps the last value.The module runs 366 tests with no failures, 345 on master.
Not covered
LASTNAMEdoes not stand in forlastname.[lastname=L, LASTNAME=X]writesXintolastname,[EMAIL=a, email=b]writes no email, and[LASTNAME=X, lastname=L]is refused becauselastnameis missing. With two spellings of__NAME__, the taken-name check uses the first and the file gets the last. Master behaves the same way (XML connector: create and update accept an attribute name in another case, then lose its value #212). The framework'sCreateImplrefuses two attributes with exactly the same name.findAttributeValuename the attribute as the schema spells it. The other messages use the caller's spelling.