Skip to content

Commit

Permalink
Re order the spec files for execution in CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
nirajCITZ committed Sep 4, 2023
1 parent f0e78c2 commit 0a5c95b
Show file tree
Hide file tree
Showing 23 changed files with 183 additions and 175 deletions.
143 changes: 143 additions & 0 deletions e2e/cypress/tests/01-api-key/03-request-access-inactive-env.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// import ApiDirectoryPage from '../../pageObjects/apiDirectory'
// import ApplicationPage from '../../pageObjects/applications'
// import HomePage from '../../pageObjects/home'
// import LoginPage from '../../pageObjects/login'
// import NamespaceAccessPage from '../../pageObjects/namespaceAccess'
// import Products from '../../pageObjects/products'
// import MyAccessPage from '../../pageObjects/myAccess'

// describe('Change an Active environment to Inactive', () => {
// const login = new LoginPage()
// const home = new HomePage()
// const na = new NamespaceAccessPage()
// const pd = new Products()

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

// beforeEach(() => {
// cy.preserveCookies()
// cy.fixture('apiowner').as('apiowner')
// // cy.visit(login.path)
// })

// 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 Products Page', () => {
// cy.visit(pd.path)
// })

// it('Change the current active environment to inactive state', () => {
// cy.get('@apiowner').then(({ product }: any) => {
// pd.editProductEnvironment(product.name, product.environment.name)
// pd.editProductEnvironmentConfig(product.environment.config, true)
// })
// })

// after(() => {
// cy.logout()
// cy.clearLocalStorage({ log: true })
// cy.deleteAllCookies()
// })
// })

// describe('Verify enactive environment in rrequest access pop up', () => {
// const apiDir = new ApiDirectoryPage()
// const app = new ApplicationPage()
// const myAccessPage = new MyAccessPage()

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

// beforeEach(() => {
// cy.preserveCookies()
// cy.fixture('developer').as('developer')
// // cy.visit(login.path)
// })

// it('authenticates Harley (developer)', () => {
// cy.get('@developer').then(({ user }: any) => {
// cy.login(user.credentials.username, user.credentials.password)
// })
// })

// it('creates an application', () => {
// cy.visit(app.path)
// cy.get('@developer').then(({ application }: any) => {
// app.createApplication(application)
// })
// })

// it('Verify that inactive environment is not displayed', () => {
// cy.visit(apiDir.path)
// cy.get('@developer').then(({ product, application }: any) => {
// apiDir.checkInactiveEnvironmentAccessReqOption(product, application)
// })
// })

// it('Close the popup by click on Cancel button', () => {
// myAccessPage.cancelRequestAccessPopUp()
// })

// after(() => {
// cy.logout()
// cy.clearLocalStorage({ log: true })
// cy.deleteAllCookies()
// })
// })

// describe('Change an the environment back to active', () => {
// const login = new LoginPage()
// const home = new HomePage()
// const na = new NamespaceAccessPage()
// const pd = new Products()

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

// beforeEach(() => {
// cy.preserveCookies()
// cy.fixture('apiowner').as('apiowner')
// // cy.visit(login.path)
// })

// 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 Products Page', () => {
// cy.visit(pd.path)
// })

// it('Change the environment back to active state', () => {
// cy.get('@apiowner').then(({ product }: any) => {
// pd.editProductEnvironment(product.name, product.environment.name)
// pd.editProductEnvironmentConfig(product.environment.config)
// })
// })

// after(() => {
// cy.logout()
// cy.clearLocalStorage({ log: true })
// cy.deleteAllCookies()
// })
// })
Original file line number Diff line number Diff line change
Expand Up @@ -35,54 +35,36 @@ describe('Verify CLI commands', () => {
})
})

it('Check for gwa help', () => {
cy.executeCliCommand('gwa help').then((response) => {
debugger
assert.equal(response.stdout, cli.content.help)
});
})

it('Check gwa command for login help', () => {
cy.executeCliCommand('gwa login -h').then((response) => {
assert.equal(response.stdout, cli.content.login_help)
});
})

it('Check gwa command to login with client ID and secret', () => {
let clientID = cli.credentials.clientID
let clientSecret = cli.credentials.clientSecret
cy.log('gwa login --host ${url} --scheme http')
cy.executeCliCommand('gwa login --client-id ' + clientID + ' --client-secret ' + clientSecret + ' --host ' + cleanedUrl + ' --scheme http').then((response) => {
assert.equal(response.stdout, "Logged in")
expect(response.stdout).to.contain('Successfully logged in');
});
})

it('Check gwa command for login with invalid client id', () => {
let clientID = "dummy-client"
let clientSecret = cli.credentials.clientSecret
cy.executeCliCommand('gwa login --client-id '+clientID+' --client-secret '+clientSecret+' --host '+cleanedUrl+' --scheme http').then((response) => {
cy.executeCliCommand('gwa login --client-id ' + clientID + ' --client-secret ' + clientSecret + ' --host ' + cleanedUrl + ' --scheme http').then((response) => {
assert.equal(response.stderr, "Error: unauthorized_client\nINVALID_CREDENTIALS: Invalid client credentials")
});
})

it('Check gwa command for login with invalid client secret', () => {
let clientID = cli.credentials.clientID
let clientSecret = "dummy-client-secret"
cy.executeCliCommand('gwa login --client-id '+clientID+' --client-secret '+clientSecret+' --host '+cleanedUrl+' --scheme http').then((response) => {
cy.executeCliCommand('gwa login --client-id ' + clientID + ' --client-secret ' + clientSecret + ' --host ' + cleanedUrl + ' --scheme http').then((response) => {
assert.equal(response.stderr, "Error: unauthorized_client\nINVALID_CREDENTIALS: Invalid client credentials")
});
})

it('Check gwa command for config help', () => {
cy.executeCliCommand('gwa config -h').then((response) => {
debugger
assert.equal(response.stdout, cli.content.config_help)
});
})

it('Check gwa config command to set environment', () => {
var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, "");
cy.executeCliCommand('gwa config set --host '+cleanedUrl+' --scheme http').then((response) => {
cy.executeCliCommand('gwa config set --host ' + cleanedUrl + ' --scheme http').then((response) => {
expect(response.stdout).to.contain("Config settings saved")
});
})
Expand All @@ -93,24 +75,24 @@ describe('Verify CLI commands', () => {
});
})

it('Check gwa command for namespace help', () => {
cy.executeCliCommand('gwa namespace -h').then((response) => {
debugger
assert.equal(response.stdout, cli.content.namespace_help)
});
})

it('Check gwa command to create namespace', () => {
cy.executeCliCommand('gwa namespace create --host ' + cleanedUrl + ' --scheme http').then((response) => {
assert.isNotNaN(response.stdout)
namespace = response.stdout
});
})


it('Check gwa namespace list command and verify the created namespace in the list', () => {
cy.executeCliCommand('gwa namespace list --host ' + cleanedUrl + ' --scheme http').then((response) => {
expect(response.stdout).to.contain(namespace);
});
})

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})

})
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let cli = require("../../fixtures/test_data/gwa-cli.json")

const jose = require('node-jose')

describe('Verify CLI commands', () => {
describe('Verify CLI commands for generate/apply config', () => {
const login = new LoginPage()
const apiDir = new ApiDirectoryPage()
const app = new ApplicationPage()
Expand Down Expand Up @@ -39,31 +39,36 @@ describe('Verify CLI commands', () => {
})
})

// 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 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', () => {
cy.executeCliCommand('gwa generate-config --template client-credentials-shared-idp --service my-service --upstream https://httpbin.org --org ministry-of-health --org-unit planning-and-innovation-division').then((response) => {
assert.equal(response.stdout, "File gw-config.yml created")
});
})

// it('Check gwa command to generate config', () => {
// cy.executeCliCommand('gwa generate-config --template client-credentials-shared-idp --service my-service --upstream https://httpbin.org --org ministry-of-health --org-unit planning-and-innovation-division').then((response) => {
// assert.equal(response.stdout, "File gw-config.yml created")
// });
// })
it('Check gwa command to apply generated config', () => {
cy.executeCliCommand('gwa apply').then((response) => {
debugger
let wordOccurrences = (response.stdout.match(/\bcreated\b/g) || []).length;
expect(wordOccurrences).to.equal(3)
namespace = response.stdout.split('\n')[0]
namespace = namespace.replace('-', '').trim()
});
})

// it('Check gwa command to apply generated config', () => {
// cy.executeCliCommand('gwa apply').then((response) => {
// let wordOccurrences = (response.stdout.match(/\bcreated\b/g) || []).length;
// expect(wordOccurrences).to.equal(3)
// wordOccurrences = (response.stdout.match(/\published\b/g) || []).length;
// expect(wordOccurrences).to.equal(1)
// });
// })
it('Check gwa command to generate config for kong httpbin template', () => {
cy.executeCliCommand('gwa generate-config --template kong-httpbin --service my-service --upstream https://httpbin.org --org ministry-of-health --org-unit planning-and-innovation-division').then((response) => {
assert.equal(response.stdout, "File gw-config.yml created")
});
})

it('activates new namespace', () => {
cy.get('@apiowner').then(({ namespace }: any) => {
home.useNamespace(namespace)
})
home.useNamespace(namespace)
})

it('Verify that the product created through gwa command is displayed in the portal', () => {
Expand All @@ -76,11 +81,11 @@ describe('Verify CLI commands', () => {
})

it('Verify the issuer details for the product', () => {
pd.verifyIssuer('gw-d4ed4 default (test)')
pd.verifyIssuer(namespace + ' default (test)')
})

it('Verify that the dataset created through GWA comand is assocuated with the product', () => {
cy.visit(pd.path)
pd.verifyDataset('my-service','my-service API')
pd.verifyDataset('my-service', 'my-service API')
})
})
Loading

0 comments on commit 0a5c95b

Please sign in to comment.