Uploaded image for project: 'OpenIDM'
  1. OpenIDM
  2. OPENIDM-7536

Relationship fields are not returned on an "upsert" update

    Details

      Description

      1) Start default openidm project

      2) Create a role:

      curl -u openidm-admin:openidm-admin -X PUT -k https://localhost:8443/openidm/managed/role/foobar --data '{"name": "foobar", "description": "foobar"}' -H 'Content-type: application/json'
      

      3) Create a user which is explicitly granted that role:

      curl -u openidm-admin:openidm-admin -X PUT -k "https://localhost:8443/openidm/managed/user/jfeasel?_fields=*,roles" --data '{"userName": "jfeasel","givenName":"Jake","sn":"Feasel", "mail": "jfeasel@example.com", "roles": [{"_ref": "managed/role/foobar"}]}' -H 'Content-type: application/json'
      

      Note that this CREATE request includes "roles" amongst the "_fields" list. As a result, the "roles" property is included in the response content (for example):

      {"_id":"jfeasel","_rev":"1","roles":[{"_ref":"managed/role/foobar","_refProperties":{"_id":"3f02ebc8-e8b7-4d54-b085-665d77cd1250","_rev":"1"}}],"userName":"jfeasel","givenName":"Jake","sn":"Feasel","mail":"jfeasel@example.com","accountStatus":"active"}
      

      4) Update the same user, removing the explicitly-granted role:

      curl -u openidm-admin:openidm-admin -X PUT -k "https://localhost:8443/openidm/managed/user/jfeasel?_fields=*,roles" --data '{"userName": "jfeasel","givenName":"Jake","sn":"Feasel", "mail": "jfeasel@example.com", "roles": []}' -H 'Content-type: application/json'
      

      Note that this UPDATE request also includes "roles" in the "_fields" list. The expected response would be to see "roles" included in the response, in this case with an empty array value. Instead, we see this:

      {"_id":"jfeasel","_rev":"2","userName":"jfeasel","givenName":"Jake","sn":"Feasel","mail":"jfeasel@example.com"}
      

      5) Update the user again, with the same request as was used in step 3:

      curl -u openidm-admin:openidm-admin -X PUT -k "https://localhost:8443/openidm/managed/user/jfeasel?_fields=*,roles" --data '{"userName": "jfeasel","givenName":"Jake","sn":"Feasel", "mail": "jfeasel@example.com", "roles": [{"_ref": "managed/role/foobar"}]}' -H 'Content-type: application/json'
      

      Expect same response (with updated _rev) as was returned to the CREATE request in step 3. Instead, the "roles" property is omitted from the response.

      Note that if the requests include an 'If-Match: rev' header, the proper response is produced. It appears that this incorrect response is only produced when using "upsert" requests.

        Attachments

          Activity

            People

            • Assignee:
              dhogan Dirk Hogan
              Reporter:
              jake.feasel Jake Feasel
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: