Skip to content

Commit 00556ce

Browse files
authored
Merge pull request #1036 from bcgov/test
Create Latest Release
2 parents 73d0b1b + a9958fd commit 00556ce

File tree

16 files changed

+471
-38
lines changed

16 files changed

+471
-38
lines changed

e2e/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ Install Cypress on your local machine by following [these instructions](https://
3535
- Clone the API Service Portal repository
3636
- Run `./e2e $ npm i` to install all the dependencies
3737

38+
### Test data dependencies
39+
40+
Many tests cannot be run independently because they depend on state established by other tests. These dependencies are [documented](test-data-dependencies.md) to assist in running tests selectively.
41+
3842
### Running Cypress Locally
3943

40-
- `./e2e/cypress.json` contains the web app config. Update the file to use local or dev version of the portal for executing the tests
44+
- `./e2e/cypress.config.ts` contains the web app config. Update the file to use local or dev version of the portal for executing the tests
4145

42-
- Recommendation is to use local version of portal. Use `docker-compose` to create local development environment
46+
- Recommendation is to use local version of portal. Use `docker compose` to create local development environment
4347

4448
#### Cypress Test Runner
4549

@@ -52,14 +56,14 @@ Install Cypress on your local machine by following [these instructions](https://
5256

5357
### Docker Compose
5458

55-
- Run `docker-compose up` to spin up a local development environment, which includes Cypress as one of the services and it executes all the tests and generates the HTML report
56-
- Run `docker-compose down` to tear down the environment
59+
- Run `docker compose up` to spin up a local development environment, which includes Cypress as one of the services and it executes all the tests and generates the HTML report
60+
- Run `docker compose down` to tear down the environment
5761

5862
#### GitHub Actions
5963

60-
- Any new commit pushed to `util/*automation*` branch triggers job (`.github/workflows/aps-cypress-e2e.yaml`) and it spawns all the services including cypress to execute the test suite
64+
- Any new commit pushed to a `cypress*` branch or `test`, triggers the job (`.github/workflows/aps-cypress-e2e.yaml`) and it spawns all the services including Cypress to execute the test suite
6165

62-
- The test results would be uploaded to `https://www.cypress.io/dashboard/`
66+
- The test results would be uploaded to `https://www.cypress.io/dashboard/`, as well as attached as an artifact on the GitHub Action run.
6367

6468
## 3. Cypress on Windows
6569

@@ -85,7 +89,7 @@ WSL 2 or your local machine are prefaced with `WSL` and `LM` respectively in the
8589

8690
### `WSL`: Build and Run Dev Environment
8791

88-
- Inside the `api-services-portal` directory, build and run the application by running `docker-compose up` at the project root.
92+
- Inside the `api-services-portal` directory, build and run the application by running `docker compose up` at the project root.
8993

9094
### `LM`: Install E2E Testing Dependencies
9195

@@ -97,13 +101,13 @@ WSL 2 or your local machine are prefaced with `WSL` and `LM` respectively in the
97101

98102
## 4. Creating Tests
99103

100-
After you run `npm run cy:open`, the Cypress console will open. Before continuing, ensure the `Electron` browser is selected from the drop-down list of available browsers (top-right corner of the Cypress test runner).
104+
After you run `npm run cy:open`, the Cypress console will open. Before continuing, ensure the `Edge` browser is selected from the drop-down list of available browsers (top-right corner of the Cypress test runner).
101105

102106
Each test file defined in the `./e2e/cypress/tests` directory will be visible. Click on a test in order to run all test cases in that file. A new browser window will open and you will see your tests executed sequentially.
103107

104108
### Test File Naming Convention and Location
105109

106-
- Test files follow this naming convention: `<num>-<test-name>.spec.ts`. (e.g., `01-create-api.spec.ts`)
110+
- Test files follow this naming convention: `<num>-<test-name>.cy.ts`. (e.g., `01-create-api.cy.ts`)
107111
- Store the test files in the `./e2e/cypress/tests` directory.
108112

109113
### Test File Structure

e2e/cypress/fixtures/apiowner.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,5 +782,14 @@
782782
},
783783
"activityAt": "2022-09-20T20:37:30.570Z"
784784
}
785-
]
785+
],
786+
"twoTieredHidden": {
787+
"product": {
788+
"name": "Two Tiered Hidden Product",
789+
"serviceName": "two-tier-service",
790+
"environment": {
791+
"name": "dev"
792+
}
793+
}
794+
}
786795
}

e2e/cypress/fixtures/common-testdata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,8 @@
7878
"apiTest": {
7979
"namespace": "gw-c3f31",
8080
"delete_namespace": "testplatform"
81+
},
82+
"twoTieredHidden": {
83+
"namespace": "two-tier-hidden"
8184
}
8285
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
kind: Namespace
2+
name: two-tier-hidden
3+
displayName: two-tier-hidden Display Name
4+
---
5+
kind: GatewayService
6+
name: two-tier-service-dev
7+
tags: [ns.two-tier-hidden]
8+
host: httpbin.org
9+
port: 443
10+
protocol: https
11+
retries: 0
12+
routes:
13+
- name: two-tier-service-dev
14+
tags: [ns.two-tier-hidden]
15+
hosts:
16+
- two-tier-service.dev.api.gov.bc.ca
17+
methods:
18+
- GET
19+
strip_path: false
20+
https_redirect_status_code: 426
21+
path_handling: v0
22+
request_buffering: true
23+
response_buffering: true
24+
plugins:
25+
- name: jwt-keycloak
26+
tags: [ns.two-tier-hidden, aps.two-tiered-hidden]
27+
enabled: true
28+
config:
29+
allowed_iss:
30+
- https://dev.loginproxy.gov.bc.ca/auth/realms/apigw
31+
allowed_aud: ap-two-tier-hidden-default-dev
32+
run_on_preflight: true
33+
iss_key_grace_period: 10
34+
maximum_expiration: 0
35+
algorithm: RS256
36+
claims_to_verify:
37+
- exp
38+
uri_param_names:
39+
- jwt
40+
cookie_names: []
41+
scope: null
42+
roles: null
43+
realm_roles: null
44+
client_roles: null
45+
anonymous: ce26955a-cf08-4907-9427-12d01c8bd94c
46+
consumer_match: true
47+
consumer_match_claim: azp
48+
consumer_match_claim_custom_id: true
49+
consumer_match_ignore_not_found: false
50+
- name: request-transformer
51+
tags: [ns.two-tier-hidden]
52+
enabled: true
53+
config:
54+
http_method: null
55+
---
56+
kind: DraftDataset
57+
name: two-tier-service-dataset
58+
title: Two-tier-service
59+
organization: ministry-of-health
60+
organizationUnit: public-health
61+
notes: Some information about the two-tier-service service
62+
tags: [two-tier-service, openapi]
63+
license_title: Access Only
64+
view_audience: Government
65+
security_class: LOW-PUBLIC
66+
record_publish_date: '2021-05-27'
67+
---
68+
kind: Product
69+
name: Two Tiered Hidden Product
70+
appId: 'LFH78YU956RE'
71+
dataset: two-tier-service-dataset
72+
environments:
73+
- name: dev
74+
active: true
75+
approval: false
76+
flow: kong-api-key-acl
77+
appId: '506CB7CF'
78+
services: [two-tier-service-dev]
79+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
kind: Namespace
2+
name: two-tier-hidden
3+
displayName: two-tier-hidden Display Name
4+
---
5+
kind: GatewayService
6+
name: two-tier-service-dev
7+
tags: [ns.two-tier-hidden]
8+
host: httpbin.org
9+
port: 443
10+
protocol: https
11+
retries: 0
12+
routes:
13+
- name: two-tier-service-dev
14+
tags: [ns.two-tier-hidden]
15+
hosts:
16+
- two-tier-service.dev.api.gov.bc.ca
17+
methods:
18+
- GET
19+
strip_path: false
20+
https_redirect_status_code: 426
21+
path_handling: v0
22+
request_buffering: true
23+
response_buffering: true
24+
plugins:
25+
- name: key-auth
26+
tags: [ ns.two-tier-hidden, aps.two-tiered-hidden ]
27+
protocols: [ http, https ]
28+
config:
29+
key_names: ["X-API-KEY"]
30+
run_on_preflight: true
31+
hide_credentials: true
32+
key_in_body: false
33+
anonymous: ce26955a-cf08-4907-9427-12d01c8bd94c
34+
- name: acl
35+
tags: [ ns.two-tier-hidden ]
36+
config:
37+
hide_groups_header: true
38+
allow: [ "406CB7CF" ]
39+
---
40+
kind: DraftDataset
41+
name: two-tier-service-dataset
42+
title: Two-tier-service
43+
organization: ministry-of-health
44+
organizationUnit: public-health
45+
notes: Some information about the two-tier-service service
46+
tags: [two-tier-service, openapi]
47+
license_title: Access Only
48+
view_audience: Government
49+
security_class: LOW-PUBLIC
50+
record_publish_date: '2021-05-27'
51+
---
52+
kind: Product
53+
name: Two Tiered Hidden Product
54+
appId: 'LFH78YU956RE'
55+
dataset: two-tier-service-dataset
56+
environments:
57+
- name: dev
58+
active: true
59+
approval: false
60+
flow: kong-api-key-acl
61+
appId: '506CB7CF'
62+
services: [two-tier-service-dev]

e2e/cypress/pageObjects/apiDirectory.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ class ApiDirectoryPage {
112112
cy.get(ele).should('exist')
113113
}
114114

115+
checkTwoTieredIcon(productName: string) {
116+
const pname: string = productName.toLowerCase().replaceAll(' ', '-')
117+
var ele: string = `[data-testid=two-tiered-icon-${pname}]`
118+
cy.get(ele).should('exist')
119+
}
120+
121+
checkTwoTieredHiddenButton() {
122+
var ele: string = '[data-testid=request-access-button-two-tiered-hidden]'
123+
cy.get(ele).should('exist')
124+
}
125+
115126
addOrganizationAndOrgUnit(product: any) {
116127
cy.contains('button', 'Add Organization').click({ force: true })
117128
cy.get(this.orgDropDown).select(product.orgName)

e2e/cypress/tests/07-manage-control/02-rate-limiting.cy.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ describe('Manage Control-Rate Limiting Spec for Service as Scope and Local Polic
5757
cy.get('@apiowner').then(({ product }: any) => {
5858
cy.makeKongRequest(product.environment.config.serviceName, 'GET').then((response) => {
5959
expect(response.status).to.be.equal(200)
60-
})
61-
cy.makeKongRequest(product.environment.config.serviceName, 'GET').then((response) => {
62-
expect(response.status).to.be.equal(429)
63-
expect(response.body.message).to.be.contain('API rate limit exceeded')
64-
})
60+
cy.makeKongRequest(product.environment.config.serviceName, 'GET').then((response) => {
61+
expect(response.status).to.be.equal(429)
62+
expect(response.body.message).to.be.contain('API rate limit exceeded')
63+
})
64+
})
6565
})
6666
})
6767
})
@@ -273,4 +273,4 @@ describe('Manage Control-Apply Rate limiting to Global and Consumer at Route lev
273273
after(() => {
274274
cy.logout()
275275
})
276-
})
276+
})

0 commit comments

Comments
 (0)