This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TT-6703] Added integration tests using Venom framework (#520)
* Add test suit for json valiation * Rewrite test * Add readme * Add executor for applying manifests * Fix indentation * commiting * commiting * Fix header transform tests * reverting-original-changes-in-crds.yaml-file * Fix circuit breaker tests * Fix blacklist tests * Fix request transform test * Remove tests for cache plugins * Add samples in venom-tests folder * Remove readme file * Update make file * Remove venom tests from test-all target for now * Try to run venom tests in GithubActions * Fix check * Do not run tests on PR * Update changelog * Delete duplicate tests * Delete duplicate sample * Remove comments from sample file Co-authored-by: Pranshu Singh <pranshusingh@Pranshus-MacBook-Pro.local>
- Loading branch information
1 parent
4e839b0
commit c4b8507
Showing
19 changed files
with
586 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
venom-tests/QA-949-api-Circuit-Breaker-Enforced-Timeouts.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Test Availability Circuit Breaker and Enforced Timeouts | ||
testcases: | ||
- name: Create API | ||
steps: | ||
- type: applyManifests | ||
filename: "samples/httpbin_timeout.yaml" | ||
assertions: | ||
- result.code ShouldEqual 0 | ||
|
||
- name: Test with Enforced Timeouts Plugin | ||
steps: | ||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin-timeout-breaker/delay/3 | ||
assertions: | ||
- result.statuscode ShouldEqual 504 | ||
- result.bodyjson.error ShouldContainSubstring Upstream service reached hard timeout | ||
|
||
- name: Test with Circuit Breaker Plugin | ||
steps: | ||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin-timeout-breaker/status/500 | ||
assertions: | ||
- result.statuscode ShouldEqual 500 | ||
|
||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin-timeout-breaker/status/500 | ||
assertions: | ||
- result.statuscode ShouldEqual 500 | ||
|
||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin-timeout-breaker/status/500 | ||
assertions: | ||
- result.statuscode ShouldEqual 500 | ||
|
||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin-timeout-breaker/status/500 | ||
assertions: | ||
- result.statuscode ShouldEqual 500 | ||
|
||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin-timeout-breaker/status/500 | ||
assertions: | ||
- result.statuscode ShouldEqual 503 | ||
- result.bodyjson.error ShouldContainSubstring Service temporarily unavailable | ||
|
||
- name: Delete API | ||
steps: | ||
- type: exec | ||
script: kubectl delete -f ../config/samples/httpbin_timeout.yaml | ||
assertions: | ||
- result.code ShouldEqual 0 | ||
|
28 changes: 28 additions & 0 deletions
28
venom-tests/QA-950-api-Headers-injection-request-response-add-remove.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Test Header injection for response and resquest | ||
testcases: | ||
- name: Create API | ||
steps: | ||
- type: applyManifests | ||
filename: "samples/httpbin_global-headers.yaml" | ||
assertions: | ||
- result.code ShouldEqual 0 | ||
|
||
- name: Test with Request and Response Headers add and remove | ||
steps: | ||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin-global-headers/get | ||
assertions: | ||
- result.statuscode ShouldEqual 200 | ||
- result.bodyjson.headers ShouldNotBeEmpty | ||
- result.bodyjson.headers.foo-req ShouldEqual my-foo | ||
- result.bodyjson.headers.bar-req ShouldEqual my-bar | ||
- result.headers.foo ShouldEqual Bar | ||
- result.headers.Server ShouldBeEmpty | ||
|
||
- name: Delete API | ||
steps: | ||
- type: exec | ||
script: kubectl delete -f ../config/samples/httpbin_global-headers.yaml | ||
assertions: | ||
- result.code ShouldEqual 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Test Whitelist Endpoint Designer | ||
testcases: | ||
- name: Create API | ||
steps: | ||
- type: applyManifests | ||
filename: "samples/httpbin_whitelist.yaml" | ||
assertions: | ||
- result.code ShouldEqual 0 | ||
|
||
- name: Test with Security Allowlist | ||
steps: | ||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin/get | ||
assertions: | ||
- result.statuscode ShouldEqual 200 | ||
|
||
- name: Delete API | ||
steps: | ||
- type: exec | ||
script: kubectl delete -f ../config/samples/httpbin_whitelist.yaml | ||
assertions: | ||
- result.code ShouldEqual 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Test Blacklist Endpoint Designer | ||
testcases: | ||
- name: Create API | ||
steps: | ||
- type: applyManifests | ||
filename: "samples/httpbin_blacklist.yaml" | ||
assertions: | ||
- result.code ShouldEqual 0 | ||
|
||
- name: Test with Security Blocklist | ||
steps: | ||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin/get | ||
assertions: | ||
- result.statuscode ShouldEqual 403 | ||
- result.bodyjson.error ShouldContainSubstring Requested endpoint is forbidden | ||
|
||
- name: Test request to non-block paths is successful | ||
steps: | ||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin/anything | ||
assertions: | ||
- result.statuscode ShouldEqual 200 | ||
|
||
- name: Delete API | ||
steps: | ||
- type: exec | ||
script: kubectl delete -f ../config/samples/httpbin_blacklist.yaml | ||
assertions: | ||
- result.code ShouldEqual 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Test Ignore Endpoint Designer | ||
testcases: | ||
- name: Create API | ||
steps: | ||
- type: applyManifests | ||
filename: "samples/httpbin_ignored.yaml" | ||
assertions: | ||
- result.code ShouldEqual 0 | ||
|
||
- name: Test with Security Ignorelist | ||
steps: | ||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin/get | ||
assertions: | ||
- result.statuscode ShouldEqual 200 | ||
|
||
- name: Delete API | ||
steps: | ||
- type: exec | ||
script: kubectl delete -f ../config/samples/httpbin_ignored.yaml | ||
assertions: | ||
- result.code ShouldEqual 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Test Method Transform Plugin | ||
testcases: | ||
- name: Create API | ||
steps: | ||
- type: applyManifests | ||
filename: "samples/httpbin_method_transform.yaml" | ||
assertions: | ||
- result.code ShouldEqual 0 | ||
|
||
- name: Test Tyk can change method of a request using Method Transform Plugin | ||
steps: | ||
- type: http | ||
method: POST | ||
url: http://localhost:8080/transform/anything | ||
assertions: | ||
- result.statuscode ShouldEqual 200 | ||
|
||
- name: Delete API | ||
steps: | ||
- type: exec | ||
script: kubectl delete -f ../bdd/custom_resources/transform/method.yaml | ||
assertions: | ||
- result.code ShouldEqual 0 |
35 changes: 35 additions & 0 deletions
35
venom-tests/QA-958-api-transform-request-response-body.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Test Body Transform Plugin | ||
testcases: | ||
- name: Create API | ||
steps: | ||
- type: applyManifests | ||
filename: "samples/httpbin_transform.yaml" | ||
assertions: | ||
- result.code ShouldEqual 0 | ||
|
||
- name: Test Tyk can change Body of a request using Body Transform Plugin | ||
steps: | ||
- type: http | ||
method: POST | ||
url: http://localhost:8080/httpbin-transform/anything | ||
body: '{ | ||
"foo": "test" | ||
}' | ||
assertions: | ||
- result.statuscode ShouldEqual 200 | ||
- result.bodyjson.json.bar ShouldEqual test | ||
|
||
- name: Test Tyk can change Body of a response using Body Transform Plugin | ||
steps: | ||
- type: http | ||
method: GET | ||
url: http://localhost:8080/httpbin-transform/xml | ||
assertions: | ||
- result.statuscode ShouldEqual 200 | ||
|
||
- name: Delete API | ||
steps: | ||
- type: exec | ||
script: kubectl delete -f ../config/samples/httpbin_transform.yaml | ||
assertions: | ||
- result.code ShouldEqual 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Test Json Validation Plugin | ||
testcases: | ||
- name: Create API | ||
steps: | ||
- type: applyManifests | ||
filename: "samples/httpbin_json_schema_validation.yaml" | ||
assertions: | ||
- result.code ShouldEqual 0 | ||
|
||
- name: Test with invalid request | ||
steps: | ||
- type: http | ||
url: http://localhost:8080/httpbin/get | ||
body: '{ | ||
"userName": "b", | ||
"age": 0 | ||
}' | ||
assertions: | ||
- result.statuscode ShouldEqual 422 | ||
|
||
- name: Test with valid request | ||
steps: | ||
- type: http | ||
url: http://localhost:8080/httpbin/get | ||
body: '{ | ||
"userName": "burak", | ||
"age": 2 | ||
}' | ||
assertions: | ||
- result.statuscode ShouldEqual 200 | ||
|
||
- name: Delete API | ||
steps: | ||
- type: exec | ||
script: kubectl delete -f ../config/samples/httpbin_json_schema_validation.yaml | ||
assertions: | ||
- result.code ShouldEqual 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
executor: applyManifests | ||
input: | ||
filename: {} | ||
steps: | ||
- type: exec | ||
script: | | ||
kubectl apply -f '{{.input.filename}}' | ||
sleep 20 | ||
assertions: | ||
- result.code ShouldEqual 0 | ||
output: | ||
code: '{{.result.code}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apiVersion: tyk.tyk.io/v1alpha1 | ||
kind: ApiDefinition | ||
metadata: | ||
name: httpbin-blacklist | ||
spec: | ||
name: httpbin-blacklist | ||
use_keyless: true | ||
protocol: http | ||
active: true | ||
proxy: | ||
target_url: http://httpbin.org/ | ||
listen_path: /httpbin | ||
strip_listen_path: true | ||
version_data: | ||
default_version: Default | ||
not_versioned: true | ||
versions: | ||
Default: | ||
name: Default | ||
use_extended_paths: true | ||
paths: | ||
black_list: [] | ||
ignored: [] | ||
white_list: [] | ||
extended_paths: | ||
black_list: | ||
- ignore_case: true | ||
method_actions: | ||
GET: | ||
action: "no_action" | ||
code: 200 | ||
data: "" | ||
headers: {} | ||
path: "/get" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apiVersion: tyk.tyk.io/v1alpha1 | ||
kind: ApiDefinition | ||
metadata: | ||
name: httpbin-global-headers | ||
spec: | ||
name: httpbin-global-headers | ||
use_keyless: true | ||
protocol: http | ||
active: true | ||
org_id: acme.com | ||
proxy: | ||
target_url: http://httpbin.org | ||
listen_path: /httpbin-global-headers | ||
strip_listen_path: true | ||
response_processors: | ||
- name: header_injector | ||
version_data: | ||
default_version: Default | ||
not_versioned: true | ||
versions: | ||
Default: | ||
name: Default | ||
use_extended_paths: true | ||
paths: | ||
black_list: [] | ||
ignored: [] | ||
white_list: [] | ||
global_headers: | ||
foo-req: my-foo | ||
bar-req: my-bar | ||
global_headers_remove: | ||
- hello | ||
global_response_headers: | ||
Foo: Bar | ||
global_response_headers_remove: | ||
- Server |
Oops, something went wrong.