diegorubin / tshield Goto Github PK
View Code? Open in Web Editor NEWAPI mocks for development and testing
License: MIT License
API mocks for development and testing
License: MIT License
Describe the bug
I took this example, from component-test, but when I hit the API, it doesn't generate the folder correctly with the session and the related files
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expected when running the tests with the name SOLICITANTE of the session, all the referring requestes, would be inside this folder
When a session with 2 objects is activated, and this 2 objects have different params, Tshield always returns the first object.
I'd like to get the object which has more matches. In the following example Tshield always returns the first object of the matching session, while the second object has more params to match.
Scenario: Return correct answer for same path with different params
Given a file to describe "/path/1" path
And in session "multiples-responses-with-different-params"
When this api is accessed throught tshield with params
And this api is accessed throught tshield with params
| key | value |
| param1 | param1_value |
| param2 | param2_value |
| param3 | param3_value |
Then response should be equal "request called with 3 params"
The 'multiples-responses-with-different-params' session has 2 objects:
[
{
"session": "multiples-responses-with-different-params",
"stubs": [
{
"method": "GET",
"path": "/path/1",
"query": {
"param1": "param1_value",
"param2": "param2_value"
},
"response": {
"status": 200,
"headers": {
"content-type": "application/json;charset=UTF-8"
},
"body": "request called with 2 params"
}
},
{
"method": "GET",
"path": "/path/1",
"query": {
"param1": "param1_value",
"param2": "param2_value",
"param3": "param3_value"
},
"response": {
"status": 200,
"headers": {
"content-type": "application/json;charset=UTF-8"
},
"body": "request called with 3 params"
}
}
]}
]
Today all query params are used as record key
Is your feature request related to a problem? Please describe.
Today the exposed port is fixed at 4567
Describe the solution you'd like
Include a option to config file to define the running port
Is your feature request related to a problem? Please describe.
No.
Describe the solution you'd like
Maybe could send to tshield session multiples session names OR not clear session before.
So, I want a user with permission to menu A and can to download something.
Today, I want to have one session with both. But, the it could be two session with self-responsibility.
Is your feature request related to a problem? Please describe.
When using gRPC with VCR and occurs an error, the error is not saved.
Describe the solution you'd like
Save a error file with gRPC error code and description, and return the error to client.
In order to make Tshield compatible with Windows, Tshield cannot create folders and files with '?' (question mark) character in the name.
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
Expected: Tshield get the windows compatibility flag from config file and replace '?' for '%3f' (%3f is the ascii for '?' in Windows-1252 charset).
Is your feature request related to a problem? Please describe.
When using tshield as mock-server it is desirable to disable the option to access external service in some scenarios.
Describe the solution you'd like
It would be nice to have some modes to run tshield:
Normal mode: As it is today, if tshield does not have the requested resource, accesses the external service, writes the resource and returns it to the client, from the second call no longer accesses the external service for that match.
Simulation mode only: tshield responds only to previously recorded resources, if it does not have the requested resource no request is made to the external service
Fallback Mode: Always tries to access the external service and records the response on success, in case of communication failure with the external service returns the previously recorded resource.
Is your feature request related to a problem? Please describe.
As it exists in vcr mode, it allows multiple responses to a stub in matching mode.
Describe the solution you'd like
It should behave like a circular row.
The response attribute should be an array.
Describe the bug
After update tshield from 0.10 to 0.11 on startup it terminate with exception in sessions.rb
registered': undefined local variable or method 'request' for TShield::Controllers::Sessions:Module (NameError)
To Reproduce
Steps to reproduce the behavior:
Traceback
I, [2019-08-29T14:32:10.706933 #32583] INFO -- : == registering /v2/keys/v1/toggles/MeuVivoEmpresas for methods get with action toggles
#<Thread:0x00007fc7e5a7b930@/Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/tshield-0.11.0.0/bin/tshield:8 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
6: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/tshield-0.11.0.0/bin/tshield:8:in `block in <top (required)>'
5: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/tshield-0.11.0.0/lib/tshield/server.rb:42:in `run!'
4: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/tshield-0.11.0.0/lib/tshield/server.rb:23:in `register_resources'
3: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1398:in `register'
2: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1398:in `each'
1: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1400:in `block in register'
/Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/tshield-0.11.0.0/lib/tshield/controllers/sessions.rb:14:in `registered': undefined local variable or method `request' for TShield::Controllers::Sessions:Module (NameError)
Did you mean? require
Traceback (most recent call last):
6: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/tshield-0.11.0.0/bin/tshield:8:in `block in <top (required)>'
5: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/tshield-0.11.0.0/lib/tshield/server.rb:42:in `run!'
4: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/tshield-0.11.0.0/lib/tshield/server.rb:23:in `register_resources'
3: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1398:in `register'
2: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1398:in `each'
1: from /Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1400:in `block in register'
/Users/egarcia/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/tshield-0.11.0.0/lib/tshield/controllers/sessions.rb:14:in `registered': undefined local variable or method `request' for TShield::Controllers::Sessions:Module (NameError)
Did you mean? require
Expected behavior
TShield should start and expose mocks :)
Additional context
$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin18]
Is your feature request related to a problem? Please describe.
Some external integrations are done without waiting for a response, it is desirable to be able to check at least how many times the endpoit has been called and in some scenarios check the request details.
This feature is based on wiremock verify (http://wiremock.org/docs/verifying/)
Describe the solution you'd like
{ "method": "POST", "url": "/resource/to/count" }
{ "count": 4 }
Describe alternatives you've considered
For a first release just the request count option filtering for url match and method would be very good
In TShield exists a resource to transform request before(transform request body) and after(transform server response) but not exists documentation to usage.
Use case: In a project, it was necessary to simulate a cache of addresses. Instead of creating a mock it was used google service to recover real data.
Original flow:
client -> request_service > cache service -> response_service -> client
With TShield:
client -> request_service -> tshield -> before_filter(request_service to google_request) -> google -> after_filter(google_response to response_service) -> response_service -> client
Describe the bug
Using request matching with body attribute pointing to a content file, if that content file doesn't have an empty ending line an error is raised
To Reproduce
docker.tar.gz
Remove the ending line from file tshield/matching/examples/content.json
Expected behavior
Work as designed
Recently I needed to access an endpoint that Tshield exposes via localhost but somehow it needed a CORS configuration and Tshield not supports this yet.
So perhaps would be interesting to this project enable this functionality and allows access from different domains.
Describe the bug
Mapping a similar path to tshield.yml will match wrong domains
To Reproduce
Steps to reproduce the behavior:
domains:
'http://localhost:9092':
name: 'customer-backend'
paths:
- /users
'http://localhost:9090':
name: 'invoice-backend'
paths:
- /secure/users
Expected behavior
A request should be saved in "invoice-backend/secure-users/get/0.content"
Scenario: Save response body for similar paths
Given an api "http://localhost:9092" with path "/users" and name "customer-backend"
And an api "http://localhost:9090" with path "/secure/users" and name "invoice-backend"
When "/users" is accessed throught tshield
And "/secure/users" is accessed throught tshield
Then response should be saved in "customer-backend/users/get/0.content"
And response should be saved in "invoice-backend/secure-users/get/0.content"
Additional context
$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin18]
Request Matching é uma feature comum em muitos mocking / stubbing servers
https://hoverfly.readthedocs.io/en/latest/pages/reference/hoverfly/request_matchers.html
https://hoverfly.readthedocs.io/en/latest/pages/keyconcepts/matching/matching.html
https://github.com/mrak/stubby4node#how-endpoints-are-matched
Essa nova feature deve determinar qual o mock deve ser usado.
Sugestão: usar um Lucene-based approach para determinar qual o request mais próximo para responder a requisição. No ruby existe o Ferret (https://github.com/dbalmain/ferret) que podemos avaliar a possibilidade
Describe the bug
When the end service returns multiple 'set-cookie' headers, the tshiled is able to save them, however, when they're restored and sent to back, the browser recognizes as a unique cookie.
To Reproduce
Perform a stub record/ save from a endpoint that returns multiple 'set-cookie' headers.
Expected behavior
Restore and send back from stub all the cookies sent by original service.
Describe the bug
When the client performs a preflight request (HTTP/ OPTIONS), the tshield sends back the headers 'Access-Control-Allow-Headers' and 'Access-Control-Allow-Methods', that results in error of 'Cross-Origin Resource Sharing (CORS)', once ther first restrict the possibile allowed headers in: Authorization, Content-Type, Accept, X-User-Email, X-Auth-Token; and the second does not inform the allowed methods supported.
To Reproduce
Perform a preflight request (HTTP/ OPTIONS), for a DELETE endpoint, that sends a header not supported.
Expected behavior
Allow the preflight request return status OK (200)
Describe the bug
Counter class count called only with path, but without query params. So, if it has two calls to the same endpoint but with different parameters, it will count two calls instead of one.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.