-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
a few fixes for Namespace to Gateway update (#1161)
* scroll to top, fix redirect for gateway detail * add return null * scroll to top of details on nav from /list * Cypress/ns to gw cli tests (#1158) Cypress tests for new features in `gwa` CLI from NS to GW. * replace Namespace with Gateway in org permission (#1159)
- Loading branch information
Showing
11 changed files
with
289 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
e2e/cypress/tests/16-gwa-cli/02-cli-generate-config-quick-start.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import LoginPage from '../../pageObjects/login' | ||
import ApplicationPage from '../../pageObjects/applications' | ||
import ApiDirectoryPage from '../../pageObjects/apiDirectory' | ||
import MyAccessPage from '../../pageObjects/myAccess' | ||
import HomePage from '../../pageObjects/home'; | ||
import Products from '../../pageObjects/products'; | ||
const YAML = require('yamljs'); | ||
let cli = require("../../fixtures/test_data/gwa-cli.json") | ||
const { v4: uuidv4 } = require('uuid') | ||
const jose = require('node-jose') | ||
|
||
let userSession: any | ||
const customId = uuidv4().replace(/-/g, '').toLowerCase().substring(0, 3) | ||
const serviceName = 'my-service-' + customId | ||
|
||
describe('Verify CLI commands for generate/apply config', () => { | ||
const login = new LoginPage() | ||
const apiDir = new ApiDirectoryPage() | ||
const app = new ApplicationPage() | ||
const ma = new MyAccessPage() | ||
const pd = new Products() | ||
let namespace: string | ||
const home = new HomePage() | ||
|
||
before(() => { | ||
// cy.visit('/') | ||
cy.reload(true) | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.preserveCookies() | ||
cy.fixture('apiowner').as('apiowner') | ||
// cy.visit(login.path) | ||
}) | ||
|
||
it('authenticates Janis (api owner) to get the user session token', () => { | ||
cy.get('@apiowner').then(({ apiTest }: any) => { | ||
cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { | ||
userSession = value | ||
}) | ||
}) | ||
}) | ||
|
||
it('Check gwa config command to set token', () => { | ||
cy.executeCliCommand('gwa config set --token ' + userSession).then((response) => { | ||
expect(response.stdout).to.contain("Config settings saved") | ||
}); | ||
}) | ||
|
||
it('Check gwa command to generate config for client credential template', () => { | ||
const command = [ | ||
'gwa generate-config --template quick-start', | ||
`--service ${serviceName}`, | ||
'--upstream https://httpbin.org', | ||
'--org ministry-of-health', | ||
'--org-unit planning-and-innovation-division', | ||
'--out gw-config-qs.yaml' | ||
].join(' '); | ||
cy.executeCliCommand(command).then((response) => { | ||
expect(response.stdout).to.contain("File gw-config-qs.yaml created") | ||
}); | ||
}) | ||
|
||
it('Check gwa command to apply generated config', () => { | ||
cy.executeCliCommand('gwa apply -i gw-config-qs.yaml').then((response) => { | ||
expect(response.stdout).to.contain("3/3 Published, 0 Skipped") | ||
let wordOccurrences = (response.stdout.match(/\bcreated\b/g) || []).length; | ||
expect(wordOccurrences).to.equal(2) | ||
}); | ||
}) | ||
|
||
it('Check gwa status --hosts include routes', () => { | ||
cy.executeCliCommand('gwa status --hosts').then((response) => { | ||
expect(response.stdout).to.contain('https://' + serviceName + '.dev.api.gov.bc.ca') | ||
}); | ||
}) | ||
|
||
it('activates namespace in Portal', () => { | ||
cy.executeCliCommand('gwa gateway current').then((response) => { | ||
const namespace = response.stdout.match(/\bgw-\w+/g)[0] | ||
cy.activateGateway(namespace) | ||
}) | ||
}) | ||
|
||
it('Verify that the product created through gwa command is displayed in the portal', () => { | ||
cy.visit(pd.path) | ||
pd.editProductEnvironment(serviceName + ' API', 'dev') | ||
}) | ||
|
||
it('Verify that the dataset created through GWA comand is assocuated with the product', () => { | ||
cy.visit(pd.path) | ||
pd.verifyDataset(serviceName, serviceName + ' API') | ||
}) | ||
|
||
it('Verify service name validation error in new namespace', () => { | ||
const command = [ | ||
'gwa generate-config --template quick-start', | ||
`--service ${serviceName}`, | ||
'--upstream https://httpbin.org', | ||
'--org ministry-of-health', | ||
'--org-unit planning-and-innovation-division' | ||
].join(' '); | ||
cy.executeCliCommand('gwa gateway create --generate').then((response) => { | ||
const namespace = response.stdout.match(/\bgw-\w+/g)[0] | ||
cy.executeCliCommand(command).then((response) => { | ||
expect(response.stderr).to.contain(`Error: Service ${serviceName} is already in use. Suggestion: ${namespace}-${serviceName}`) | ||
}); | ||
}); | ||
}) | ||
|
||
after(() => { | ||
cy.logout() | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.