mockserver: Adding httpForward expectation with JavaScript API fails

I’m trying to add a simple httpForward expectation using JavaScript API (v. 5.3.0) but it fails with an error message : oneOf of the following must be specified “httpResponseTemplate” “httpForwardTemplate” “httpClassCallback” “httpError” “httpObjectCallback”

The reason is mockServerClient.mockAnyResponse() adds all expectations pre-defined default response headers. Although i want to add a forward expectation with:

    {
        "httpRequest": {
          "path": "/some/path"
        },
        "httpForward": {
          "host": "mock-server.com",
          "port": 8080,
          "scheme": "HTTP"
        }
      }

the generated request with JavaScript API is:

[{
		"httpRequest" : {
			"path" : "/some/path"
		},
		"httpForward" : {
			"host" : "mock-server.com",
			"port" : 8080,
			"scheme" : "HTTP"
		},
		"httpResponse" : {
			"headers" : [{
					"name" : "Content-Type",
					"values" : ["application/json; charset=utf-8"]
				}, {
					"name" : "Cache-Control",
					"values" : ["no-cache, no-store"]
				}
			]
		}
	}
]

which is, i think, not allowed.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16

Most upvoted comments

makeRequest(host, port, “/expectation”, expectation);