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

Cypress delete service acc #805

Merged
merged 6 commits into from
May 11, 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
2 changes: 1 addition & 1 deletion e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export default defineConfig({
config.specPattern=[
'./cypress/tests/01-*/*.ts',
'./cypress/tests/02-*/*.ts',
'./cypress/tests/06-*/*.ts',
'./cypress/tests/03-*/*.ts',
'./cypress/tests/04-*/*.ts',
'./cypress/tests/05-*/*.ts',
'./cypress/tests/06-*/*.ts',
'./cypress/tests/07-*/*.ts',
'./cypress/tests/08-*/*.ts',
'./cypress/tests/09-*/*.ts',
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/fixtures/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
"mode": "auto",
"environmentDetails": [
{
"environment": "dev",
"environment": "test",
"issuerUrl": "http://keycloak.localtest.me:9080/auth/realms/master",
"clientRegistration": "managed",
"clientId": "gwa-api",
Expand Down
3 changes: 2 additions & 1 deletion e2e/cypress/fixtures/manage-control-config-setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"rateLimiting": {
"requestPerHour_Consumer" : "1",
"requestPerHour_Global" : "2",
"rateLimiting_hour": "25"
"rateLimiting_hour": "25",
"requestPerHour_Elevated" : "250"
},
"ipRestriction" :{
"ipRange_valid" : "192.168.0.1/0",
Expand Down
22 changes: 12 additions & 10 deletions e2e/cypress/fixtures/service-plugin-key-auth-only.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
plugins:
- name: key-auth
tags: [ ns.newplatform ]
protocols: [ http, https ]
config:
key_names: ["X-API-KEY"]
run_on_preflight: true
hide_credentials: true
key_in_body: false

plugins:
-
name: key-auth
tags:
- ns.newplatform
protocols:
- http
- https
config:
key_names:
- x-api-key
anonymous: 1aaf2351-0622-4cc4-8d14-32e78771e620
58 changes: 47 additions & 11 deletions e2e/cypress/pageObjects/consumers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import { Assertion } from "chai"
import { wrap } from "module"
import dateformat from 'dateformat'
import { checkElementExists } from "../support/e2e"
import { String } from "cypress/types/lodash"
import { StringLiteral } from "typescript"
import { truncate } from "fs/promises"

export default class ConsumersPage {

path: string = '/manager/consumers'
rateLimitHourInput: string = '[data-testid="ratelimit-hour-input"]'
ipRestrictionAllowInput: string = '[data-testid="allow-ip-restriction-input-input"]'
Expand Down Expand Up @@ -38,6 +42,9 @@ export default class ConsumersPage {
removeRateLimitControlButton: string = '[data-testid="ratelimit-item-delete-btn-0"]'
rateLimitRouteRadioBtn: string = '[data-testid="ratelimit-route-radio"]'
consumerDialogCancelBtn: string = '[data-testid="edit-consumer-dialog-edit-cancel-btn"]'
linkConsumerToNamespaceBtn: string = '[data-testid="link-consumer-namespace"]'
userNameTxt: string = '[data-testid="link-consumer-username"]'
linkBtn: string = '[data-testid="link-consumer-link-btn"]'

clickOnRateLimitingOption() {
cy.get(this.rateLimitingOption, { timeout: 2000 }).click()
Expand Down Expand Up @@ -65,14 +72,24 @@ export default class ConsumersPage {
setRateLimiting(requestCount: string, scope = 'Service', policy = 'Local') {
this.editConsumerDialog()
cy.wait(2000)
if (!checkElementExists(this.rateLimitingOption)){
if (!checkElementExists(this.rateLimitingOption)) {
cy.get(this.consumerDialogCancelBtn).click()
this.editConsumerDialog()
}
// cy.wait(1000)
cy.wait(1000)
this.setRateLimitingWithOutConsumerID(requestCount, scope, policy)
// cy.wait(500)
cy.get(this.consumerDialogSaveBtn).click()
cy.get(this.consumerDialogSaveBtn, { timeout: 2000 }).should('not.exist')
cy.wait(3000)
}

setRateLimitingWithOutConsumerID(requestCount: string, scope?: string, policy?: string) {
scope = scope || 'Service'
policy = policy || 'Local'
this.clickOnRateLimitingOption()
cy.wait(3000)


cy.get(this.rateLimitHourInput, { timeout: 5000 }).click()
cy.get(this.rateLimitHourInput, { timeout: 2000 }).type(requestCount)
Expand All @@ -83,10 +100,6 @@ export default class ConsumersPage {
cy.get(this.policyDropDown).select(policy, { force: true }).invoke('val')
}
cy.get(this.rateLimitingApplyBtn).click()
// cy.wait(500)
cy.get(this.consumerDialogSaveBtn).click()
cy.get(this.consumerDialogSaveBtn, { timeout: 2000 }).should('not.exist')
cy.wait(3000)
}

setAllowedIPAddress(allowIP: string, scope = 'Service') {
Expand Down Expand Up @@ -149,7 +162,7 @@ export default class ConsumersPage {
cy.verifyToastMessage("Access request approved")
}

reviewThePendingRequest() : Boolean{
reviewThePendingRequest(): Boolean {
cy.wait(3000)
var flag = false;
cy.get("body").then($body => {
Expand Down Expand Up @@ -308,16 +321,39 @@ export default class ConsumersPage {
selectAuthorizationScope(scopes: any) {
cy.contains("Authorization").click()
scopes.forEach(function (scope: string) {
cy.get('[data-testid="client-scope-'+scope+'"]').click()
cy.get('[data-testid="client-scope-' + scope + '"]').click()
cy.wait(1000)
})
}

selectClientRole(roles: any) {
cy.contains("Authorization").click()
roles.forEach(function (role: string) {
cy.get('[data-testid="client-role-'+role.toLocaleLowerCase()+'"]').click()
cy.get('[data-testid="client-role-' + role.toLocaleLowerCase() + '"]').click()
cy.wait(1000)
})
}
}

deleteConsumer(consumerID: any) {
cy.get(this.allConsumerTable).find('tr').each(($row, index) => {
cy.log($row.find('td:nth-child(1)').text())
if ($row.find('td:nth-child(1)').text() == consumerID) {
cy.wrap($row).find('button').first().click()
cy.get('[data-testid="consumer-delete-menuitem"]').last().click({force:true})
}
})
}

clickOnLinkConsumerToNamespaceBtn() {
cy.get(this.linkConsumerToNamespaceBtn).click({force:true})
}

linkTheConsumerToNamespace(consumerID: any) {
cy.get(this.userNameTxt).type(consumerID)
cy.get(this.linkBtn).click({force:true})
}

getText(){
cy.get('[data-testid="all-consumer-control-tbl"]').find('tr').last().find('td').first().find('a').as('inputValue')
}
}
8 changes: 8 additions & 0 deletions e2e/cypress/pageObjects/myAccess.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class myAccessPage {

generateSecretsBtn: string = '[data-testid=generate-secrets-button]'
apiKyeValueTxt: string = '[data-testid=sa-new-creds-api-key]'
clientId: string = '[data-testid=sa-new-creds-client-id]'
Expand All @@ -12,6 +13,7 @@ class myAccessPage {
regenerateCredentialBtn: string = '[data-testid=regenerate-credentials-btn]'
regenerateCredentialCloseBtn: string = '[data-testid=regenerate-credentials-done-button]'
collectCredentialsBtn: string = '[data-testid="generate-credentials-button"]'
clientIDValueTxt: string = '[data-testid="sa-new-creds-client-id"]'
path: string = '/devportal/access'


Expand Down Expand Up @@ -158,6 +160,12 @@ class myAccessPage {
}
})
}

saveClientIDValue() {
cy.get(this.clientIDValueTxt).invoke('val').then(($clientID: any) => {
cy.saveState('clientID', $clientID)
})
}
}

export default myAccessPage
1 change: 0 additions & 1 deletion e2e/cypress/pageObjects/namespaceAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class NamespaceAccessPage {
// cy.get(this.userNameInput).type(editPermission.email);
let accessRole: Array<string> = editPermission.accessRole
accessRole.forEach(function (accessName) {
debugger
cy.contains("Permissions").next().find('li').find('label').each(($el, index, $list) => {
// cy.wrap($el).find('input').uncheck({ force: true });
const textAccessRoleName = $el.text()
Expand Down
21 changes: 13 additions & 8 deletions e2e/cypress/pageObjects/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Products {
credentialIssuer: string = '[name="credentialIssuer"]'
config: string | undefined
publishAPI: string = '[id="orgEnabled"]'
messageForNotDataset: string = '[data-testid="no-result-for-dataset"]'

getTestIdEnvName(env: string): string {
switch (env) {
Expand Down Expand Up @@ -110,16 +111,14 @@ class Products {
authType === 'Oauth2 Authorization Code Flow' ||
authType === 'Oauth2 Client Credentials Flow'
) {
debugger
let env = this.getTestIdEnvName(config.authIssuerEnv)
cy.get('[name="credentialIssuer"]').select(
`${config.authIssuer} (${env})`
)
}

cy.get(this.envCfgOptText).type(config.optionalInstructions)
cy.get(this.envCfgOptText).clear().type(config.optionalInstructions)
cy.get('[name="active"]').then($button => {
debugger
if ($button.is(':disabled')) {
flag = false
}
Expand All @@ -129,7 +128,6 @@ class Products {
.as('checkbox')
.invoke('is', ':checked')
.then(checked => {
debugger
if (invalid) {
cy
.get('@checkbox')
Expand All @@ -148,7 +146,6 @@ class Products {
.as('checkbox')
.invoke('is', ':checked')
.then(checked => {
debugger
if (!isApproved) {
cy
.get('@checkbox')
Expand All @@ -164,7 +161,6 @@ class Products {
// cy.get(this.envCfgApprovalCheckbox).click()
// cy.get(this.editPrdEnvConfigBtn).click()
cy.wait(3000)
debugger
if (flag) {
cy.get(this.envCfgApplyChangesContinueBtn).click()
}
Expand Down Expand Up @@ -300,8 +296,7 @@ class Products {
.get(this.publishAPI)
.as('checkbox')
.invoke('is', ':checked')
.then(checked => {
debugger
.then(checked => {
if (status) {
cy
.get('@checkbox')
Expand All @@ -314,6 +309,16 @@ class Products {
}
});
}

checkMessageForNoDataset(productName: string,search_input: string ) {
this.editProduct(productName)
cy.get(this.catelogueDropDown).type(search_input + '{downArrow}' + '{enter}', {
force: true,
delay: 500
})
cy.get(this.messageForNotDataset).should('be.visible');

}
}

export default Products
25 changes: 14 additions & 11 deletions e2e/cypress/support/auth-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ Cypress.Commands.add('login', (username: string, password: string, skipFlag = fa
cy.get(login.loginSubmitButton).click()
}

// log.end()
// cy.getLoginCallback().then(() => {
// cy.get('@login1').should((response :any) => {
// debugger
// if (response.status == 403)
// cy.wait(60000);
// cy.log("Trigger the block")
// })
// })
if (!skipFlag) {
cy.get(home.nsDropdown, { timeout: 6000 }).then(($el) => {
expect($el).to.exist
Expand All @@ -87,6 +78,14 @@ Cypress.Commands.add('keycloakLogin', (username: string, password: string) => {
cy.get(login.loginSubmitButton).click()
})

Cypress.Commands.add('getLastConsumerID',() =>{
let id : any
cy.get('[data-testid="all-consumer-control-tbl"]').find('tr').last().find('td').first().find('a').then(($text)=>{
id = $text.text()
return id
})
})

Cypress.Commands.add('resetCredential', (accessRole: string) => {
const login = new LoginPage()
const home = new HomePage()
Expand Down Expand Up @@ -291,7 +290,11 @@ Cypress.Commands.add('makeKongRequest', (serviceName: string, methodType: string
let authorization
cy.fixture('state/regen').then((creds: any) => {
cy.wait(2000)
let token = key || creds.apikey
let token = key
if (key==undefined)
{
token = creds.apikey
}
const service = serviceName
cy.log("Token->" + token)
return cy.request({
Expand Down Expand Up @@ -354,7 +357,7 @@ Cypress.Commands.add('updateKongPlugin', (pluginName: string, name: string, endP
let endpoint
if (pluginName == '')
endpoint = 'plugins'
else
else if(id !== undefined)
endpoint = pluginName.toLowerCase() + '/' + id.toString() + '/' + 'plugins'
endpoint = (typeof endPoint !== 'undefined') ? endPoint : endpoint
body = config[name]
Expand Down
2 changes: 2 additions & 0 deletions e2e/cypress/support/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ declare namespace Cypress {

selectLoginOptions(username: string): Chainable<any>

getLastConsumerID(): Chainable<any>

// isProductDisplay(productName: string, expResult : boolean) :Chainable<Cypress.Response<any>>
}
}
7 changes: 7 additions & 0 deletions e2e/cypress/tests/01-api-key/01-create-api.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ describe('Create API Spec', () => {
})
})

it('Verify the message when no dataset is linked to BCDC', () => {
cy.visit(pd.path)
cy.get('@apiowner').then(({ product }: any) => {
pd.checkMessageForNoDataset(product.name,"health")
})
})

it('update the Dataset in BC Data Catelogue to appear the API in the Directory', () => {
cy.visit(pd.path)
cy.get('@apiowner').then(({ product }: any) => {
Expand Down
1 change: 1 addition & 0 deletions e2e/cypress/tests/01-api-key/05-collect-credentials.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('Collect credential Spec', () => {
myAccessPage.clickOnCollectCredentialButton()
myAccessPage.clickOnGenerateSecretButton()
cy.contains("API Key").should('be.visible')
myAccessPage.saveClientIDValue()
myAccessPage.saveAPIKeyValue()
})

Expand Down
Loading