Sign inSign up

zadoev/httpserverstub

By zadoev

•Updated over 3 years ago

Http server with api to define expected http requests and responses.

Image
0

1.1K

zadoev/httpserverstub repository overview

⁠Stub http server with api to control responses and validate expectations

Made for own usage, i'm tired to find smth simple. I found good things in java, but mvn failed to build it. Some python soft failed with py3 compatibilyti in httplib and another strange things happened.

sources at https://github.com/zadoev/httpserverstub⁠

⁠Usage

Http requests examples done with https://github.com/jkbrzt/httpie⁠ tool

⁠Pull image
docker pull zadoev/httpserverstub
⁠Run container
docker run --name=stubby -p 8181:8181 -d zadoev/httpserverstub

Or

docker run --name=stubby -p YOURLOCALPORT:8181 -d zadoev/httpserverstub
⁠Write expectations
http POST 127.0.0.1:8181/ X-Stuby-Control:expect request:='{ "path": "/path", "method": "GET", "headers" : {}}' response:='{"body": "body response", "status": 301, "headers": {}}'

This command sends POST http query to http://127.0.0.1:8181/⁠ with json data:

   {
       "request": {
           "headers": {}, 
           "method": "GET", 
           "path": "/path"
       }, 
       "response": {
           "body": "body response",  //this http response body will be send on matched http query
           "headers": {},  // not works in this version
           "status": 301 // response http status for matched request 
       }
   }
⁠Make http calls
http GET 127.0.0.1:8181/path
⁠Validate
http POST 127.0.0.1:8181/ X-Stuby-Control:assert

HTTP/1.1 200 OK
Content-Length: 1
Content-Type: text/plain; charset=utf-8
Date: Thu, 10 Sep 2015 05:24:53 GMT
⁠Validate when requests history does not match expectations
http POST 127.0.0.1:8181/ X-Stuby-Control:assert

HTTP/1.1 500 Internal Server Error
Content-Length: 25  
Content-Type: text/plain; charset=utf-8
Date: Thu, 10 Sep 2015 05:26:24 GMT
No match for: GET /path

More information at https://github.com/zadoev/httpserverstub⁠

Tag summary

Content type

Image

Digest

sha256:11ca3977d…

Size

213.9 MB

Last updated

about 11 years ago

docker pull zadoev/httpserverstub