Mock server to collaborate with shunit2β .
mockake startmockake statusmockake --config ./test_case1.yaml setmockake flushmockake --config ./test_case2.yaml setmockake stopor
mockake --config ./test_case1.yaml startmockake stopAfter mockake start you also may interact with a server by API:
curl http://127.0.0.1:8088/-/status β mockake statuscurl -X POST http://127.0.0.1:8088/-/set --data-binary @example_test_ok.yaml β mockake setcurl -X POST http://127.0.0.1:8088/-/flush β mockake flushcurl --head http://127.0.0.1:8088/-/stop β mockake stopPort also may be rewritten:
Usage of mockake:
-bind string
Default address to serve incoming requests (default ":8088")
-config string
Configuration file
It's easy as eat a :banana:, just look an example:
example.sh βΒ code to testexample_test_(.*).yaml β sets used in mock serverexample_test.sh β test with assertsBefore you execute ./example_test.sh make shure that all dependencies installed:
An additional tool to test HTTP resources.
httptest -c .httptest.yamlExample:
@options resolve=work.company.com:443/10.10.0.10:443
@test url=https://work.company.com/api code=401
@test url=https://work.company.com/api/status body.regex=ok headers.x-powered-by.prefix=PHP code.exact=200
@test url=https://work.company.com/ code=200 tls=1.1
@test url=https://work.company.com/ code=200 tls=1.2
@test url=https://work.company.com/ code=200 tls=1.3
@test url=https://work.company.com/ code=200 tls=1.4
or
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: work-company-route
spec:
# @options resolve=work.company.com:443/10.10.0.10:443
hosts:
- work.company.com
http:
- match:
# @test url=https://work.company.com/api code=401
# @test url=https://work.company.com/api/status body.regex=ok headers.x-powered-by.prefix=PHP code.exact=200
- uri:
prefix: /api
route:
- destination:
host: api
- route:
# @test url=https://work.company.com/ code=200 tls=1.1
# @test url=https://work.company.com/ method=POST code=200 tls=1.2
# @test url=https://work.company.com/ method=DELETE code=200 tls=1.3
# @test url=https://work.company.com/ method=OPTIONS code=200 tls=1.4
- destination:
host: ui
Content type
Image
Digest
Size
11.1 MB
Last updated
over 5 years ago
docker pull leominov/mockake