Closed jameslive closed 6 years ago
The problem is caused by providing both httpForward
and httpResponse
, however, each expectation only has a single action.
The expectation you submitted is as follows:
{
"httpRequest": {
"path": "/path/tomatch"
},
"httpForward": {
"host": "host.com",
"port": 443,
"scheme": "HTTPS"
},
"httpResponse": {
"headers": [
{
"name": "Content-Type",
"values": [
"application/json; charset=utf-8"
]
},
{
"name": "Cache-Control",
"values": [
"no-cache, no-store"
]
}
]
}
}
Clearly the error message returned was confusing and was not pointing you in the correct direction. So I have fixed the error so in future it will be as follows:
1 error:
- oneOf of the following must be specified ["httpForward", "httpResponseTemplate",
"httpResponseObjectCallback", "httpResponseClassCallback", "httpResponse",
"httpForwardTemplate", "httpForwardObjectCallback", "httpForwardClassCallback",
"httpOverrideForwardedRequest", "httpError"] but 2 found
This is the expectation it posted:
| "string" : "{\"httpRequest\":{\"path\":\"/api/search/list\"},\"httpForward\":{\"host\":\"host.com\",\"port\":443,\"scheme\":\"HTTPS\"},\"httpResponse\":{\"headers\":[{\"name\":\"Content-Type\",\"values\":[\"application/json; charset=utf-8\"]},{\"name\":\"Cache-Control\",\"values\":[\"no-cache, no-store\"]}]}}",
but what i actually sent was:
mockServerClient('mockserver', 1080)
.mockAnyResponse({
"httpRequest": {
"path": "/api/list"
},
"httpForward": {
"host": "host.com",
"port": 443,
"scheme": "HTTPS"
}
})
.then(
function () {
console.log('expectation created');
},
function (error) {
console.log(error);
}
);
I think that is the bug here and I am still getting it
Thank you for the quick reply on my previous issue/request... Now I am trying to set this expectation and using the docker version of mockserver
I am using mockserver-client-node to set these two properties in my expectation, but I keep getting this error back: (edited paths below)
2018-02-01 19:29:53,653 ERROR o.m.m.HttpStateHandler Exception processing { mockserver | "method" : "PUT", mockserver | "path" : "/expectation", mockserver | "headers" : { mockserver | "Content-Type" : [ "application/json; charset=utf-8" ], mockserver | "Host" : [ "localhost:1080" ], mockserver | "Connection" : [ "close" ], mockserver | "content-length" : [ "278" ] mockserver | }, mockserver | "keepAlive" : false, mockserver | "secure" : false, mockserver | "body" : { mockserver | "type" : "STRING", mockserver | "string" : "{\"httpRequest\":{\"path\":\"/path/tomatch\"},\"httpForward\":{\"host\":\"host.com\",\"port\":443,\"scheme\":\"HTTPS\"},\"httpResponse\":{\"headers\":[{\"name\":\"Content-Type\",\"values\":[\"application/json; charset=utf-8\"]},{\"name\":\"Cache-Control\",\"values\":[\"no-cache, no-store\"]}]}}", mockserver | "contentType" : "text/plain; charset=utf-8" mockserver | } mockserver | } mockserver | java.lang.IllegalArgumentException: 1 error: mockserver | - oneOf of the following must be specified "httpResponseTemplate" "httpForwardTemplate" "httpClassCallback" "httpError" "httpObjectCallback" mockserver | at org.mockserver.client.serialization.ExpectationSerializer.deserializeArray(ExpectationSerializer.java:110) ~[mockserver-netty-jar-with-dependencies.jar:na] mockserver | at org.mockserver.mock.HttpStateHandler.handle(HttpStateHandler.java:218) ~[mockserver-netty-jar-with-dependencies.jar:na] mockserver | "type" : "string"
Thanks for any help, seems like I am doing everything correctly based on the examples, but I am missing something I guess..