Skip to content

Commit

Permalink
Cypress gwa cli (#896)
Browse files Browse the repository at this point in the history
* upd controllers

* add openid as api auth

* add namespace creation

* fix build error

* fix required field for create namespace

* upd roles for tsoa user

* filter out inactive environments from drop down (#825)

* Fix BCDC Datasets out of sync (#837)


---------

Co-authored-by: James Elson <james.elson@gov.bc.ca>
Co-authored-by: Elson9 <Elson9@users.noreply.github.com>

* add description to namespace

* use name for namespace

* gwa-cli for namespace, login and config

* upg http-proxy

* move around proxy

* Update oauth2-proxy config

* use displayName for namespace

* have create namespace using application json

* change from lodash to just-kebab-case for shared idp client id

* change from lodash to just-kebab-case for shared idp client id

* service account failing with cannot read properties of null

* order the namespaces in the api

* upd feed worker put bubble up child results

* upd feed worker put bubble up child results

* Added scenarios for GWA-CLI and update existing scenarios as per new gateway layout

* make issuer env details optional

* make issuer env details optional

* upd the batch default array

* upds for handling delete namespace

* upd delete ns for issuers

* chg delete ns put back gw deletion

* Updated/added scenarios for GWA command and as per new namespace creation workflow

* Updated Cypress Tests as per GWA CLI and new namespace creation logic

* Added workflow to install binary file

* Update step in the workflow file

* update steps in the workflow

* Update steps to Build Executable Binary

* Update in the workflow file

* Update step of Checkout souce-repo in the workflow file

* Update step in the workflow file

* Update step to install go in the workflow file

* Code cleanup, update test name, added test for keycloak role and invalid JWK Public key format

* Added scenarios for gwa generate config and update github action to build, install gwa cli

* Update the workflow file to build gwa binary

* Add cypress as branch regex to trigger the execution on the feature branch

* update branch for GWA API step

* Update steps in the workflow to build and install gwa cli

* Corrected steps for access permission

* Add GWA help step in workflow and update api.json test file

* Check for gwa command through cypress

* Update workflow and e2e dockerfile

* Update workflow file

* Modified step to build go binary file

* Corrected error in the workflow file

* Updated step to build go binary file

* Update step to build go binary

* Commented the GWA help step

* Commented step to set up just and create issue in github

* update command to build go binary file in the workflow file

* Update steps to download and build go

* Added go tidy command

* Updated the build file in the workflow file

* Downgrade go to 1.16

* Update action go setup

* Updated Github action workflow to install GWA CLI executable binary and run cypress test

* Update the workflow file

* Update in the workflow step and removed unused code

* Uncomment test in cypress config file

* Change assertion type from equals to contains

* Increased time out in cy exec command

* Remove wait statement inside cy exec command

* Re order the spec files for execution in CI/CD

* Update Test scenarios/specs order and added test for zenhub#887

* Update steps for API Key request access and gwa generate confin

* update workflow file to check cypress test on remote VM

* 1)Added scenarios to verify invalid namespace name
2) Replace 'gwa publish'to 'gwa apply'
3)Made changes as per PR Review comments

* Update API directory test data in the file

* Remove commented code and debugger statements

* remove branch name

---------

Co-authored-by: ikethecoder <ikethecoder@copeconsulting.ca>
Co-authored-by: Elson9 <Elson9@users.noreply.github.com>
Co-authored-by: James Elson <james.elson@gov.bc.ca>
Co-authored-by: Niraj Patel <niraj.patel@gov.bc.ca>
  • Loading branch information
5 people committed Sep 15, 2023
1 parent f025fbd commit a836efd
Show file tree
Hide file tree
Showing 96 changed files with 3,130 additions and 1,436 deletions.
38 changes: 36 additions & 2 deletions .github/workflows/aps-cypress-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Deploy Cypress and Execute Tests

on:
push:
branches: ['test', 'cypress/*']
branches: ['test', 'cypress*']

env:
DASHBOARD_PROJECT_ID: ${{ secrets.CY_DASHBOARD_PRJ_ID }}
Expand All @@ -20,14 +20,47 @@ jobs:
steps:
- name: Build GWA API Image
run: |
git clone https://github.com/bcgov/gwa-api.git -b master
git clone https://github.com/bcgov/gwa-api.git
cd gwa-api/microservices/gatewayApi
docker build -t gwa-api:e2e .
- name: Checkout Portal
uses: actions/checkout@v2

- name: Checkout Source Repository
run: |
git clone https://github.com/bcgov/gwa-cli.git
cd gwa-cli
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.20.x'

- name: create .env file
run: |
cd gwa-cli
echo "GWA_API_HOST=api-services-portal-feature-gwa-cli-v2.apps.silver.devops.gov.bc.ca" >> .env
echo "GWA_CLIENT_ID=gwa-cli" >> .env
- name: Debug
run: echo ${{ github.workspace }}

- name: Build
run: |
cd gwa-cli
go clean
go build -o ${{ github.workspace }}/e2e/gwa
- uses: actions/upload-artifact@v2
with:
name: binary-artifact
path: ${{ github.workspace }}/e2e

- name: Build Docker Images
run: |
docker-compose build
- name: Spin up API Services Portal and Run E2E Tests
run: |
export CY_EXECUTION_ENV=${{ env.EXECUTION_ENV }}
Expand All @@ -40,6 +73,7 @@ jobs:
export CY_REPO_URL=${{ env.GIT_REPO_URL }}
export CY_COMMIT_AUTHOR_EMAIL=$(git --no-pager show -s --format='%ae' ${{ env.GIT_COMMIT_SHA }})
docker-compose up -d
- name: Execute Tests & Clean Up
run: |
while true; do
Expand Down
3 changes: 2 additions & 1 deletion e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ FROM cypress/included:12.4.0
WORKDIR /e2e

RUN apt-get -y update; apt-get -y install curl

COPY cypress.config.ts /e2e
COPY tsconfig.json /e2e
COPY package.json /e2e
COPY package-lock.json /e2e
COPY entrypoint.sh /tmp
COPY gwa /usr/local/bin
ADD cypress /e2e/cypress

RUN npm install


ENTRYPOINT ["npm", "run", "cy:run:html"]
5 changes: 3 additions & 2 deletions e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ export default defineConfig({
'./cypress/tests/10-*/*.ts',
'./cypress/tests/11-*/*.ts',
'./cypress/tests/12-*/*.ts',
'./cypress/tests/13-*/*.ts',
'./cypress/tests/13-*/*.ts',
'./cypress/tests/14-*/*.ts',
'./cypress/tests/15-*/*.ts',
'./cypress/tests/16-*/*.ts'
'./cypress/tests/16-*/*.ts',
'./cypress/tests/17-*/*.ts'
]
return config
},
Expand Down
150 changes: 128 additions & 22 deletions e2e/cypress/fixtures/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,36 @@
"title": "Planning and Innovation Division"
},
"orgName": "ministry-of-health",
"expectedScope": ["Dataset.Manage", "GroupAccess.Manage", "Namespace.Assign"],
"expectedScope": [
"Dataset.Manage",
"GroupAccess.Manage",
"Namespace.Assign"
],
"expectedNamespace": {
"name": "newplatform",
"orgUnit": "planning-and-innovation-division"
"name": "gw-3a443",
"orgUnit": "planning-and-innovation-division",
"enabled": true
},
"expectedRoles": {
"organization-admin": {
"label": "Organization Administrator",
"permissions": [
{
"resourceType": "organization",
"scopes": [
"GroupAccess.Manage",
"Namespace.Assign",
"Dataset.Manage"
]
},
{
"resourceType": "namespace",
"scopes": [
"Namespace.View"
]
}
]
}
},
"body": {
"name": "ministry-of-health",
Expand All @@ -24,7 +50,9 @@
"id": "janis@idir",
"email": "janis@testmail.com"
},
"roles": ["organization-admin"]
"roles": [
"organization-admin"
]
}
]
}
Expand All @@ -44,7 +72,10 @@
"order": 0,
"isPublic": true,
"isComplete": true,
"tags": ["tag1", "tag2"]
"tags": [
"tag1",
"tag2"
]
}
},
"apiDirectory": {
Expand All @@ -65,18 +96,25 @@
"title": "Dataset for Test API",
"isInCatalog": "false",
"isDraft": "false",
"tags": ["gateway", "kong"],
"tags": [
"gateway",
"kong"
],
"organization": "ministry-of-health",
"organizationUnit": "planning-and-innovation-division"
},
"directory": {
"name": "api-auto-test-product",
"title": "API Auto Test Product",
"notes": "API Gateway Services provides a way to configure services on the API Gateway, manage access to APIs and get insight into the use of them.",
"license_title": "Access Only",
"view_audience": "Government",
"security_class": "LOW-PUBLIC",
"tags": ["gateway", "kong", "openapi"],
"name": "gwa-auto-test-product",
"title": "GWA Auto Test Product",
"notes": "For Test Purpose",
"license_title": "Open Government Licence - British Columbia",
"view_audience": "Public",
"security_class": "PUBLIC",
"record_publish_date": "2017-09-05",
"tags": [
"tag1",
"tag2"
],
"organization": {
"name": "ministry-of-health",
"title": "Ministry of Health"
Expand All @@ -87,12 +125,18 @@
},
"products": [
{
"name": "API Auto Test Product",
"id": "2",
"name": "GWA Auto Test Product",
"environments": [
{
"name": "dev",
"active": true,
"flow": "kong-api-key-acl"
"flow": "kong-api-key-only"
},
{
"name": "test",
"active": true,
"flow": "client-credentials"
}
]
}
Expand All @@ -105,7 +149,11 @@
"license_title": "Access Only",
"view_audience": "Government",
"security_class": "LOW-PUBLIC",
"tags": ["gateway", "kong", "openapi"],
"tags": [
"gateway",
"kong",
"openapi"
],
"organization": {
"name": "ministry-of-health",
"title": "Ministry of Health"
Expand Down Expand Up @@ -174,6 +222,46 @@
],
"isShared": true
},
"shared_gwa": {
"name": "Gold Shared IdP",
"description": "A Shared IdP for Teams to use",
"flow": "client-credentials",
"clientAuthenticator": "client-secret",
"mode": "auto",
"environmentDetails": [
{
"environment": "test",
"issuerUrl": "http://keycloak.localtest.me:9080/auth/realms/master",
"clientRegistration": "managed",
"clientId": "gwa-api",
"clientSecret": "18900468-3db1-43f7-a8af-e75f079eb742"
}
],
"isShared": true
},
"shared_gwa_publish": {
"name": "Gold Shared IdP",
"description": "A Shared IdP for Teams to use",
"flow": "client-credentials",
"mode": "auto",
"clientAuthenticator": "client-secret",
"environmentDetails": [
{
"clientId": "gwa-api",
"clientRegistration": "managed",
"clientSecret": "****",
"environment": "test",
"issuerUrl": "http://keycloak.localtest.me:9080/auth/realms/master",
"exists": true
}
],
"clientRoles": [],
"clientMappers": [],
"availableScopes": [],
"resourceScopes": [],
"isShared": true,
"apiKeyName": "X-API-KEY"
},
"shared_IDP_body": {
"name": "Sample Shared IdP new",
"description": "A Shared IdP for Teams to use",
Expand All @@ -194,8 +282,12 @@
"shared_IDP_inheritFrom": {
"environmentDetails": [],
"mode": "auto",
"clientRoles": ["administrator"],
"clientMappers": ["test-audience"],
"clientRoles": [
"administrator"
],
"clientMappers": [
"test-audience"
],
"flow": "client-credentials",
"clientAuthenticator": "client-secret",
"name": "my-auth-client-secret-1",
Expand All @@ -218,8 +310,12 @@
"clientId": "ap-my-auth-client-secret-1-test"
}
],
"clientRoles": ["administrator"],
"clientMappers": ["test-audience"],
"clientRoles": [
"administrator"
],
"clientMappers": [
"test-audience"
],
"isShared": false,
"apiKeyName": "X-API-KEY",
"inheritFrom": {
Expand Down Expand Up @@ -282,11 +378,21 @@
"name": "CredentialIssuer.Admin"
}
],
"permDomains": [".api.gov.bc.ca"],
"permDomains": [
".api.gov.bc.ca"
],
"permDataPlane": "local.dataplane",
"permProtectedNs": "deny",
"org": "ministry-of-health",
"orgUnit": "planning-and-innovation-division"
},
"userDefinedNamespace": {
"name": "gwanelatform",
"displayName": "Test for GWA test"
},
"inValidNamespace": {
"name": "gwa",
"displayName": "Test for GWA test"
}
}
}
}
Loading

0 comments on commit a836efd

Please sign in to comment.