Skip to content

Commit

Permalink
Merge pull request #670 from bcgov/dev
Browse files Browse the repository at this point in the history
Release Login Refresh Shared IdP Org Assignment
  • Loading branch information
ikethecoder committed Dec 30, 2022
2 parents 671b218 + 5c70ade commit ff834c2
Show file tree
Hide file tree
Showing 234 changed files with 8,383 additions and 3,047 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/ci-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
image:
registry: docker.pkg.github.com
repository: bcgov-dss/api-serv-infra/mongodb
tag: 4.4-ea993071
tag: 5.0-7a639fba
pullPolicy: IfNotPresent
pullSecrets:
- dev-github-read-packages-creds
Expand All @@ -111,8 +111,18 @@ jobs:
rbac:
create: true
strategyType: Recreate
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 100%
readinessProbe:
timeoutSeconds: 20
livenessProbe:
timeoutSeconds: 20
persistence:
enabled: true
size: 2Gi
Expand All @@ -134,7 +144,7 @@ jobs:
runAsUser: ${{ secrets.RUNNING_UID_GID }}
' > values.yaml
helm repo add bitnami https://charts.bitnami.com/bitnami
helm upgrade --install proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-db --version 10.31.5 -f values.yaml bitnami/mongodb
helm upgrade --install proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-db --version 12.1.31 -f values.yaml bitnami/mongodb
- name: 'Deploy Backend'
if: github.ref != 'refs/heads/dev'
Expand Down Expand Up @@ -188,7 +198,7 @@ jobs:
client-secret: ${{ secrets.OIDC_CLIENT_SECRET }}
oidc-issuer-url: ${{ secrets.OIDC_ISSUER }}
redirect-url: https://api-services-portal-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}.apps.silver.devops.gov.bc.ca/oauth2/callback
skip-auth-regex: '/login|/health|/public|/docs|/redirect|/_next|/images|/devportal|/manager|/about|/maintenance|/admin/session|/ds/api|/feed/|/signout|^[/]$'
skip-auth-regex: '/login|/health|/public|/docs|/redirect|/_next|/images|/devportal|/manager|/about|/maintenance|/admin/session|/ds/api|/feed/|/signout|/content|^[/]$'
whitelist-domain: authz-apps-gov-bc-ca.dev.api.gov.bc.ca
skip-provider-button: 'true'
profile-url: ${{ secrets.OIDC_ISSUER }}/protocol/openid-connect/userinfo
Expand Down
54 changes: 40 additions & 14 deletions .github/workflows/ci-build-only.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Deploy Refactor

on:
push:
branches: [NEVER]
branches: [hotfix/*]

env:
REGISTRY: ghcr.io
Expand All @@ -15,6 +15,28 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/bcgov/api-services-portal/api-services-portal

- name: Docker meta Feeder
id: docker_meta_feeder
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/bcgov/api-services-portal/data-feeder

- name: Set DEPLOY_ID which will deploy a custom deploy to 'dev' environment
run: |
echo '::set-output name=DEPLOY_ID::${{ steps.docker_meta.outputs.version }}'
echo '::set-output name=APP_VERSION::${{ fromJSON(steps.docker_meta.outputs.json).labels['org.opencontainers.image.version'] }}'
echo '::set-output name=APP_REVISION::${{ fromJSON(steps.docker_meta.outputs.json).labels['org.opencontainers.image.revision'] }}'
id: set-deploy-id

- name: Get deploy ID
run: echo "The DEPLOY_ID is ${{ steps.set-deploy-id.outputs.DEPLOY_ID }}"

- uses: actions/checkout@v2

- name: Login to DockerHub
Expand All @@ -35,27 +57,31 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v1

- id: release
uses: rymndhng/release-on-push-action@v0.15.0
- name: Build Feeder
uses: docker/build-push-action@v2
with:
bump_version_scheme: patch

- name: Check Output Parameters
run: |
echo "Got tag name ${{ steps.release.outputs.tag_name }}"
echo "Got release version ${{ steps.release.outputs.version }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
context: feeds
file: feeds/Dockerfile
tags: ${{ steps.docker_meta_feeder.outputs.tags }}
push: true
build-args: |
GITHUB_API_TOKEN=${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
APP_VERSION=${{ steps.set-deploy-id.outputs.APP_VERSION }}
APP_REVISION=${{ steps.set-deploy-id.outputs.APP_REVISION }}
- name: Build
- name: Build Portal
uses: docker/build-push-action@v2
with:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
context: .
file: Dockerfile
tags: ${{ steps.release.outputs.tag_name }}
load: true
tags: ${{ steps.docker_meta.outputs.tags }}
push: true
build-args: |
GITHUB_API_TOKEN=${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
APP_VERSION=${{ steps.set-deploy-id.outputs.APP_VERSION }}
APP_REVISION=${{ steps.set-deploy-id.outputs.APP_REVISION }}
- name: Push
run: docker push ${{ steps.release.outputs.tag_name }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,4 @@ select 'drop table "' || tablename || '" cascade;' from pg_tables where schemana
```

In the mean time, it is possible to drop the tables and re-run the `init-aps-portal-keystonejs-batch-job`.

85 changes: 85 additions & 0 deletions e2e/cypress/pageObjects/gatewayService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
class GatewayServicePage {

path: string = '/manager/services'
userNameInput: string = '[data-testid="nsa-gua-email-field"]'
grantUserAccessBtn: string = '[data-testid="nsa-grant-access-btn"]'
serviceTable: string = '[data-testid="matrixDetailsTable"]'
clearAllFilterBtn: string = '[data-testid="btn-filter-clear-all"]'
filterType: string = '[data-testid="filter-type-select"]'
filterValue: string = '[data-testid="consumer-filters-select"]'
filterApplyBtn: string = '[data-testid="btn-filter-apply"]'

getTestIdEnvName(env: string): string {
switch (env) {
case "Development":
return "dev"
case "Production":
return "prod"
default:
return env.toLowerCase()
}
}

expandServiceDetails(productName: string, envName: string) {
let pname: string = productName.toLowerCase().replaceAll(' ', '-')
let env = this.getTestIdEnvName(envName);
cy.get(`[data-testid=${pname}-${env}-metrics-details]`).click()
}

verifyRequestCount(productName: string, envName: string, count: number) {
let pname: string = productName.toLowerCase().replaceAll(' ', '-')
let env = this.getTestIdEnvName(envName);
cy.get(`[data-testid=${pname}-${env}-totalRequest]`).then(($value) => {
let countValue = $value.text()
assert.equal(countValue, count.toString())
})
}

verifyHostName(hostName: string) {
cy.contains('Host').next('dd').then(($value) => {
let hostValue = $value.text()
assert.equal(hostValue, hostName)
})
}

verifyTagsName(tagsName: string) {
cy.contains('Tags').next('dd').find('span').then(($value) => {
let hostValue = $value.text()
assert.equal(hostValue, tagsName)
})
}

verifyRouteName(service: string, route: string) {
cy.get(`[data-testid^=${service}-service-details`).then(($value) => {
let routeValue = $value.text()
debugger
assert.equal(routeValue, route)
})
}

verifyFilterResultsForGatewayService(filterType: string, filterValue: string, expectedResult: string, labelValue?: any) {
cy.wait(2000)
this.filterGatewayServiceByTypeAndValue(filterType, filterValue)
cy.wait(2000)
cy.get(this.serviceTable).find("tbody").find("tr").then((row) => {
expect(row.length.toString()).eq(expectedResult)
if (filterType === 'Environment') {
let environment = row.find('td:nth-child(2)').find('span').text()
assert.equal(environment,filterValue)
}
})

}

filterGatewayServiceByTypeAndValue(type: string, value: string) {
cy.get("body").then($body => {
if ($body.find(this.clearAllFilterBtn).length > 0) {
cy.get(this.clearAllFilterBtn, { timeout: 2000 }).click()
}
});
cy.get(this.filterType).select(type).invoke('val')
cy.get(this.filterValue).select(value).invoke('val')
cy.get(this.filterApplyBtn).click()
}
}
export default GatewayServicePage
6 changes: 1 addition & 5 deletions e2e/cypress/pageObjects/namespaceAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ class NamespaceAccessPage {
})
})
cy.contains("Share").click()
cy.wait(2000)
}

revokePermission(revokePermission: any) {
let accessRole: Array<string> = revokePermission.accessRole
accessRole.forEach(function (accessName) {
// cy.contains(revokePermission.userName).parents('tr').find('td:nth-child(2)').each(($e1, index, $list) => {
cy.contains(revokePermission.userName).parents('tr').find('td:nth-child(2)').find('span').each(($e1, index, $list) => {
cy.contains(revokePermission.userName).parents('tr').find('td:nth-child(2)').find('span').each(($e1, index, $list) => {
const text = $e1.text()
if (text === accessName) {
cy.wrap($e1).find('button').click()
Expand All @@ -38,15 +36,13 @@ class NamespaceAccessPage {
{
cy.contains(user).parents('tr').find('td:nth-child(3)').children('button').click()
cy.get('[data-testid$="-revoke-btn"]').filter(':visible').first().click()
cy.wait(2000)
}

path: string = '/manager/namespace-access'

clickGrantUserAccessButton() {
cy.get('[data-testid="nsa-users-table-row-0-menu"]',{ timeout: 5000 }).should('be.visible');
cy.get(this.grantUserAccessBtn).first().click({force:true})
cy.wait(2000)
}
}
export default NamespaceAccessPage
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import ApiDirectoryPage from '../../pageObjects/apiDirectory'
import GatewayServicePage from '../../pageObjects/gatewayService'
import HomePage from '../../pageObjects/home'
import LoginPage from '../../pageObjects/login'
import MyAccessPage from '../../pageObjects/myAccess'
import NamespaceAccessPage from '../../pageObjects/namespaceAccess'

describe('Verify Gateway Service details', () => {
const login = new LoginPage()
const apiDir = new ApiDirectoryPage()
const myAccessPage = new MyAccessPage()
const home = new HomePage()
const na = new NamespaceAccessPage()
const gs = new GatewayServicePage()

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
})

beforeEach(() => {
cy.preserveCookies()
cy.fixture('apiowner').as('apiowner')
})

it('authenticates Janis (api owner)', () => {
cy.get('@apiowner').then(({ user, namespace }: any) => {
cy.login(user.credentials.username, user.credentials.password)
cy.log('Logged in!')
home.useNamespace(namespace)
})
})

it('Navigate to Gateway Service Page', () => {
cy.intercept('POST', '/gql/api').as('createBoard')
cy.visit(gs.path)
cy.wait(2000)
})

it('Expand Gateway service details pane', () => {
cy.get('@apiowner').then(({ product }: any) => {
gs.expandServiceDetails(product.environment.config.serviceName, product.environment.name)
})
})

it('Verify total requests counts', () => {
cy.get('@apiowner').then(({ product }: any) => {
gs.verifyRequestCount(product.environment.config.serviceName, product.environment.name, 0)
})
})

it('Verify the routes details ', () => {
cy.get('@apiowner').then(({ product }: any) => {
gs.verifyRouteName(product.environment.config.serviceName, 'https://a-service-for-newplatform.api.gov.bc.ca/')
})
})

it('Verify the host details ', () => {
gs.verifyHostName('httpbin.org')
})

it('Verify the Tags details ', () => {
gs.verifyTagsName('ns.newplatform')
})

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import ConsumersPage from '../../pageObjects/consumers'
import LoginPage from '../../pageObjects/login'
import HomePage from '../../pageObjects/home'
import ProductPage from '../../pageObjects/products'
import GatewayServicePage from '../../pageObjects/gatewayService'

describe('Filter Gateway Services Spec', () => {
const login = new LoginPage()
const consumers = new ConsumersPage()
const home = new HomePage()
const gs = new GatewayServicePage()

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
})

beforeEach(() => {
cy.preserveCookies()
cy.fixture('apiowner').as('apiowner')
})

it('authenticates Janis (api owner)', () => {
cy.get('@apiowner').then(({ user, namespace }: any) => {
cy.login(user.credentials.username, user.credentials.password)
cy.log('Logged in!')
home.useNamespace(namespace)
})
})

it('Navigate to Gateway Service Page', () => {
cy.visit(gs.path)
cy.wait(2000)
})

it('verify that Gateway service filters as per given parameter', () => {
cy.get('@apiowner').then(({ product }: any) => {
gs.verifyFilterResultsForGatewayService('Products', product.name, '2')
gs.verifyFilterResultsForGatewayService('Environment', product.environment.name, '1')
gs.verifyFilterResultsForGatewayService('Environment', product.test_environment.name, '1')
})
})
})
File renamed without changes.
Loading

0 comments on commit ff834c2

Please sign in to comment.