Skip to content

Commit

Permalink
Release patch for 1.1 (#432)
Browse files Browse the repository at this point in the history
Co-authored-by: Niraj Patel <[email protected]>
Co-authored-by: Nithin Shekar Kuruba <[email protected]>
Co-authored-by: Nithin Kuruba <[email protected]>
Co-authored-by: ikethecoder <[email protected]>
Co-authored-by: nirajCITZ <[email protected]>
  • Loading branch information
6 people authored Jun 13, 2022
1 parent 5f16f8d commit 2893be4
Show file tree
Hide file tree
Showing 41 changed files with 822 additions and 171 deletions.
4 changes: 2 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: ['util/*automation*']
branches: ['test']

env:
DASHBOARD_PROJECT_ID: ${{ secrets.CY_DASHBOARD_PRJ_ID }}
Expand All @@ -20,7 +20,7 @@ jobs:
steps:
- name: Build GWA API Image
run: |
git clone https://github.com/bcgov/gwa-api.git -b dev
git clone https://github.com/bcgov/gwa-api.git -b master
cd gwa-api/microservices/gatewayApi
docker build -t gwa-api:e2e .
- name: Checkout Portal
Expand Down
41 changes: 40 additions & 1 deletion .github/workflows/ci-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Deploy

on:
push:
branches: [dev, main, feature/*]
branches: [dev, test, main, feature/*]

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -299,3 +299,42 @@ jobs:
OIDC_CLIENT_ID=${{ secrets.OIDC_CLIENT_ID }} \
OIDC_CLIENT_SECRET=${{ secrets.OIDC_CLIENT_SECRET }} \
./scripts/init.sh
- name: 'Restart Portal in OCP Test Namespace'
if: github.ref == 'refs/heads/test'
run: |
oc rollout restart deployment/bcgov-aps-portal-generic-api -n ${{ secrets.OPENSHIFT_TEST_NAMESPACE }}
- name: 'Create Pull Request for Release'
if: github.ref == 'refs/heads/test'
uses: actions/github-script@v6
with:
script: |
const { repo, owner } = context.repo;
const openPrs = await github.rest.pulls.list({
owner,
repo,
head: '${{ github.ref_name }}',
base: 'main',
state: 'open'
})
if(openPrs.data.length === 0){
await github.rest.pulls.create({
title: 'Create Latest Release',
owner,
repo,
head: '${{ github.ref_name }}',
base: 'main',
body: [
'This Pull Request is auto-created by [actions/github-script](https://github.com/actions/github-script).',
'Please update this PR with appropriate labels to target specific type of release'
].join('\n\n'),
draft: true
});
} else {
console.log("There is already an open Pull Request in place.\n")
openPrs.data.forEach((item) => {
console.log(item.html_url)
})
}
59 changes: 52 additions & 7 deletions e2e/cypress/fixtures/api.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
{
"organization": {
"headers": {
"accept": "application/json"
"accept": "application/json",
"content-type": "application/json"
},
"endPoint": "ds/api/v2/organizations",
"orgExpectedList":
{
"name": "planning-and-innovation-division",
"title": "Planning and Innovation Division"
},
"orgName": "ministry-of-health"
"orgExpectedList": {
"name": "planning-and-innovation-division",
"title": "Planning and Innovation Division"
},
"orgName": "ministry-of-health",
"expectedScope": ["Dataset.Manage", "GroupAccess.Manage", "Namespace.Assign"],
"expectedNamespace": {
"name": "newplatform",
"orgUnit": "planning-and-innovation-division"
},
"body": {
"name": "ministry-of-health",
"parent": "/ca.bc.gov",
"members": [
{
"member": {
"username": "janis@idir"
},
"roles": ["organization-admin"]
}
]
}
},
"documentation": {
"endPoint": "ds/api/v2/namespaces/apiplatform/contents",
"getDocumentation_endPoint": "ds/api/v2/documentation",
"headers": {
"accept": "application/json",
"content-type": "application/json"
Expand All @@ -28,6 +46,26 @@
"tags": ["tag1", "tag2"]
}
},
"apiDirectory": {
"endPoint": "ds/api/v2/namespaces",
"orgEndPoint": "ds/api/v2/organizations",
"headers": {
"accept": "application/json",
"content-type": "application/json"
},
"body": {
"name": "auto-test-product-new",
"license_title": "Open Government Licence - British Columbia",
"security_class": "PUBLIC",
"view_audience": "Government",
"download_audience": "Public",
"notes": "Some notes",
"title": "Dataset for Test API",
"tags": ["gateway", "kong"],
"organization": "ministry-of-health",
"organizationUnit": "planning-and-innovation-division"
}
},
"authorizationProfiles": {
"body": {
"name": "my-auth-profile",
Expand Down Expand Up @@ -72,5 +110,12 @@
}
]
}
},
"namespaces": {
"headers": {
"accept": "application/json",
"content-type": "application/json"
},
"endPoint": "ds/api/v2/namespaces"
}
}
3 changes: 2 additions & 1 deletion e2e/cypress/fixtures/apiowner.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
}
},
"apiTest": {
"namespace": "apiplatform"
"namespace": "apiplatform",
"delete_namespace": "deleteplatform1"
}
}
4 changes: 1 addition & 3 deletions e2e/cypress/fixtures/state/store.json
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"credentials": "{\"clientId\": \"\", \"clientSecret\": \"\"}"
}
{}
1 change: 0 additions & 1 deletion e2e/cypress/pageObjects/authProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class AuthorizationProfile {
}
}
cy.get(this.createBtn).click()
cy.wait(2000)
if (isCreated === true)
cy.get(this.profileTable).contains(authProfile.name).should('exist')
else
Expand Down
1 change: 0 additions & 1 deletion e2e/cypress/pageObjects/myAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class myAccessPage {

saveAPIKeyValue(): void {
cy.get(this.apiKyeValueTxt).invoke('val').then(($apiKey: any) => {
debugger
cy.saveState('apikey', $apiKey)
})
cy.get(this.closeRequestAccesss).click()
Expand Down
5 changes: 5 additions & 0 deletions e2e/cypress/pageObjects/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class NameSpacePage {
cy.get(this.serviceAccountsLink).should('exist')
cy.get(this.deleteNamespaceLink).should('exist')
}

deleteNamespace(name: string) {
cy.get(this.deleteNamespaceLink).click()
cy.contains('button', 'Yes, Delete').click()
}
}

export default NameSpacePage
38 changes: 34 additions & 4 deletions e2e/cypress/support/auth-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ Cypress.Commands.add('login', (username: string, password: string) => {
const login = new LoginPage()
const home = new HomePage()

cy.get('header').then(($a) => {
cy.get('header').then(($a) => {
if ($a.text().includes('Login')) {
debugger

cy.get(login.loginButton).click()
cy.contains('Github').click()
const log = Cypress.log({
name: 'Login to Dev',
displayName: 'LOGIN_DEV',
Expand All @@ -40,7 +41,7 @@ Cypress.Commands.add('login', (username: string, password: string) => {
cy.get(login.loginSubmitButton).click()
}
})
debugger

if (checkElementExists('.alert')) {
cy.reload()
cy.get(login.usernameInput).click().type(username)
Expand Down Expand Up @@ -86,6 +87,30 @@ Cypress.Commands.add('resetCredential', (accessRole: string) => {
})
})

Cypress.Commands.add('getUserSessionTokenValue', () => {
const login = new LoginPage()
const home = new HomePage()
const na = new NamespaceAccessPage()
let userSession: string
cy.deleteAllCookies()
cy.visit('/')
cy.reload()
cy.fixture('apiowner').as('apiowner')
cy.preserveCookies()
cy.visit(login.path)
cy.getUserSession().then(() => {
cy.get('@apiowner').then(({ user, apiTest }: any) => {
cy.login(user.credentials.username, user.credentials.password)
cy.log('Logged in!')
home.useNamespace(apiTest.namespace)
cy.get('@login').then(function (xhr: any) {
userSession = xhr.response.headers['x-auth-request-access-token']
return userSession
})
})
})
})

Cypress.Commands.add('getSession', () => {
cy.log('< Get Session')
cy.request({ method: 'GET', url: Cypress.config('baseUrl') + '/admin/session' }).then(
Expand Down Expand Up @@ -277,7 +302,6 @@ Cypress.Commands.add('setHeaders', (headerValues: any) => {
})

Cypress.Commands.add('setRequestBody', (body: any) => {
debugger
requestBody = JSON.stringify(body)
})

Expand Down Expand Up @@ -319,6 +343,12 @@ Cypress.Commands.add('compareJSONObjects', (actualResponse: any, expectedRespons
cy.compareJSONObjects(objectValue2[value], objectValue1[value]);
}
} else {
debugger
if ((expectedResponse[p] == 'true') || (expectedResponse[p] == 'false'))
Boolean(expectedResponse[p])
if (['organization', 'organizationUnit'].includes(p) && (!indexFlag)) {
response[p] = response[p]['name']
}
if ((response[p] !== expectedResponse[p]) && !(['clientSecret', 'appId'].includes(p))) {
cy.log("Different Value ->" + expectedResponse[p])
assert.fail("JSON value mismatch for " + p)
Expand Down
3 changes: 3 additions & 0 deletions e2e/cypress/support/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ declare namespace Cypress {
getUserSession(): Chainable<Cypress.Response<any>>

compareJSONObjects(actualResponse: any, expectedResponse:any, indexFlag?: boolean) : Chainable<Cypress.Response<any>>

getUserSessionTokenValue(): Chainable<Cypress.Response<any>>

}
}
12 changes: 11 additions & 1 deletion e2e/cypress/tests/05-clear-resources/02-delete-resources.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import HomePage from '../../pageObjects/home'
import LoginPage from '../../pageObjects/login'
import NameSpacePage from '../../pageObjects/namespace'
import Products from '../../pageObjects/products'
import ServiceAccountsPage from '../../pageObjects/serviceAccounts'

Expand All @@ -8,6 +9,7 @@ describe('Delete created resources', () => {
const home = new HomePage()
const sa = new ServiceAccountsPage()
const pd = new Products()
const ns = new NameSpacePage

before(() => {
cy.visit('/')
Expand Down Expand Up @@ -54,7 +56,15 @@ describe('Delete created resources', () => {

it('Delete Namespace', () => {
cy.get('@apiowner').then(({ deleteResources }: any) => {
home.deleteNamespace(deleteResources.namespace)
cy.visit(ns.path)
ns.deleteNamespace(deleteResources.namespace)
})
})

// it('Verify that the deleted namespace does not display in namespace list', () => {
// cy.get('@apiowner').then(({ deleteResources }: any) => {
// const flag = home.useNamespace(deleteResources.namespace)
// assert.equal(flag, false)
// })
// })
})
1 change: 1 addition & 0 deletions e2e/cypress/tests/06-aps-api/01-create-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('Create API Spec', () => {
it('creates and activates new namespace', () => {
cy.get('@apiowner').then(({ apiTest }: any) => {
home.createNamespace(apiTest.namespace)
home.createNamespace(apiTest.delete_namespace)
})
})

Expand Down
Loading

0 comments on commit 2893be4

Please sign in to comment.