Skip to content

Supposely unmatched request always default to an expectation #1423

Open
@gbmarc1

Description

@gbmarc1

Describe the issue
I have an openapi spec that creates multiple expectations. When calling an endpoint that does not exist (that does should not match any expectation), I would assume that the mock server would return 404. However, it always returns a reponse of a specific expectation that does NOT match.

For example:
Request:
curl --user name:password -v GET "http://localhost:1080/idontexists"

Response:


*   Trying 127.0.0.1:1080...
* Connected to localhost (127.0.0.1) port 1080 (#0)
* Server auth using Basic with user 'name'
> GET /idontexists HTTP/1.1
> Host: localhost:1080
> Authorization: Basic bmFtZTpwYXNzd29yZA==
> User-Agent: curl/7.83.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 201 Created
< content-type: application/json
< connection: keep-alive
< content-length: 648
<
{
    "fileId" : 0,
    "name" : "some_string_value",
    "projectId" : 0,
    "dataOwnerId" : 0,
    "language" : "some_string_value",
    "territory" : "some_string_value",
    "importType" : "comment",
    "workUnitId" : 0,
    "totalSubmittedData" : 0,
    "totalUniqueData" : 0,
    "createdDatumParts" : 0,
    "createdData" : 0,
    "createdProjectData" : 0,
    "createdWorkUnitData" : 0,
    "createdOnWorkUnitData" : "2018-11-13T20:20:39+00:00",
    "createdOn" : "2018-11-13T20:20:39+00:00",
    "modifiedOn" : "2018-11-13T20:20:39+00:00",
    "expiredOn" : "2018-11-13T20:20:39+00:00",
    "status" : "import-submitted",
    "progress" : 1.5,
    "error" : "some_string_value"
}* Connection #0 to host localhost left intact

The default response comes from a "not supported" operation that is added. It seems that its response becomes the default when not found.

multipart form data is not supported on requestBody, skipping operation:	"v1.datamgmt.projects.projectId.workUnit.workUnitId.workUnitData.files.post"	method:	"POST"	in open api:	

If I remove that operation in the .yaml file, the mock server behaves properly.

MockServer version
I used mockserver/mockserver:mockserver-5.13.2 and mockserver/mockserver:latest and both have the same behaviour.

MockServer Log

{
  "method": "GET",
  "path": "/idontexists",
  "headers": {
    "content-length": [
      "0"
    ],
    "User-Agent": [
      "curl/7.83.1"
    ],
    "Host": [
      "localhost:1080"
    ],
    "Authorization": [
      "Basic bmFtZTpwYXNzd29yZA=="
    ],
    "Accept": [
      "*/*"
    ]
  },
  "keepAlive": true,
  "secure": false,
  "remoteAddress": "172.17.0.1"
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions