Skip to content

Commit

Permalink
Add cucumber test for header modifier filter
Browse files Browse the repository at this point in the history
  • Loading branch information
sgayangi committed May 29, 2024
1 parent a498253 commit 1d61ce4
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
id: "api-with-request-and-response-filters"
name: "EmployeeServiceAPI"
basePath: "/request-and-response-filters"
version: "3.14"
type: "REST"
defaultVersion: false
endpointConfigurations:
production:
endpoint: "http://backend:80/anything"
operations:
- target: "/employee"
verb: "GET"
secured: false
scopes: []
operationPolicies:
request:
- policyName: AddHeaders
policyVersion: v1
parameters:
headers:
- name: "Test-Request-Header"
value: "Test-Value"
- policyName: SetHeaders
policyVersion: v1
parameters:
headers:
- name: "Set-Request-Header"
value: "Test-Value"
- policyName: RemoveHeaders
policyVersion: v1
parameters:
headers:
- "Authorization"
response:
- policyName: AddHeaders
policyVersion: v1
parameters:
headers:
- name: "Test-Response-Header"
value: "Test-Value"
- policyName: SetHeaders
policyVersion: v1
parameters:
headers:
- name: "Set-Response-Header"
value: "Test-Value"
- policyName: RemoveHeaders
policyVersion: v1
parameters:
headers:
- "content-type"
- target: "/employee"
verb: "POST"
secured: true
scopes: []
- target: "/employee/{employeeId}"
verb: "PUT"
secured: true
scopes: []
- target: "/employee/{employeeId}"
verb: "DELETE"
secured: true
scopes: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Feature: Test HTTPRoute Filter Header Modifier functionality
Scenario: Test request and response header modification functionality
Given The system is ready
And I have a valid subscription
When I use the APK Conf file "artifacts/apk-confs/request_and_response_filters.apk-conf"
And the definition file "artifacts/definitions/employees_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/request-and-response-filters/3.14/employee/" with body ""
And I eventually receive 200 response code, not accepting
| 401 |
And the response body should contain "\"Test-Request-Header\": \"Test-Value\""
And the response body should contain "\"Set-Request-Header\": \"Test-Value\""
And the response body should not contain "\"Authorization\""
Then the response headers contains key "Set-Response-Header" and value "Test-Value"
Then the response headers contains key "Test-Response-Header" and value "Test-Value"
And the response headers should not contain
| content-type |

Scenario: Undeploy the API
Given The system is ready
And I have a valid subscription
When I undeploy the API whose ID is "api-with-request-and-response-filters"
Then the response status code should be 202


0 comments on commit 1d61ce4

Please sign in to comment.