|
|
@ -9,7 +9,7 @@ export const genTest = (type, xcdb) => { |
|
|
|
|
|
|
|
|
|
|
|
describe(`Swagger API - Test preparation`, () => { |
|
|
|
describe(`Swagger API - Test preparation`, () => { |
|
|
|
before(()=> { |
|
|
|
before(()=> { |
|
|
|
loginPage.loginAndOpenProject('rest', false) |
|
|
|
loginPage.loginAndOpenProject(type, false) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it("[REST] open project & record swagger URL, AuthToken", () => { |
|
|
|
it("[REST] open project & record swagger URL, AuthToken", () => { |
|
|
@ -17,156 +17,165 @@ export const genTest = (type, xcdb) => { |
|
|
|
cy.url().then( (url) => { |
|
|
|
cy.url().then( (url) => { |
|
|
|
// retrieve project name from URL & use it to construct Swagger URL
|
|
|
|
// retrieve project name from URL & use it to construct Swagger URL
|
|
|
|
// URL on homepage: http://localhost:3000/#/nc/externalrest_weUO?type=roles&dbalias=&name=Team%20%26%20Auth%20
|
|
|
|
// URL on homepage: http://localhost:3000/#/nc/externalrest_weUO?type=roles&dbalias=&name=Team%20%26%20Auth%20
|
|
|
|
// Swagger URL: http://localhost:8080/nc/externalrest_weUO/db/swagger
|
|
|
|
// [REST] Swagger URL: http://localhost:8080/nc/externalrest_weUO/db/swagger
|
|
|
|
//
|
|
|
|
// [GQL] http://localhost:8080/nc/externalgql_dgwx/v1/graphql
|
|
|
|
const projectName = url.split("/")[5].split("?")[0]; |
|
|
|
const projectName = url.split("/")[5].split("?")[0]; |
|
|
|
let swaggerURL = `http://localhost:8080/nc/${projectName}/db/swagger` |
|
|
|
let swaggerURL = `` |
|
|
|
|
|
|
|
if ('rest' == type) { |
|
|
|
|
|
|
|
swaggerURL = `http://localhost:8080/nc/${projectName}/db/swagger` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
swaggerURL = `http://localhost:8080/nc/${projectName}/v1/graphql` |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// exchange information between two tests using a file
|
|
|
|
// exchange information between two tests using a file
|
|
|
|
// https://stackoverflow.com/questions/52050657/what-is-the-best-practice-of-pass-states-between-tests-in-cypress
|
|
|
|
// https://stackoverflow.com/questions/52050657/what-is-the-best-practice-of-pass-states-between-tests-in-cypress
|
|
|
|
//
|
|
|
|
//
|
|
|
|
cy.writeFile("shared.json", {SWAGGER_URL: swaggerURL, AUTH_TOKEN: authToken}) |
|
|
|
cy.writeFile("shared.json", {SWAGGER_URL: swaggerURL, AUTH_TOKEN: authToken}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
describe(`Swagger page, base verification`, () => { |
|
|
|
if ('rest' == type) { |
|
|
|
|
|
|
|
|
|
|
|
// returns swagger button intended for
|
|
|
|
describe(`Swagger page, base verification`, () => { |
|
|
|
//
|
|
|
|
|
|
|
|
const getSwaggerButton = (tag, idx, desc) => { |
|
|
|
// returns swagger button intended for
|
|
|
|
return cy.get(`#operations-tag-${tag}`).next().find('.opblock').eq(idx).find(`button:contains(${desc})`) |
|
|
|
//
|
|
|
|
} |
|
|
|
const getSwaggerButton = (tag, idx, desc) => { |
|
|
|
|
|
|
|
return cy.get(`#operations-tag-${tag}`).next().find('.opblock').eq(idx).find(`button:contains(${desc})`) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let Token |
|
|
|
let Token |
|
|
|
|
|
|
|
|
|
|
|
// basic authentication tag verification
|
|
|
|
// basic authentication tag verification
|
|
|
|
//
|
|
|
|
|
|
|
|
it("Swagger URL access & basic validation", () => { |
|
|
|
|
|
|
|
// retrieve information stored in previous IT block
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
cy.readFile("shared.json").then((jsonPayload) => { |
|
|
|
it("Swagger URL access & basic validation", () => { |
|
|
|
let URL = jsonPayload.SWAGGER_URL |
|
|
|
// retrieve information stored in previous IT block
|
|
|
|
Token = jsonPayload.AUTH_TOKEN |
|
|
|
//
|
|
|
|
|
|
|
|
cy.readFile("shared.json").then((jsonPayload) => { |
|
|
|
cy.visit(URL) |
|
|
|
let URL = jsonPayload.SWAGGER_URL |
|
|
|
cy.log(Token) |
|
|
|
Token = jsonPayload.AUTH_TOKEN |
|
|
|
|
|
|
|
|
|
|
|
// validate; API order assumed
|
|
|
|
cy.visit(URL) |
|
|
|
cy.get('#operations-tag-Authentication').next().find('.opblock').should('has.length', 9) |
|
|
|
cy.log(Token) |
|
|
|
getSwaggerButton("Authentication", 0, "User login").should('exist') |
|
|
|
|
|
|
|
getSwaggerButton("Authentication", 1, "User signup").should('exist') |
|
|
|
// validate; API order assumed
|
|
|
|
getSwaggerButton("Authentication", 2, "Password Forgot").should('exist') |
|
|
|
cy.get('#operations-tag-Authentication').next().find('.opblock').should('has.length', 9) |
|
|
|
getSwaggerButton("Authentication", 3, "Email validate link").should('exist') |
|
|
|
getSwaggerButton("Authentication", 0, "User login").should('exist') |
|
|
|
getSwaggerButton("Authentication", 4, "Validate password reset token").should('exist') |
|
|
|
getSwaggerButton("Authentication", 1, "User signup").should('exist') |
|
|
|
getSwaggerButton("Authentication", 5, "Password reset").should('exist') |
|
|
|
getSwaggerButton("Authentication", 2, "Password Forgot").should('exist') |
|
|
|
getSwaggerButton("Authentication", 6, "User details").should('exist') |
|
|
|
getSwaggerButton("Authentication", 3, "Email validate link").should('exist') |
|
|
|
getSwaggerButton("Authentication", 7, "Update user details").should('exist') |
|
|
|
getSwaggerButton("Authentication", 4, "Validate password reset token").should('exist') |
|
|
|
getSwaggerButton("Authentication", 8, "Update user details").should('exist') |
|
|
|
getSwaggerButton("Authentication", 5, "Password reset").should('exist') |
|
|
|
|
|
|
|
getSwaggerButton("Authentication", 6, "User details").should('exist') |
|
|
|
|
|
|
|
getSwaggerButton("Authentication", 7, "Update user details").should('exist') |
|
|
|
|
|
|
|
getSwaggerButton("Authentication", 8, "Update user details").should('exist') |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it("Authorize success: Valid token", ()=> { |
|
|
|
it("Authorize success: Valid token", ()=> { |
|
|
|
// authorize button, feed token, click authorize
|
|
|
|
// authorize button, feed token, click authorize
|
|
|
|
cy.get('[class="btn authorize unlocked"]').click() |
|
|
|
cy.get('[class="btn authorize unlocked"]').click() |
|
|
|
cy.get('input').type(Token) |
|
|
|
cy.get('input').type(Token) |
|
|
|
cy.get('.auth-btn-wrapper > .authorize').click() |
|
|
|
cy.get('.auth-btn-wrapper > .authorize').click() |
|
|
|
|
|
|
|
|
|
|
|
// Response: "Authorized" should exist on DOM
|
|
|
|
// Response: "Authorized" should exist on DOM
|
|
|
|
cy.get('.auth-container').contains('Authorized').should('exist')
|
|
|
|
cy.get('.auth-container').contains('Authorized').should('exist')
|
|
|
|
cy.get('.btn-done').click() |
|
|
|
cy.get('.btn-done').click() |
|
|
|
|
|
|
|
|
|
|
|
// Authorize button is LOCKED now
|
|
|
|
// Authorize button is LOCKED now
|
|
|
|
cy.get('[class="btn authorize locked"]').should('exist') |
|
|
|
cy.get('[class="btn authorize locked"]').should('exist') |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it("Execute Authentication (valid token case) > GET: User details API", ()=> {
|
|
|
|
it("Execute Authentication (valid token case) > GET: User details API", ()=> {
|
|
|
|
// Auth> User details API
|
|
|
|
// Auth> User details API
|
|
|
|
getSwaggerButton("Authentication", 6, "User details").click() |
|
|
|
getSwaggerButton("Authentication", 6, "User details").click() |
|
|
|
|
|
|
|
|
|
|
|
// "Try it out" button, followed by "Execute"
|
|
|
|
// "Try it out" button, followed by "Execute"
|
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
cy.get('.execute-wrapper > .btn').click() |
|
|
|
cy.get('.execute-wrapper > .btn').click() |
|
|
|
|
|
|
|
|
|
|
|
// check response: validate email credentials
|
|
|
|
// check response: validate email credentials
|
|
|
|
cy.get('.highlight-code > .microlight').contains('email').should('exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains('email').should('exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('exist') |
|
|
|
|
|
|
|
|
|
|
|
// reset operations (clear, cancel, windback User details tab)
|
|
|
|
// reset operations (clear, cancel, windback User details tab)
|
|
|
|
cy.get('.btn-clear').click() |
|
|
|
cy.get('.btn-clear').click() |
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
getSwaggerButton("Authentication", 6, "User details").click() |
|
|
|
getSwaggerButton("Authentication", 6, "User details").click() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it("Logout post authorization", ()=> { |
|
|
|
it("Logout post authorization", ()=> { |
|
|
|
// authorize button, logout
|
|
|
|
// authorize button, logout
|
|
|
|
cy.get('[class="btn authorize locked"]').click() |
|
|
|
cy.get('[class="btn authorize locked"]').click() |
|
|
|
cy.get('.auth-btn-wrapper > button:contains("Logout")').click() |
|
|
|
cy.get('.auth-btn-wrapper > button:contains("Logout")').click() |
|
|
|
cy.get('.btn-done').click() |
|
|
|
cy.get('.btn-done').click() |
|
|
|
|
|
|
|
|
|
|
|
// Authorize button is UNLOCKED now
|
|
|
|
// Authorize button is UNLOCKED now
|
|
|
|
cy.get('[class="btn authorize unlocked"]').should('exist') |
|
|
|
cy.get('[class="btn authorize unlocked"]').should('exist') |
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it("Execute Authentication (logout case) > GET: User details API", ()=> {
|
|
|
|
it("Execute Authentication (logout case) > GET: User details API", ()=> {
|
|
|
|
// Auth> User details API
|
|
|
|
// Auth> User details API
|
|
|
|
getSwaggerButton("Authentication", 6, "User details").click() |
|
|
|
getSwaggerButton("Authentication", 6, "User details").click() |
|
|
|
|
|
|
|
|
|
|
|
// "Try it out" button, followed by "Execute"
|
|
|
|
// "Try it out" button, followed by "Execute"
|
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
cy.get('.execute-wrapper > .btn').click() |
|
|
|
cy.get('.execute-wrapper > .btn').click() |
|
|
|
|
|
|
|
|
|
|
|
// check response: email credentials shouldnt exist. should display 'guest:true'
|
|
|
|
// check response: email credentials shouldnt exist. should display 'guest:true'
|
|
|
|
cy.get('.highlight-code > .microlight').contains('guest').should('exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains('guest').should('exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains('email').should('not.exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains('email').should('not.exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('not.exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('not.exist') |
|
|
|
|
|
|
|
|
|
|
|
// reset operations (clear, cancel, windback User details tab)
|
|
|
|
// reset operations (clear, cancel, windback User details tab)
|
|
|
|
cy.get('.btn-clear').click() |
|
|
|
cy.get('.btn-clear').click() |
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
getSwaggerButton("Authentication", 6, "User details").click()
|
|
|
|
getSwaggerButton("Authentication", 6, "User details").click()
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it("Authorize failure: invalid token", ()=> { |
|
|
|
it("Authorize failure: invalid token", ()=> { |
|
|
|
// authorize button, feed *invalid* token, click authorize
|
|
|
|
// authorize button, feed *invalid* token, click authorize
|
|
|
|
cy.get('[class="btn authorize unlocked"]').click() |
|
|
|
cy.get('[class="btn authorize unlocked"]').click() |
|
|
|
cy.get('input').type('xyz') |
|
|
|
cy.get('input').type('xyz') |
|
|
|
cy.get('.auth-btn-wrapper > .authorize').click() |
|
|
|
cy.get('.auth-btn-wrapper > .authorize').click() |
|
|
|
|
|
|
|
|
|
|
|
// Response: "Authorized" should *not* exist on DOM
|
|
|
|
// Response: "Authorized" should *not* exist on DOM
|
|
|
|
// TBD: cy.get('.auth-container').contains('Authorized').should('not.exist')
|
|
|
|
// TBD: cy.get('.auth-container').contains('Authorized').should('not.exist')
|
|
|
|
cy.get('.btn-done').click() |
|
|
|
cy.get('.btn-done').click() |
|
|
|
|
|
|
|
|
|
|
|
// Authorize button should be UNLOCKED now
|
|
|
|
// Authorize button should be UNLOCKED now
|
|
|
|
// TBD: cy.get('[class="btn authorize unlocked"]').should('exist')
|
|
|
|
// TBD: cy.get('[class="btn authorize unlocked"]').should('exist')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it("Execute Authentication (invalid token case) > GET: User details API", ()=> {
|
|
|
|
it("Execute Authentication (invalid token case) > GET: User details API", ()=> {
|
|
|
|
// Auth> User details API
|
|
|
|
// Auth> User details API
|
|
|
|
getSwaggerButton("Authentication", 6, "User details").click() |
|
|
|
getSwaggerButton("Authentication", 6, "User details").click() |
|
|
|
|
|
|
|
|
|
|
|
// "Try it out" button, followed by "Execute"
|
|
|
|
// "Try it out" button, followed by "Execute"
|
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
cy.get('.execute-wrapper > .btn').click() |
|
|
|
cy.get('.execute-wrapper > .btn').click() |
|
|
|
|
|
|
|
|
|
|
|
// check response: email credentials shouldnt exist. should display 'guest:true'
|
|
|
|
// check response: email credentials shouldnt exist. should display 'guest:true'
|
|
|
|
cy.get('.highlight-code > .microlight').contains('guest').should('exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains('guest').should('exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains('email').should('not.exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains('email').should('not.exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('not.exist') |
|
|
|
cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('not.exist') |
|
|
|
|
|
|
|
|
|
|
|
// reset operations (clear, cancel, windback User details tab)
|
|
|
|
// reset operations (clear, cancel, windback User details tab)
|
|
|
|
cy.get('.btn-clear').click() |
|
|
|
cy.get('.btn-clear').click() |
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
cy.get('.try-out > .btn').click() |
|
|
|
getSwaggerButton("Authentication", 6, "User details").click()
|
|
|
|
getSwaggerButton("Authentication", 6, "User details").click()
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// clean-up created file (shared.json)
|
|
|
|
// clean-up created file (shared.json)
|
|
|
|
after(() => { |
|
|
|
after(() => { |
|
|
|
cy.exec("del shared.json").then(()=> { |
|
|
|
cy.exec("del shared.json").then(()=> { |
|
|
|
cy.log("file cleaned up!") |
|
|
|
cy.log("file cleaned up!") |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
})
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// genTest('rest', false)
|
|
|
|
// genTest('rest', false)
|
|
|
|