Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev to test 1.2.15 #955

Merged
merged 10 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/jira.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,18 @@ jobs:
- uses: ikethecoder/sync-issues-github-jira@dev
with:
webhook-url: ${{ secrets.JIRA_WEBHOOK_URL }}

cleanup-runs:
name: Delete workflow runs
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 1
keep_minimum_runs: 5
delete_workflow_pattern: jira.yaml
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# API Services Portal

[![Lifecycle:Stable](https://img.shields.io/badge/Lifecycle-Stable-97ca00?style=for-the-badge)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/bcgov/aps-portal/Build%20and%20Deploy/dev?style=for-the-badge)](https://github.com/bcgov/api-services-portal/actions/workflows/ci-build-deploy.yaml)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/bcgov/api-services-portal/ci-build-deploy.yaml?branch=dev&style=for-the-badge)](https://github.com/bcgov/api-services-portal/actions/workflows/ci-build-deploy.yaml)
[![Coverage](https://img.shields.io/sonar/coverage/aps-portal/dev?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge)](https://sonarcloud.io/summary/new_code?id=aps-portal)
![GitHub](https://img.shields.io/github/license/bcgov/aps-portal?style=for-the-badge)
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/bcgov/aps-portal?label=release&style=for-the-badge)
Expand Down Expand Up @@ -58,10 +58,13 @@ Once running, the `api services portal` application is reachable via `localhost:

1. Create a `.env` from `.env.local` file
2. Create a `.env` from `.env.local` file under `feeds` directory
3. Run `docker-compose up` to spin up a local development environment with services (Postgres, Keycloak, OAuth2-proxy, APS-Portal, Feeder and Kong Gateway)
4. Go to: http://oauth2proxy.localtest.me:4180
5. To login, use username `local` and password `local`, or username `awsummer@idir` and password `awsummer`
6. `docker-compose down` : Removes all the hosted services
3. Remove cypress from docker-compose file (L106-129 & L217-229)
4. Run build steps [here](https://github.com/bcgov/api-services-portal/tree/dev/e2e#build-gateway-api-image)
5. Run `docker-compose build`
5. Run `docker-compose up` to spin up a local development environment with services (Postgres, Keycloak, OAuth2-proxy, APS-Portal, Feeder and Kong Gateway)
6. Go to: http://oauth2proxy.localtest.me:4180
7. To login, use username `local` and password `local`, or username `janis@idir` and password `awsummer`
8. `docker-compose down` : Removes all the hosted services

##### Note:

Expand Down
82 changes: 82 additions & 0 deletions e2e/cypress/fixtures/common-testdata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"namespace": "newplatform",
"deleteResources": {
"namespace": "gw-a9232"
},
"clientCredentials": {
"namespace": "gw-d2c50"
},
"namespacePreview": {
"namespace": "gw-16a3a"
},
"orgAssignment": {
"namespace": "gw-f016e"
},
"orgAssignmentMultipleAdmin": {
"namespace": "orgassignment1"
},
"orgAssignmentOrgUnit": {
"namespace": "orgassign-unit"
},
"checkPermission": {
"namespace": "gw-deedd",
"grantPermission": {
"Mark": {
"userName": "Mark F Mark L",
"email": "mark@gmail.com",
"accessRole": [
"Access.Manage"
]
},
"Mark_NV": {
"userName": "Mark F Mark L",
"email": "mark@gmail.com",
"accessRole": [
"Namespace.View"
]
},
"Wendy": {
"userName": "Wendy F Wendy L",
"email": "wendy@test.com",
"accessRole": [
"Namespace.Manage",
"CredentialIssuer.Admin"
]
},
"Wendy_NM": {
"userName": "Wendy F Wendy L",
"email": "wendy@test.com",
"accessRole": [
"Namespace.Manage"
]
},
"Wendy_CA": {
"userName": "Wendy F Wendy L",
"email": "wendy@test.com",
"accessRole": [
"CredentialIssuer.Admin"
]
},
"Wendy_GC": {
"userName": "Wendy F Wendy L",
"email": "wendy@test.com",
"accessRole": [
"GatewayConfig.Publish",
"Namespace.View"
]
},
"Janis": {
"userName": "Janis Smith",
"email": "janis@testmail.com",
"accessRole": [
"Namespace.Manage",
"CredentialIssuer.Admin"
]
}
}
},
"apiTest": {
"namespace": "gw-c3f31",
"delete_namespace": "testplatform"
}
}
10 changes: 10 additions & 0 deletions e2e/cypress/fixtures/developer.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@
"environment": "dev"
}
},
"deleteResources":{
"application": {
"name": "Delete-Auto Test App",
"description": "Test application for auto test"
},
"product": {
"name": "Delete-Auto Test Product",
"environment": "dev"
}
},
"elevatedAccess":{
"application": {
"name": "Request for Elevated Acess",
Expand Down
34 changes: 34 additions & 0 deletions e2e/cypress/fixtures/service-plugin_A.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
services:
- name: a-service-for-newplatform
host: httpbin.org
tags: [ns.newplatform.test]
port: 443
protocol: https
retries: 0
routes:
- name: a-service-for-newplatform-route
tags: [ns.newplatform.test]
hosts:
- a-service-for-newplatform.api.gov.bc.ca
paths:
- /
methods:
- GET
strip_path: false
https_redirect_status_code: 426
path_handling: v0

plugins:
- name: key-auth
tags: [ ns.newplatform.test ]
protocols: [ http, https ]
config:
key_names: ["X-API-KEY"]
run_on_preflight: true
hide_credentials: true
key_in_body: false
- name: acl
tags: [ ns.newplatform.test ]
config:
hide_groups_header: true
allow: [ "406CB7CF" ]
34 changes: 34 additions & 0 deletions e2e/cypress/fixtures/service-plugin_B.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
services:
- name: a-service-for-newplatform-test
host: httpbin.org
tags: [ns.newplatform.test]
port: 443
protocol: https
retries: 0
routes:
- name: a-service-for-newplatform-test-route
tags: [ns.newplatform.test]
hosts:
- a-service-for-newplatform-test.api.gov.bc.ca
paths:
- /
methods:
- GET
strip_path: false
https_redirect_status_code: 426
path_handling: v0

plugins:
- name: key-auth
tags: [ ns.newplatform.test ]
protocols: [ http, https ]
config:
key_names: ["X-API-KEY"]
run_on_preflight: true
hide_credentials: true
key_in_body: false
- name: acl
tags: [ ns.newplatform.test ]
config:
hide_groups_header: true
allow: [ "9AA97172" ]
2 changes: 1 addition & 1 deletion e2e/cypress/pageObjects/authProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class AuthorizationProfile {
cy.wrap($e1).find('button').eq(1).click()
cy.wait(2000)
cy.wrap($e1).find('button').last().click({force: true})
cy.verifyToastMessage(authProfileName +' deleted')
// cy.verifyToastMessage(authProfileName +' deleted')
return false
}
})
Expand Down
11 changes: 10 additions & 1 deletion e2e/cypress/pageObjects/consumers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default class ConsumersPage {
linkConsumerToNamespaceBtn: string = '[data-testid="link-consumer-namespace"]'
userNameTxt: string = '[data-testid="link-consumer-username"]'
linkBtn: string = '[data-testid="link-consumer-link-btn"]'
productDetails: string = '[data-testid="product-list-table"]'

clickOnRateLimitingOption() {
cy.get(this.rateLimitingOption, { timeout: 2000 }).click()
Expand Down Expand Up @@ -202,7 +203,7 @@ export default class ConsumersPage {
}

editConsumerDialog() {
cy.get('[data-testid="product-list-table"]').then($button => {
cy.get(this.productDetails).then($button => {
if ($button.is(':visible')) {
cy.contains('Edit').first().click()
}
Expand Down Expand Up @@ -374,4 +375,12 @@ export default class ConsumersPage {
getText() {
cy.get('[data-testid="all-consumer-control-tbl"]').find('tr').last().find('td').first().find('a').as('inputValue')
}

revokeProductEnvAccess(prodEnv: any) {
cy.get(this.productDetails).find('tr').each(($row) => {
if ($row.find('td:nth-child(1)').text() == prodEnv) {
cy.wrap($row).find('button').last().click({ force: true })
}
})
}
}
2 changes: 1 addition & 1 deletion e2e/cypress/pageObjects/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class HomePage {
cy.wait(1000)
cy.get(this.namespaceNameInput).next('div').then(($ele) => {
let validationMessage = $ele.text()
assert.equal(validationMessage,"Namespace name must be between 5 and 15 alpha-numeric lowercase characters and begin with an alphabet.")
assert.equal(validationMessage,"Namespace name must be between 5 and 15 alpha-numeric lowercase characters and start and end with an alphabet.")
})
// cy.verifyToastMessage("Namespace create failed")
})
Expand Down
40 changes: 26 additions & 14 deletions e2e/cypress/support/auth-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,20 @@ Cypress.Commands.add('resetCredential', (accessRole: string) => {
cy.visit('/')
cy.reload()
cy.fixture('apiowner').as('apiowner')
cy.fixture('common-testdata').as('common-testdata')
cy.preserveCookies()
cy.visit(login.path)
cy.get('@apiowner').then(({ user, checkPermission }: any) => {
cy.login(user.credentials.username, user.credentials.password)
cy.log('Logged in!')
home.useNamespace(checkPermission.namespace)
cy.visit(na.path)
na.revokeAllPermission(checkPermission.grantPermission[accessRole].userName)
cy.wait(2000)
na.clickGrantUserAccessButton()
na.grantPermission(checkPermission.grantPermission[accessRole])
cy.get('@apiowner').then(({ user }: any) => {
cy.get('@common-testdata').then(({ checkPermission }: any) => {
cy.login(user.credentials.username, user.credentials.password)
cy.log('Logged in!')
home.useNamespace(checkPermission.namespace)
cy.visit(na.path)
na.revokeAllPermission(checkPermission.grantPermission[accessRole].userName)
cy.wait(2000)
na.clickGrantUserAccessButton()
na.grantPermission(checkPermission.grantPermission[accessRole])
})
})
})

Expand Down Expand Up @@ -241,17 +244,26 @@ Cypress.Commands.add('getServiceOrRouteID', (configType: string, host: string) =
}).then((res) => {
expect(res.status).to.eq(200)
if (config === 'routes') {
cy.saveState(config + 'ID', Cypress._.get((Cypress._.filter(res.body.data, ["hosts", [host+".api.gov.bc.ca"]]))[0], 'id'))
cy.saveState(config + 'ID', Cypress._.get((Cypress._.filter(res.body.data, ["hosts", [host + ".api.gov.bc.ca"]]))[0], 'id'))
}
else {
cy.saveState(config + 'ID', Cypress._.get((Cypress._.filter(res.body.data, ["name", host]))[0], 'id'))
}
})
})

Cypress.Commands.add('publishApi', (fileName: string, namespace: string, flag?: boolean) => {
Cypress.Commands.add('publishApi', (fileNames: any, namespace: string, flag?: boolean) => {
let fixtureFile = flag ? "state/regen" : "state/store";
cy.log('< Publish API')
let fileName = ''
if (fileNames instanceof Array) {
for (const filepath of fileNames) {
fileName = fileName + ' ./cypress/fixtures/' + filepath;
}
}
else {
fileName = ' ./cypress/fixtures/' + fileNames
}
const requestName: string = 'publishAPI'
cy.fixture(fixtureFile).then((creds: any) => {
const serviceAcctCreds = JSON.parse(creds.credentials)
Expand All @@ -263,7 +275,7 @@ Cypress.Commands.add('publishApi', (fileName: string, namespace: string, flag?:
cy.executeCliCommand('gwa config set --token ' + res.body.access_token).then((response) => {
{
expect(response.stdout).to.contain("Config settings saved")
cy.executeCliCommand('gwa pg ./cypress/fixtures/' + fileName).then((response) => {
cy.executeCliCommand('gwa pg ' + fileName).then((response) => {
expect(response.stdout).to.contain("Gateway config published")
})
}
Expand Down Expand Up @@ -502,7 +514,7 @@ Cypress.Commands.add('updatePropertiesOfPluginFile', (filename: string, property
if (propertyName === "config.anonymous") {
obj.plugins[0].config.anonymous = propertyValue
}
else if (propertyName === "tags"){
else if (propertyName === "tags") {
obj.plugins[0][propertyName] = propertyValue
}
else {
Expand Down Expand Up @@ -573,7 +585,7 @@ Cypress.Commands.add('forceVisit', (url: string) => {
});
});

Cypress.Commands.add('updateJsonBoby', (json: any, key: string, newValue: string):any => {
Cypress.Commands.add('updateJsonBoby', (json: any, key: string, newValue: string): any => {
json[key] = newValue
return json
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/support/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ declare namespace Cypress {
client_secret: string
): Chainable<Cypress.Response<any>>

publishApi(fileName: string, namespace: string, flag?: boolean): Chainable<Cypress.Response<any>>
publishApi(fileNames: any, namespace: string, flag?: boolean): Chainable<Cypress.Response<any>>

getServiceOrRouteID(configType: string, host: string
): Chainable<Cypress.Response<any>>
Expand Down
4 changes: 0 additions & 4 deletions e2e/cypress/support/util-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ Cypress.Commands.add('resetState', () => {
})

Cypress.Commands.add('updateJsonValue', (filePath: string, jsonPath: string, newValue: string, index?: any) => {
debugger
cy.readFile('cypress/fixtures/' + filePath).then(currState => {
debugger

const keys = jsonPath.split('.'); // Split the keyPath using dot notation
let currentObj = currState;
Expand Down Expand Up @@ -142,7 +140,6 @@ Cypress.Commands.add('executeCliCommand', (command: string) => {
})

Cypress.Commands.add('replaceWordInJsonObject', (targetWord: string, replacement: string, fileName: string) => {
debugger
cy.readFile('cypress/fixtures/' + fileName).then((content: any) => {
let regex = new RegExp(targetWord, 'g');
let modifiedString = content.replace(regex, replacement);
Expand All @@ -165,7 +162,6 @@ Cypress.Commands.add('gwaPublish', (type: string, fileName: string) => {
Cypress.Commands.add('deleteFileInE2EFolder', (fileName: string) => {
const currentDirectory = Cypress.config('fileServerFolder'); // Get the current working directory
const filePath = path.join(currentDirectory, fileName)
debugger
try {
cy.exec(`rm -f ${filePath}`);
cy.log(`File '${fileName}' has been deleted from the e2e folder.`);
Expand Down
Loading
Loading