Uploaded image for project: 'RAML Module Builder'
  1. RAML Module Builder
  2. RMB-513

PgUtil.post returned Location is not a URI

    XMLWordPrintable

Details

    • CP: Roadmap backlog
    • Core: Platform

    Description

      It returns the UUID of the new item which is not the same as a location URI:

      https://tools.ietf.org/html/rfc7231#section-7.1.2
      https://tools.ietf.org/html/rfc3986#section-4.2
      https://tools.ietf.org/html/rfc3986#section-5.4 (Reference Resolution Examples)

      This, most likely will require a new PGUtil.post with a separate "prefix" parameter.

      This test fails .. in MyItemsApiTest

      @Test
        void post() {
          JsonObject foo = new JsonObject().put("id", randomUuid()).put("name", "foo");
          JsonObject bar = new JsonObject().put("id", randomUuid()).put("name", "bar");
          JsonObject baz = new JsonObject().put("id", randomUuid()).put("name", "baz'");
          JsonObject [] jsonObjects = { foo, bar, baz };
      
          for (JsonObject jsonObject : jsonObjects) {
            given(r).body(jsonObject.encode()).
            when().post("/myitems").
            then().statusCode(201).header("Location", startsWith("/myitems"));
          }
      ...
      

      Expected location header:

      Location: http://localhost:9230/myitems/528bd1cb-676a-4c15-838a-652afe1f1c1c
      

      or (complete path)

      Location: /myitems/528bd1cb-676a-4c15-838a-652afe1f1c1c
      

      or (last path segment + slash + UUID)

      Location: myitems/528bd1cb-676a-4c15-838a-652afe1f1c1c
      

      Actual location header:

      Location: 528bd1cb-676a-4c15-838a-652afe1f1c1c
      

      This relative URI resolves to this wrong absolute URI: http://localhost:9230/528bd1cb-676a-4c15-838a-652afe1f1c1c

      The Location, obviously, has not been used in much client software because the UUID is also returned in the body as "id" property. The error was seen by coincidence with mod-configuration which has a test that uses returned Location header.

      For most endpoints we use the collection rtype that declares to return a correct Location header: https://github.com/folio-org/raml/blob/raml1.0/rtypes/collection.raml#L51

      TestRail: Results

        Attachments

          Issue Links

            Activity

              People

                Unassigned Unassigned
                adam Adam Dickmeiss (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:

                  TestRail: Runs

                    TestRail: Cases