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

[DX-1780]Generate test for tyk gateway swagger #6760

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ tyk_linux_*
main

/coprocess/*.pb.go-e
tests/schema/node_modules
tests/schema/dashboard.collection.postman.json
tests/schema/filtered.dashboard.swagger.yml
tests/schema/.env
tests/schema/package-lock.json
tests/schema/tmp
2 changes: 1 addition & 1 deletion .redocly.lint-ignore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ swagger.yml:
#/paths/~1tyk~1apis~1oas~1{apiID}/patch/requestBody/content/application~1json/schema
- >-
#/paths/~1tyk~1apis~1oas~1import/post/requestBody/content/application~1json/schema
https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json:
https://raw.githubusercontent.com/TykTechnologies/tyk/refs/heads/master/apidef/oas/schema/3.0.json:
spec:
- '#/id'
- '#/$schema'
Expand Down
12 changes: 6 additions & 6 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ paths:
schema:
items:
allOf:
- $ref: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json
- $ref: https://raw.githubusercontent.com/TykTechnologies/tyk/refs/heads/master/apidef/oas/schema/3.0.json
- $ref: '#/components/schemas/XTykAPIGateway'
type: array
description: List of API definitions in Tyk OAS format.
Expand Down Expand Up @@ -664,7 +664,7 @@ paths:
url: https://localhost:8080
schema:
allOf:
- $ref: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json
- $ref: https://raw.githubusercontent.com/TykTechnologies/tyk/refs/heads/master/apidef/oas/schema/3.0.json
- $ref: '#/components/schemas/XTykAPIGateway'
responses:
"200":
Expand Down Expand Up @@ -802,7 +802,7 @@ paths:
$ref: '#/components/examples/oasExample'
schema:
allOf:
- $ref: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json
- $ref: https://raw.githubusercontent.com/TykTechnologies/tyk/refs/heads/master/apidef/oas/schema/3.0.json
- $ref: '#/components/schemas/XTykAPIGateway'
description: OK
headers:
Expand Down Expand Up @@ -912,7 +912,7 @@ paths:
upstream:
url: https://localhost:8080
schema:
$ref: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json
$ref: https://raw.githubusercontent.com/TykTechnologies/tyk/refs/heads/master/apidef/oas/schema/3.0.json
responses:
"200":
content:
Expand Down Expand Up @@ -1025,7 +1025,7 @@ paths:
url: https://localhost:8080
schema:
allOf:
- $ref: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json
- $ref: https://raw.githubusercontent.com/TykTechnologies/tyk/refs/heads/master/apidef/oas/schema/3.0.json
- $ref: '#/components/schemas/XTykAPIGateway'
responses:
"200":
Expand Down Expand Up @@ -1334,7 +1334,7 @@ paths:
servers:
- url: https://localhost:8080
schema:
$ref: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json
$ref: https://raw.githubusercontent.com/TykTechnologies/tyk/refs/heads/master/apidef/oas/schema/3.0.json
responses:
"200":
content:
Expand Down
121 changes: 121 additions & 0 deletions tests/schema/api_operations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Manage APIs and Policies
testcases:
- name: Delete Policy
steps:
- type: http
method: DELETE
url: http://localhost:3000/api/portal/policies/66d9121d5715ec0715608640
headers:
Authorization: Bearer {{ .bearerToken }}
assertions:
- result.statuscode ShouldBeIn 200 404

- name: Delete API
steps:
- type: http
method: DELETE
url: http://localhost:3000/api/apis/a12b34c56d78e90f1234567890abcdef
headers:
Authorization: Bearer {{ .bearerToken }}
assertions:
- result.statuscode ShouldBeIn 200 404

- name: Create API
steps:
- type: http
method: POST
url: http://localhost:3000/api/apis
headers:
Content-Type: application/json
Authorization: Bearer {{ .bearerToken }}
body: |
{
"api_definition": {
"active": true,
"api_id": "a12b34c56d78e90f1234567890abcdef",
"auth": {
"auth_header_name": "authorization"
},
"definition": {
"key": "version",
"location": "header"
},
"name": "Tyk Test API",
"proxy": {
"listen_path": "/tyk-api-test/",
"strip_listen_path": true,
"target_url": "https://httpbin.org"
},
"use_oauth2": true,
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "Default"
}
}
}
}
}
assertions:
- result.statuscode ShouldEqual 200

- name: Create Policy
steps:
- type: http
method: POST
url: http://localhost:3000/api/portal/policies
headers:
Content-Type: application/json
Authorization: Bearer {{.bearerToken }}
body: |
{
"access_rights": {
"Tyk Test API": {
"allowed_urls": [
{
"methods": [
"GET"
],
"url": "/users"
}
],
"api_id": "a12b34c56d78e90f1234567890abcdef",
"api_name": "Tyk Test API",
"disable_introspection": false,
"versions": [
"Default"
]
}
},
"id": "66d9121d5715ec0715608640",
"_id": "66d9121d5715ec0715608640",
"active": true,
"hmac_enabled": false,
"is_inactive": false,
"key_expires_in": 2592000,
"max_query_depth": -1,
"meta_data": {
"email": "[email protected]",
"user_type": "mobile_user"
},
"name": "Itachi sasuke testing policy items",
"partitions": {
"acl": true,
"complexity": false,
"per_api": false,
"quota": true,
"rate_limit": true
},
"per": 60,
"quota_max": 10000,
"quota_renewal_rate": 3600,
"rate": 1000,
"tags": [
"security"
],
"throttle_interval": 10,
"throttle_retry_limit": 10
}
assertions:
- result.statuscode ShouldEqual 200
16 changes: 16 additions & 0 deletions tests/schema/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "cli-filtering",
"version": "1.0.0",
"description": "ns",
"directories": {
"example": "examples"
},
"scripts": {
"start": "portman --cliOptionsFile=portman-cli-options.json"
},
"author": "",
"license": "ISC",
"dependencies": {
"@apideck/portman": "1.30.7"
}
}
12 changes: 12 additions & 0 deletions tests/schema/portman-cli-options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"local": "../../swagger.yml",
"baseUrl": "http://localhost:8080",
"output": "dashboard.collection.postman.json",
"oaOutput": "filtered.dashboard.swagger.yml",
"includeTests": true,
"syncPostman": false,
"runNewman": true,
"envFile": ".env",
"ignoreCircularRefs": true,
"portmanConfigFile":"portmanconfig.json"
}
Loading
Loading