Skip to content

Commit

Permalink
Added validations, tests, fixed bug. (#101)
Browse files Browse the repository at this point in the history
* Added validations, tests, fixed bug.

* Fix versions supported in e2e test

* Removed unnecessary comment

* fixed e2e tests & updated contributing.md

* updated contributing.md

---------

Co-authored-by: gustaaf jongbloed <[email protected]>
Co-authored-by: ram <[email protected]>
  • Loading branch information
3 people authored May 3, 2023
1 parent acc2245 commit d4e3e56
Show file tree
Hide file tree
Showing 13 changed files with 353 additions and 11 deletions.
14 changes: 12 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ a. Start the following docker containers separately in multiple terminals.
> `docker run --name localstack -p 127.0.0.1:4566:4566 -p 127.0.0.1:4571:4571 --rm localstack/localstack`
b. Start regression tests.
b. Check your `/etc/hosts` file for the following entry. If missing, add it and save.

> `127.0.0.1 localhost`
c. Check if the following URLs are accessible from your browser. You should see something load up.

> https://127.0.0.1:9260/services/Version
> https://127.0.0.1:9320/services/Version
d. Start regression tests.

> `yarn test:e2e`
> `yarn test:e2e` - This will run all the E2E tests.
> `yarn test:e2e <test case>` - This will only run a specific test case matching the directory name under `__tests__/e2e`.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Serverless Framework plugin to manage APIs on [WSO2 API Manager](https://wso2.co
> | `visibility` | Supports `PUBLIC` (Visible to everyone) and `PRIVATE` (Visible to current tenant). Kept in the api for backwards compatibility. Please use fields for `subscriberVisibility` and `publisherVisibility`. | `PUBLIC` |
> | `subscriberVisibility` | Visibility of the API in the developer portal. Supports `PUBLIC` (Visible to everyone) and `PRIVATE` (Visible to current tenant) and `RESTRICTED` (Visible to it's tenant domain and only to the user roles that you specify. You should provide the roles in the `subscriberVisibilityRoles`.). | `RESTRICTED` |
> | `subscriberVisibilityRoles` | The user roles that are able to access the API in Store. Only applicable in combination with `subscriberVisibility`. | `admin` |
> | `publisherVisibility` | Visibility of the API in the publisher portal. Supports `PRIVATE` (Visible to all publishers/creators) and `RESTRICTED` (Visible to publishers/creators with the roles that you specify. You should provide the roles in the `publisherVisibilityRoles`.). | `RESTRICTED` |
> | `publisherVisibility` | Visibility of the API in the publisher portal. Supports `PRIVATE` (Visible to all logged in publishers/creators) and `RESTRICTED` (Visible to logged in publishers/creators with the roles that you specify. You should provide the roles in the `publisherVisibilityRoles`.). | `RESTRICTED` |
> | `publisherVisibilityRoles` | The user roles that are able to access the API in Store. Only applicable in combination with `publisherVisibility`. | `admin` |
> | `backend` | Supports `http` and `jms` backends. <br> Note: One API definition supports only one backend. | |
> | `backend.http.baseUrl` | Your HTTP backend base URL. <br><br> It supports: <br> a. **URL** - Any valid HTTP URL. <br> b. **AWS CloudFormation Export** - Exported value must contain a valid HTTP URL. | `https://backend:port/123` <br> (or) <br> `!ImportValue xx` |
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/e2e/e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('E2E on WSO2 API Manager', () => {
}
else if (testCase.split('-')[0] === 'invalid') {
console.log("Running.. ", chalk.bold.underline(`🌧 ${wso2ApimVersion}/${testCase}`), "\n\n", procDeploy.output.toString());
expect(procDeploy.output.toString().includes('NOT OK'));
expect(procDeploy.output.toString()).toMatch(/NOT OK/);
}

const procRemove = spawnSync('sls',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
service: serverless-wso2-apim
provider:
name: aws
stackName: ${env:STACK_NAME}
deploymentBucket:
name: ${env:TEST_ID_NORMALIZED}
plugins:
- serverless-localstack
- serverless-deployment-bucket
- "../../../../src"

#⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇ Modify the configuration below to suit your test case.
#⬇⬇⬇ START HERE ⬇⬇⬇⬇ Help: https://github.com/ramgrandhi/serverless-wso2-apim#configuration-reference
#⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇ For a full list of env vars that you can use, refer `src/__tests__/e2e/e2e.test.js`
custom:
wso2apim:
enabled: true
host: ${env:WSO2_HOST}
port: ${env:WSO2_PORT}
user: ${env:WSO2_USER}
pass: ${env:WSO2_PASS}
gatewayEnv: ${env:WSO2_ENV}
apidefs:
- name: ${env:TEST_ID}-1
description: ${env:TEST_ID}-1
rootContext: /${env:TEST_ID}-1
version: "1"
publisherVisibility: "PRIVAT"
backend:
http:
baseUrl: "https://baseUrl"
maxTps: 10
tags:
- ${env:TEST_ID}-1
swaggerSpec:
swagger: "2.0"
info:
title: ${env:TEST_ID}-1
version: "v1"
contact:
name: ${env:TEST_ID}-1
email: ${env:TEST_ID}-1
paths:
post:
responses:
"201":
description: Created
x-auth-type: "None"

# Optionally, add your other AWS provider-specific resources below.
# Make sure there is at least one resource listed below, otherwise stack deployment would fail.
resources:
Resources:
Topic:
Type: AWS::SNS::Topic
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ custom:
- ${env:TEST_ID}-1
swaggerSpec:
swagger: "2.0"
pathsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:
info:
title: ${env:TEST_ID}-1
version: "v1"
contact:
name: ${env:TEST_ID}-1
email: ${env:TEST_ID}-1
paths:
/*:
post:
responses:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ custom:
- ${env:TEST_ID}-1
swaggerSpec:
swagger: "2.0"
pathsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:
info:
title: ${env:TEST_ID}-1
version: "v1"
contact:
name: ${env:TEST_ID}-1
email: ${env:TEST_ID}-1
paths:
/*:
post:
responses:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
service: serverless-wso2-apim
provider:
name: aws
stackName: ${env:STACK_NAME}
deploymentBucket:
name: ${env:TEST_ID_NORMALIZED}
plugins:
- serverless-localstack
- serverless-deployment-bucket
- "../../../../src"

#⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇ Modify the configuration below to suit your test case.
#⬇⬇⬇ START HERE ⬇⬇⬇⬇ Help: https://github.com/ramgrandhi/serverless-wso2-apim#configuration-reference
#⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇ For a full list of env vars that you can use, refer `src/__tests__/e2e/e2e.test.js`
#
custom:
wso2apim:
enabled: true
host: ${env:WSO2_HOST}
port: ${env:WSO2_PORT}
user: ${env:WSO2_USER}
pass: ${env:WSO2_PASS}
gatewayEnv: ${env:WSO2_ENV}
apidefs:
- name: ${env:TEST_ID}-1
description: ${env:TEST_ID}-1
rootContext: /${env:TEST_ID}-1
version: "1"
publisherVisibility: "RESTRICTED"
publisherVisibilityRoles:
- "admin"
- "non-existing-role"
backend:
http:
baseUrl: "https://baseUrl"
maxTps: 10
tags:
- ${env:TEST_ID}-1
swaggerSpec:
swagger: "2.0"
info:
title: ${env:TEST_ID}-1
version: "v1"
contact:
name: ${env:TEST_ID}-1
email: ${env:TEST_ID}-1
paths:
/*:
post:
responses:
"201":
description: Created
x-auth-type: "None"

# Optionally, add your other AWS provider-specific resources below.
# Make sure there is at least one resource listed below, otherwise stack deployment would fail.
resources:
Resources:
Topic:
Type: AWS::SNS::Topic
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
service: serverless-wso2-apim
provider:
name: aws
stackName: ${env:STACK_NAME}
deploymentBucket:
name: ${env:TEST_ID_NORMALIZED}
plugins:
- serverless-localstack
- serverless-deployment-bucket
- "../../../../src"

#⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇ Modify the configuration below to suit your test case.
#⬇⬇⬇ START HERE ⬇⬇⬇⬇ Help: https://github.com/ramgrandhi/serverless-wso2-apim#configuration-reference
#⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇ For a full list of env vars that you can use, refer `src/__tests__/e2e/e2e.test.js`
custom:
wso2apim:
enabled: true
host: ${env:WSO2_HOST}
port: ${env:WSO2_PORT}
user: ${env:WSO2_USER}
pass: ${env:WSO2_PASS}
gatewayEnv: ${env:WSO2_ENV}
apidefs:
- name: ${env:TEST_ID}-1
description: ${env:TEST_ID}-1
rootContext: /${env:TEST_ID}-1
version: "1"
subscriberVisibility: "RESTRICTED"
subscriberVisibilityRoles:
- "admin"
publisherVisibility: "PRIVATE"
publisherVisibilityRoles: "admin"
backend:
http:
baseUrl: "https://baseUrl"
maxTps: 10
tags:
- ${env:TEST_ID}-1
swaggerSpec:
swagger: "2.0"
info:
title: ${env:TEST_ID}-1
version: "v1"
contact:
name: ${env:TEST_ID}-1
email: ${env:TEST_ID}-1
paths:
/*:
post:
responses:
"201":
description: Created
x-auth-type: "None"

# Optionally, add your other AWS provider-specific resources below.
# Make sure there is at least one resource listed below, otherwise stack deployment would fail.
resources:
Resources:
Topic:
Type: AWS::SNS::Topic
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
service: serverless-wso2-apim
provider:
name: aws
stackName: ${env:STACK_NAME}
deploymentBucket:
name: ${env:TEST_ID_NORMALIZED}
plugins:
- serverless-localstack
- serverless-deployment-bucket
- "../../../../src"

#⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇ Modify the configuration below to suit your test case.
#⬇⬇⬇ START HERE ⬇⬇⬇⬇ Help: https://github.com/ramgrandhi/serverless-wso2-apim#configuration-reference
#⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇ For a full list of env vars that you can use, refer `src/__tests__/e2e/e2e.test.js`
custom:
wso2apim:
enabled: true
host: ${env:WSO2_HOST}
port: ${env:WSO2_PORT}
user: ${env:WSO2_USER}
pass: ${env:WSO2_PASS}
gatewayEnv: ${env:WSO2_ENV}
apidefs:
- name: ${env:TEST_ID}-1
description: ${env:TEST_ID}-1
rootContext: /${env:TEST_ID}-1
version: "1"
subscriberVisibility: "PRIVAT"
backend:
http:
baseUrl: "https://baseUrl"
maxTps: 10
tags:
- ${env:TEST_ID}-1
swaggerSpec:
swagger: "2.0"
info:
title: ${env:TEST_ID}-1
version: "v1"
contact:
name: ${env:TEST_ID}-1
email: ${env:TEST_ID}-1
paths:
/*:
post:
responses:
"201":
description: Created
x-auth-type: "None"

# Optionally, add your other AWS provider-specific resources below.
# Make sure there is at least one resource listed below, otherwise stack deployment would fail.
resources:
Resources:
Topic:
Type: AWS::SNS::Topic
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ plugins:
#⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇ Modify the configuration below to suit your test case.
#⬇⬇⬇ START HERE ⬇⬇⬇⬇ Help: https://github.com/ramgrandhi/serverless-wso2-apim#configuration-reference
#⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇ For a full list of env vars that you can use, refer `src/__tests__/e2e/e2e.test.js`
#
custom:
wso2apim:
enabled: true
Expand All @@ -25,8 +26,8 @@ custom:
description: ${env:TEST_ID}-1
rootContext: /${env:TEST_ID}-1
version: "1"
subscriberVisibility: "RESTRICTED"
subscriberVisibilityRoles:
publishVisibility: "RESTRICTED"
publisherVisibilityRoles:
- "admin"
- "non-existing-role"
backend:
Expand All @@ -37,7 +38,13 @@ custom:
- ${env:TEST_ID}-1
swaggerSpec:
swagger: "2.0"
pathsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:
info:
title: ${env:TEST_ID}-1
version: "v1"
contact:
name: ${env:TEST_ID}-1
email: ${env:TEST_ID}-1
paths:
/*:
post:
responses:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ custom:
- ${env:TEST_ID}-1
swaggerSpec:
swagger: "2.0"
pathsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:
info:
title: ${env:TEST_ID}-1
version: "v1"
contact:
name: ${env:TEST_ID}-1
email: ${env:TEST_ID}-1
paths:
/*:
post:
responses:
Expand Down
Loading

0 comments on commit d4e3e56

Please sign in to comment.