Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Internal Server Error (500) if predicate attributes have null value. #53

Merged
merged 1 commit into from
Nov 5, 2014

Conversation

zedar
Copy link
Contributor

@zedar zedar commented Nov 5, 2014

After upgrading to node v.0.11.14, attributes passed to predicate
operators could have null values. In that case, NullPointerException is
thrown and HTTP error 500 is returned.

Test cases:

  • query attribute is missing in HTTP call, while it is expected in predicate:

    curl -X DELETE http://localhost:4545/customer

    "equals": {
    "method": "DELETE",
    "path": "/customer",
    "query": {
    "id": "1001"
    }
    }

  • query attribute is not expected in predicate and is not provided in HTTP call:

    curl -X PUT -d@data.json http://localhost:4545/customer

    "equals": {
    "method": "PUT",
    "path": "/customer"
    }

After upgrading to node v.0.11.14, attributes passed to predicate
operators could have null values. In that case, NullPointerException is
thrown and HTTP error 500 is returned.

Test cases:

* *query* attribute is missing in HTTP call, while it is expected in predicate:

    curl -X DELETE http://localhost:4545/customer

    "equals": {
      "method": "DELETE",
      "path": "/customer",
      "query": {
        "id": "1001"
      }
    }

* *query* attribute is not expected in predicate and is not provided in HTTP call:

  curl -X PUT -d@data.json http://localhost:4545/customer

  "equals": {
    "method": "PUT",
    "path": "/customer"
  }
bbyars added a commit that referenced this pull request Nov 5, 2014
Fix Internal Server Error (500) if predicate attributes have null value.
@bbyars bbyars merged commit a4b13a1 into bbyars:master Nov 5, 2014
@bbyars
Copy link
Owner

bbyars commented Nov 5, 2014

Good catch - thanks again

@zedar
Copy link
Contributor Author

zedar commented Nov 5, 2014

Brandon, what do you think about adding functionality to return HTTP 404 if
there is no predicate matching?
Now mountebank returns empty response and HTTP 200. What could be a little
bit confusing.

Regards,
/Robert

On 5 November 2014 14:46, Brandon Byars notifications@github.com wrote:

Good catch - thanks again


Reply to this email directly or view it on GitHub
#53 (comment).

@bbyars
Copy link
Owner

bbyars commented Nov 7, 2014

Hi - sorry for the slow response (swamped at work). It's definitely a tradeoff, but I think I prefer leaving the 200 because one of my goals was to have as many of the imposter elements as possible be optional and have reasonable defaults. It's possible, for example, to have stubs but no predicates because predicates simply don't matter for your scenario because the system under test only calls the web service once in a well known way, and predicates would just complicate the test setup.

Thanks for the idea, and please keep sending them!
-Brandon

@zedar
Copy link
Contributor Author

zedar commented Nov 7, 2014

I see, but if you have stub without predicates it will much. So there is no
empty response. Then HTTP 200 is OK.
Rather, I was thinking about HTTP 404 if no stub matches.
Now if predicates do not match and there is stub with with empty predicate,
HTTP 200 with empty response is returned. Could be confusing.

/Robert

On 7 November 2014 16:46, Brandon Byars notifications@github.com wrote:

Hi - sorry for the slow response (swamped at work). It's definitely a
tradeoff, but I think I prefer leaving the 200 because one of my goals was
to have as many of the imposter elements as possible be optional and have
reasonable defaults. It's possible, for example, to have stubs but no
predicates because predicates simply don't matter for your scenario because
the system under test only calls the web service once in a well known way,
and predicates would just complicate the test setup.

Thanks for the idea, and please keep sending them!
-Brandon


Reply to this email directly or view it on GitHub
#53 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants