-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2473 from CrowleyRajapakse/ai
Adding cucumber test for backend api key
- Loading branch information
Showing
4 changed files
with
312 additions
and
0 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
42 changes: 42 additions & 0 deletions
42
test/cucumber-tests/src/test/resources/artifacts/apk-confs/backend_apikey_auth_conf.yaml
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,42 @@ | ||
--- | ||
name: "BackendAPIKeySecurity" | ||
basePath: "/backend-api-key-security" | ||
version: "3.14" | ||
id: "backend-api-key-test" | ||
type: "REST" | ||
defaultVersion: true | ||
endpointConfigurations: | ||
production: | ||
endpoint: "http://backend:80/anything" | ||
endpointSecurity: | ||
enabled: true | ||
securityType: | ||
secretName: "mysecret" | ||
in: "Header" | ||
apiKeyNameKey: "api-key" | ||
apiKeyValueKey: "apiKey" | ||
operations: | ||
- target: "/employee" | ||
verb: "GET" | ||
secured: true | ||
scopes: [] | ||
- target: "/get" | ||
verb: "GET" | ||
secured: true | ||
scopes: [] | ||
- target: "/post" | ||
verb: "POST" | ||
secured: true | ||
scopes: [] | ||
- target: "/employee" | ||
verb: "POST" | ||
secured: true | ||
scopes: [] | ||
- target: "/employee/{employeeId}" | ||
verb: "PUT" | ||
secured: true | ||
scopes: [] | ||
- target: "/employee/{employeeId}" | ||
verb: "DELETE" | ||
secured: true | ||
scopes: [] |
225 changes: 225 additions & 0 deletions
225
test/cucumber-tests/src/test/resources/artifacts/definitions/backend_apikey_auth_api.json
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,225 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "EmployeeServiceAPI", | ||
"version": "3.14" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://backend:80/anything", | ||
"description": "Server URL", | ||
"variables": {} | ||
} | ||
], | ||
"paths": { | ||
"/employee": { | ||
"get": { | ||
"tags": [ | ||
"employee-controller" | ||
], | ||
"operationId": "getEmployees", | ||
"parameters": [ | ||
{ | ||
"name": "id", | ||
"in": "query", | ||
"required": true, | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "default response", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/components/schemas/Employee" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
"post": { | ||
"tags": [ | ||
"employee-controller" | ||
], | ||
"operationId": "addEmployee", | ||
"requestBody": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Employee" | ||
} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"200": { | ||
"description": "default response", | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Employee" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/get": { | ||
"get": { | ||
"tags": [ | ||
"employee-controller" | ||
], | ||
"operationId": "getEmployees", | ||
"parameters": [ | ||
{ | ||
"name": "id", | ||
"in": "query", | ||
"required": true, | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "default response", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/components/schemas/Employee" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/post": { | ||
"post": { | ||
"tags": [ | ||
"employee-controller" | ||
], | ||
"operationId": "getEmployees", | ||
"parameters": [ | ||
{ | ||
"name": "id", | ||
"in": "query", | ||
"required": true, | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "default response", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/components/schemas/Employee" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/employee/{employeeId}": { | ||
"put": { | ||
"tags": [ | ||
"employee-controller" | ||
], | ||
"operationId": "editEmployee", | ||
"parameters": [ | ||
{ | ||
"name": "employeeId", | ||
"in": "path", | ||
"required": true, | ||
"schema": { | ||
"type": "integer", | ||
"format": "int32" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "default response", | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Employee" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"delete": { | ||
"tags": [ | ||
"employee-controller" | ||
], | ||
"operationId": "deleteEmployee", | ||
"parameters": [ | ||
{ | ||
"name": "employeeId", | ||
"in": "path", | ||
"required": true, | ||
"schema": { | ||
"type": "integer", | ||
"format": "int32" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "default response", | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Employee" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"Employee": { | ||
"type": "object", | ||
"properties": { | ||
"empId": { | ||
"type": "string" | ||
}, | ||
"name": { | ||
"type": "string" | ||
}, | ||
"designation": { | ||
"type": "string" | ||
}, | ||
"salary": { | ||
"type": "number", | ||
"format": "double" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
test/cucumber-tests/src/test/resources/tests/api/BackendAPIKeyAuth.feature
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 @@ | ||
Feature: Backend API Key auth | ||
Scenario: Testing API level Endpoint backend api key auth header | ||
Given The system is ready | ||
And I have a valid subscription | ||
When I use the APK Conf file "artifacts/apk-confs/backend_apikey_auth_conf.yaml" | ||
And the definition file "artifacts/definitions/backend_apikey_auth_api.json" | ||
And make the API deployment request | ||
Then the response status code should be 200 | ||
Then I set headers | ||
|Authorization|bearer ${accessToken}| | ||
And I send "GET" request to "https://default.gw.wso2.com:9095/backend-api-key-security/3.14/employee/" with body "" | ||
And I eventually receive 200 response code, not accepting | ||
|429| | ||
And the response body should contain "\"Api-Key\": \"sampath\"" | ||
|
||
|
||
Scenario Outline: Undeploy API | ||
Given The system is ready | ||
And I have a valid subscription | ||
When I undeploy the API whose ID is "<apiID>" | ||
Then the response status code should be <expectedStatusCode> | ||
|
||
Examples: | ||
| apiID | expectedStatusCode | | ||
| backend-api-key-test | 202 | | ||
|
||
Scenario: Testing undeployed API | ||
Given The system is ready | ||
And I have a valid subscription | ||
Then I set headers | ||
| Authorization | bearer ${accessToken} | | ||
And I send "GET" request to "https://default.gw.wso2.com:9095/backend-api-key-security/3.14/employee/" with body "" | ||
And I eventually receive 404 response code, not accepting | ||
| 200 | | ||
|