From 812f6d908e70a481d78de645ced6dd26f1e0114b Mon Sep 17 00:00:00 2001 From: dp Date: Tue, 5 Mar 2019 21:24:02 +0100 Subject: [PATCH 1/5] update minor fixes in secrity ui --- conf.json | 11 +- cypress/integration/agile-ui-security.js | 497 ++++++++++++++--------- cypress/integration/small-test.js | 117 ++++++ 3 files changed, 424 insertions(+), 201 deletions(-) create mode 100644 cypress/integration/small-test.js diff --git a/conf.json b/conf.json index ecedfff..598e85c 100644 --- a/conf.json +++ b/conf.json @@ -1,8 +1,8 @@ { - "host": "192.168.1.106", - "UI_URL": "http://192.168.1.106:2000", - "TOKEN_URL": "http://192.168.1.106:3000/oauth2/token", - "client": "tester", + "host": "localhost", + "UI_URL": "http://localhost:2000", + "TOKEN_URL": "http://localhost:3000/oauth2/token", + "client": "wordpress", "clientsecret": "secret", "adminuser": "agile", "adminusersecret": "secret", @@ -14,6 +14,7 @@ "data": "DummyData" }, "tabs": { + "length" : 7, "discover": { "index": 0 }, @@ -53,4 +54,4 @@ "path": "/add/group" } } -} \ No newline at end of file +} diff --git a/cypress/integration/agile-ui-security.js b/cypress/integration/agile-ui-security.js index 8cb6d3e..bfbc11a 100644 --- a/cypress/integration/agile-ui-security.js +++ b/cypress/integration/agile-ui-security.js @@ -30,27 +30,26 @@ let user_auth = { } } -function adminAuthAndVisitUI() { - return new Promise(() => { - cy.request(admin_auth).then(res => { +function visitAndAuthUI(auth_data){ + cy.request(auth_data).then((res)=>{ let token = res.body.access_token cy.visit(conf.UI_URL + '?token=' + token) + cy.log(conf.UI_URL + '?token=' + token) }) - }) + +} + +function adminAuthAndVisitUI() { + return visitAndAuthUI(admin_auth) } function userAuthAndVisitUI() { - return new Promise(() => { - cy.request(user_auth).then(res => { - let token = res.body.access_token - cy.visit(conf.UI_URL + '?token=' + token) - }) - }) + return visitAndAuthUI(user_auth) } function expand(group) { return cy.location().then(loc => { - cy.wait(1000) + //cy.wait(1000) let parts = loc.pathname.split('/') if(!group) { @@ -68,219 +67,325 @@ function expand(group) { }) } + +describe('Security Admin', () => { + beforeEach(() => { + adminAuthAndVisitUI() + }) + + it('Create, assign and delete group', () => { + cy.get('#navigation').find('button').should('have.length', conf.tabs.length) + cy.get('#navigation').get('button').then(tabs => { + tabs[conf.tabs.groups.index].click() + cy.get('#cypress-agile-local').should('not.exist') + }) + + //Create group + cy.get('#navigation').get('button').then(tabs => { + tabs[conf.tabs.groups.index].click() + let regex = new RegExp(conf.tabs.groups.path.replace(/:[a-zA-Z]*/, '.*')) + cy.url().should('match', regex) + //cy.wait(500) + cy.get('#new_entity_button').click() + cy.get('#root_group_name').type('cypress-group') + cy.get('button[type="submit"]').click() + //cy.wait(500) + }) + + //Assign group + cy.get('#navigation').get('button').then(tabs => { + tabs[conf.tabs.userlist.index].click() + cy.location('pathname').should('eq', conf.tabs.userlist.path) + cy.get('#group_' + conf.adminuser + '-agile-local').click() + //cy.wait(1000) + cy.get('#root_groups').should('exist') + cy.get('#root_groups').contains('cypress-group').find(':checkbox').should('be.not.checked') + cy.get('#root_groups').contains('cypress-group').find(':checkbox').check() + cy.get('button[type="submit"]').then(submit => { + submit.click() + //cy.wait(3000) + tabs[conf.tabs.groups.index].click() + }) + cy.get('#view_cypress-group-' + conf.adminuser + '-agile-local').click() + expand(true) + //cy.wait(1000) + cy.get('#root-entities').should('contain', conf.adminuser + '!@!agile-local') + }) + + //Remove user from group + cy.get('#navigation').get('button').then(tabs => { + tabs[conf.tabs.userlist.index].click() + cy.location('pathname').should('eq', conf.tabs.userlist.path) + cy.get('#group_' + conf.adminuser + '-agile-local').click() + //cy.wait(1000) + cy.get('#root_groups').should('exist') + cy.get('#root_groups').contains('cypress-group').find(':checkbox').should('be.checked') + cy.get('#root_groups').contains('cypress-group').find(':checkbox').uncheck() + cy.get('button[type="submit"]').then(submit => { + submit.click() + //cy.wait(3000) + tabs[conf.tabs.groups.index].click() + }) + cy.get('#view_cypress-group-' + conf.adminuser + '-agile-local').click() + expand(true) + cy.get('#root-entities').should('not.contain', conf.adminuser + '!@!agile-local') + }) + + //Delete group + cy.get('#navigation').get('button').then(tabs => { + tabs[conf.tabs.groups.index].click() + cy.get('#cypress-group-' + conf.adminuser + '-agile-local').should('exist') + cy.get('#delete_cypress-group-' + conf.adminuser + '-agile-local').click() + //cy.wait(1000) + cy.get('#cypress-group-' + conf.adminuser + '-agile-local').should('not.exist') + }) + }) + + it('Create and delete entities', () => { + cy.get('#navigation').find('button').should('have.length', conf.tabs.length) + cy.get('#navigation').get('button').then(tabs => { + tabs[conf.tabs.userlist.index].click() + cy.get('#cypress-agile-local').should('not.exist') + }) + + cy.get('#navigation').get('button').then(tabs => { + tabs[conf.tabs.userlist.index].click() + let regex = new RegExp(conf.tabs.userlist.path.replace(/:[a-zA-Z]*/, '.*')) + cy.url().should('match', regex) + //cy.wait(1500) + cy.get('#new_entity_button').click() + cy.location('pathname').should('eq', conf.views.addUser.path) + cy.get('#root_user_name').type('cypress') + cy.get('#root_auth_type').select('agile-local') + cy.get('#root_password').type('secret') + cy.get('#root_role').select('admin') + cy.get('button[type="submit"]').click() + //cy.wait(3000) + + }) + + cy.get('#navigation').get('button').then(tabs => { + let workingtab = conf.tabs.userlist + tabs[workingtab.index].click() + cy.get('#cypress-agile-local').should('exist') + cy.get('#delete_cypress-agile-local').click() + //cy.wait(3000) + cy.get('#cypress-agile-local').should('not.exist') + }) + }) + + + + it('Switch to user overview tab and view first user attributes', () => { + + cy.get('#navigation').find('button').should('have.length', conf.tabs.length) + cy.get('#navigation').get('button').then(tabs => { + let workingtab = conf.tabs.userlist + tabs[workingtab.index].click() + cy.location('pathname').should('eq', workingtab.path) + //cy.wait(1500) + cy.get('#view_' + conf.adminuser + '-agile-local').click() //First user attributes //First user attributes + let regex = new RegExp(conf.views.user.path.replace(/:[a-zA-Z]*/, '.*')) + cy.url().should('match', regex) + //cy.wait(1500) + cy.get('#new_password').should('exist') + cy.get('#old_password').should('exist') + expand() + cy.get('span').contains('id').should('be.visible') + }) + }) + + it('Switch to user overview tab and view second user attributes', () => { + + cy.get('#navigation').find('button').should('have.length', conf.tabs.length) + cy.get('#navigation').get('button').then(tabs => { + let workingtab = conf.tabs.userlist + tabs[workingtab.index].click() + cy.location('pathname').should('eq', workingtab.path) + cy.wait(1500) + cy.get('#view_' + conf.user + '-agile-local').click() //First user attributes //Second user attributes + let regex = new RegExp(conf.views.user.path.replace(/:[a-zA-Z]*/, '.*')) + cy.url().should('match', regex) + //cy.wait(1500) + cy.get('#new_password').should('exist') + cy.get('#old_password').should('not.exist') + expand() + cy.get('span').contains('id').should('be.visible') + }) + }) + + describe('Security User', () => { beforeEach(() => { userAuthAndVisitUI() - cy.wait(3000) //Let react load all state objects + //cy.wait(3000) //Let react load all state objects }) it('Create, assign and delete group', () => { - let tabs = undefined - cy.get('#navigation').get('button').then(t => { - tabs = t - return tabs[conf.tabs.groups.index].click() - }).then(()=>{ - return cy.get('#cypress-agile-local').should('not.exist') - }).then(( )=> { - //Create group - return cy.get('#navigation').get('button') - }).then(t => { - tabs = t - return tabs[conf.tabs.groups.index].click() - }).then( ()=>{ + //cy.wait(500) + // this ensures that the tabs have been loaded + cy.get('#navigation').find('button').should('have.length', conf.tabs.length) + + cy.get('#navigation').get('button').then(tabs => { + //tabs.should('have.length', 4) + tabs[conf.tabs.groups.index].click() + cy.get('#cypress-agile-local').should('not.exist') + }) + + //Create group + cy.get('#navigation').as('mynavigation') + cy.get('@mynavigation').get('button').then(tabs => { + tabs[conf.tabs.groups.index].click() let regex = new RegExp(conf.tabs.groups.path.replace(/:[a-zA-Z]*/, '.*')) - return cy.url().should('match', regex) - }).then(()=>{ - return cy.get('#new_entity_button').click() - }).then(()=>{ + cy.url().should('match', regex) + cy.get('#new_entity_button').click() cy.get('#root_group_name').type('cypress-group') - return cy.get('button[type="submit"]').click() - }).then(()=>{ - return cy.get('#navigation').get('button') - }).then(t => { - tabs = t - //Assign group - return tabs[conf.tabs.userlist.index].click() - }).then(()=>{ - return cy.location('pathname').should('eq', conf.tabs.userlist.path) - }).then(()=>{ - return cy.get('#group_' + conf.adminuser + '-agile-local').click() - }).then(()=>{ - return cy.get('#root_groups').should('exist') - }).then(()=>{ - return cy.get('#root_groups').contains('cypress-group').find(':checkbox').should('be.not.checked') - }).then(()=>{ - return cy.get('#root_groups').contains('cypress-group').find(':checkbox').check() - }).then(()=>{ - return cy.get('button[type="submit"]').click() - }).then(()=>{ - return tabs[conf.tabs.groups.index].click() - }).then(()=>{ - return cy.get('#view_cypress-group-' + conf.user + '-agile-local').click() - }).then(()=>{ - expand(true) - cy.wait(4000) - return cy.get('#root-entities').should('contain', 'agile!@!agile-local') - }).then(()=>{ - //Remove user from group - return cy.get('#navigation').get('button') - }).then(t => { - tabs = t - tabs[conf.tabs.userlist.index].click() - return cy.location('pathname').should('eq', conf.tabs.userlist.path) - }).then(()=>{ - return cy.get('#group_' + conf.adminuser + '-agile-local').click() - }).then(()=>{ - return cy.get('#root_groups').should('exist') - }).then(()=>{ - return cy.get('#root_groups').contains('cypress-group').find(':checkbox').should('be.checked') - }).then(()=>{ - return cy.get('#root_groups').contains('cypress-group').find(':checkbox').uncheck() - }).then(()=>{ - return cy.get('button[type="submit"]') - - }).then(submit => { - return submit.click() - }).then(()=>{ + cy.get('button[type="submit"]').click() + }) + + //Assign group + cy.get('#navigation').get('button').then(tabs => { + tabs[conf.tabs.userlist.index].click() + cy.location('pathname').should('eq', conf.tabs.userlist.path) + cy.get('#group_' + conf.adminuser + '-agile-local').click() + cy.get('#root_groups').should('exist') + cy.get('#root_groups').contains('cypress-group').find(':checkbox').should('be.not.checked') + cy.get('#root_groups').contains('cypress-group').find(':checkbox').check() + cy.get('button[type="submit"]').then(submit => { + submit.click() + //cy.wait(3000) tabs[conf.tabs.groups.index].click() - return cy.get('#view_cypress-group-' + conf.user + '-agile-local').click() - }).then(()=>{ - expand(true) - cy.get('#root-entities').should('not.contain', conf.adminuser + '!@!agile-local') - }).then(() =>{ - //Delete group - cy.get('#navigation').get('button').then(tabs => { + }) + cy.get('#view_cypress-group-' + conf.user + '-agile-local').click() + expand(true) + //cy.wait(1000) + cy.get('#root-entities').should('contain', 'agile!@!agile-local') + }) + + //Remove user from group + cy.get('#navigation').get('button').then(tabs => { + tabs[conf.tabs.userlist.index].click() + cy.location('pathname').should('eq', conf.tabs.userlist.path) + cy.get('#group_' + conf.adminuser + '-agile-local').click() + //cy.wait(1000) + cy.get('#root_groups').should('exist') + cy.get('#root_groups').contains('cypress-group').find(':checkbox').should('be.checked') + cy.get('#root_groups').contains('cypress-group').find(':checkbox').uncheck() + cy.get('button[type="submit"]').then(submit => { + submit.click() + //cy.wait(3000) tabs[conf.tabs.groups.index].click() - cy.get('#cypress-group-' + conf.user + '-agile-local').should('exist') - return cy.get('#delete_cypress-group-' + conf.user + '-agile-local').click() - }).then(()=>{ - cy.get('#cypress-group-' + conf.user + '-agile-local').should('not.exist') + }) + cy.get('#view_cypress-group-' + conf.user + '-agile-local').click() + expand(true) + cy.get('#root-entities').should('not.contain', conf.adminuser + '!@!agile-local') }) + + //Delete group + cy.get('#navigation').get('button').then(tabs => { + tabs[conf.tabs.groups.index].click() + cy.get('#cypress-group-' + conf.user + '-agile-local').should('exist') + cy.get('#delete_cypress-group-' + conf.user + '-agile-local').click() + //cy.wait(1000) + cy.get('#cypress-group-' + conf.user + '-agile-local').should('not.exist') + }) + }) - }) + it('Create and delete entities', () => { - let workingtab = undefined + cy.get('#navigation').find('button').should('have.length', conf.tabs.length) + cy.get('#navigation').get('button').then(tabs => { + tabs[conf.tabs.userlist.index].click() + cy.get('#cypress-agile-local').should('not.exist') + }) + cy.get('#navigation').get('button').then(tabs => { - return tabs[conf.tabs.userlist.index].click() - }).then(()=>{ - return cy.get('#cypress-agile-local').should('not.exist') - }).then(()=>{ - return cy.get('#navigation').get('button') - }).then(tabs => { tabs[conf.tabs.userlist.index].click() let regex = new RegExp(conf.tabs.userlist.path.replace(/:[a-zA-Z]*/, '.*')) - return cy.url().should('match', regex) - }).then(()=>{ - return cy.get('#new_entity_button').click() - }).then(()=>{ - return cy.location('pathname').should('eq', conf.views.addUser.path) - }).then(()=>{ - return cy.get('#root_user_name').type('cypress') - }).then(()=>{ - - return cy.get('#root_auth_type').select('agile-local') - }).then(()=>{ - - return cy.get('#root_password').type('secret') - }).then(()=>{ - - return cy.get('#root_role').select('admin') - }).then(()=>{ - - return cy.get('button[type="submit"]').click() - }).then(()=>{ - return cy.get('#navigation').get('button') - }).then(tabs => { - workingtab = conf.tabs.userlist - return tabs[workingtab.index].click() - }).then(()=>{ + cy.url().should('match', regex) + //cy.wait(1500) + cy.get('#new_entity_button').click() + cy.location('pathname').should('eq', conf.views.addUser.path) + cy.get('#root_user_name').type('cypress') + cy.get('#root_auth_type').select('agile-local') + cy.get('#root_password').type('secret') + cy.get('#root_role').select('admin') + cy.get('button[type="submit"]').click() + //cy.wait(3000) + + }) + + cy.get('#navigation').get('button').then(tabs => { + let workingtab = conf.tabs.userlist + tabs[workingtab.index].click() cy.get('#cypress-agile-local').should('not.exist') }) }) it('Add and update attribute to own user entity and delete it', () => { - let workingtab = undefined + + cy.get('#navigation').find('button').should('have.length', conf.tabs.length) cy.get('#navigation').get('button').then(tabs => { - workingtab = conf.tabs.profile + let workingtab = conf.tabs.profile tabs[workingtab.index].click() let regex = new RegExp(workingtab.path.replace(/:[a-zA-Z]*/, '.*')) cy.url().should('match', regex) expand() - cy.wait(4000) - return cy.get('#cypress').should('not.exist') - }).then(()=>{ - return cy.get('span').contains('cypress').should('not.exist') - }).then(()=>{ - return cy.get('span').contains('cypress.value').should('not.exist') - }).then(()=>{ - return cy.get('#new-attribute').type('cypress') - }).then(()=>{ - return cy.get('#new-attribute-value').type('cypress.value') - }).then(()=>{ - return cy.get('#new-attribute-submit').click() - }).then(()=>{ - return cy.get('#cypress').should('exist') - }).then(()=>{ - return cy.get('#cypress_value').should('have.value', 'cypress.value') - }).then(()=>{ - return cy.get('#cypress_value').clear() - }).then(()=>{ - return cy.get('#cypress_value').type('updated.value') - }).then(()=>{ - return cy.get('#navigation') - }).then(()=>{ - return cy.get('#cypress_value').should('have.value', 'updated.value') - }).then(()=>{ - return cy.get('#delete_cypress').click() - }).then(()=>{ + cy.get('#cypress').should('not.exist') + cy.get('span').contains('cypress').should('not.exist') + cy.get('span').contains('cypress.value').should('not.exist') + cy.get('#new-attribute').type('cypress') + cy.get('#new-attribute-value').type('cypress.value') + cy.get('#new-attribute-submit').click() + cy.get('#cypress').should('exist') + cy.get('#cypress_value').should('have.value', 'cypress.value') + cy.get('#cypress_value').clear() + cy.get('#cypress_value').type('updated.value') + cy.get('#navigation') + cy.get('#cypress_value').should('have.value', 'updated.value') + cy.get('#delete_cypress').click() cy.get('#cypress').should('not.exist') }) }) - it('Switch to user overview tab and view first user attributes', () => { - let workingtab = undefined - cy.get('#navigation').get('button').then(tabs => { - workingtab = conf.tabs.userlist - return tabs[workingtab.index].click() - }).then(()=>{ - return cy.location('pathname').should('eq', workingtab.path) - }).then(()=>{ - return cy.get('#view_' + conf.adminuser + '-agile-local').click() //First user attributes - }).then(()=>{ - let regex = new RegExp(conf.views.user.path.replace(/:[a-zA-Z]*/, '.*')) - return cy.url().should('match', regex) - }).then(()=>{ - return cy.get('#' + conf.adminuser + '-agile-local') - }).then(()=>{ - return cy.get('#new_password').should('exist') - }).then(()=>{ - return cy.get('#old_password').should('not.exist') - }).then(()=>{ - expand() - cy.wait(4000) - cy.get('span').contains('id').should('be.visible') - }) - }) - - it('Switch to user overview tab and view second user attributes', () => { - let workingtab = undefined - cy.get('#navigation').get('button').then(tabs => { - workingtab = conf.tabs.userlist - return tabs[workingtab.index].click() - }).then(()=>{ - return cy.location('pathname').should('eq', workingtab.path) - }).then(()=>{ - return cy.get('#view_' + conf.user + '-agile-local').click() //First user attributes - }).then(()=>{ - let regex = new RegExp(conf.views.user.path.replace(/:[a-zA-Z]*/, '.*')) - return cy.url().should('match', regex) - }).then(()=>{ - return cy.get('#new_password').should('exist') - }).then(()=>{ - return cy.get('#old_password').should('exist') - }).then(()=>{ - expand() - cy.get('span').contains('id').should('be.visible') - }) - }) + + + it('Switch to user overview tab and view first user attributes', () => { + + cy.get('#navigation').find('button').should('have.length', conf.tabs.length) + cy.get('#navigation').get('button').then(tabs => { + let workingtab = conf.tabs.userlist + tabs[workingtab.index].click() + cy.location('pathname').should('eq', workingtab.path) + cy.wait(1500) + cy.get('#view_' + conf.adminuser + '-agile-local').click() //First user attributes + let regex = new RegExp(conf.views.user.path.replace(/:[a-zA-Z]*/, '.*')) + cy.url().should('match', regex) + cy.get('#' + conf.adminuser + '-agile-local') + cy.get('#new_password').should('not.exist') + cy.get('#old_password').should('not.exist') + expand() + cy.get('span').contains('id').should('be.visible') + }) + }) + + it('Switch to user overview tab and view second user attributes', () => { + cy.get('#navigation').find('button').should('have.length', conf.tabs.length) + cy.get('#navigation').get('button').then(tabs => { + let workingtab = conf.tabs.userlist + tabs[workingtab.index].click() + cy.location('pathname').should('eq', workingtab.path) + cy.wait(1500) + cy.get('#view_' + conf.user + '-agile-local').click() //First user attributes + let regex = new RegExp(conf.views.user.path.replace(/:[a-zA-Z]*/, '.*')) + cy.url().should('match', regex) + cy.wait(1500) + cy.get('#new_password').should('exist') + cy.get('#old_password').should('exist') + expand() + cy.get('span').contains('id').should('be.visible') + }) + }) + +}) }) diff --git a/cypress/integration/small-test.js b/cypress/integration/small-test.js new file mode 100644 index 0000000..a111649 --- /dev/null +++ b/cypress/integration/small-test.js @@ -0,0 +1,117 @@ +let conf = require('../../conf.json') + +let admin_auth = { + method: 'POST', + url: conf.TOKEN_URL, + auth: { + user: conf.client, + pass: conf.clientsecret + }, + form: true, + body: { + grant_type: 'password', + username: conf.adminuser, + password: conf.adminusersecret + } +} + +let user_auth = { + method: 'POST', + url: conf.TOKEN_URL, + auth: { + user: conf.client, + pass: conf.clientsecret + }, + form: true, + body: { + grant_type: 'password', + username: conf.user, + password: conf.usersecret + } +} + +function visitAndAuthUI(auth_data){ + cy.request(auth_data).then((res)=>{ + let token = res.body.access_token + cy.visit(conf.UI_URL + '?token=' + token) + cy.log(conf.UI_URL + '?token=' + token) + }) + +} + +function adminAuthAndVisitUI() { + return visitAndAuthUI(admin_auth) +} + +function userAuthAndVisitUI() { + return visitAndAuthUI(user_auth) +} + +function expand(group) { + return cy.location().then(loc => { + //cy.wait(1000) + let parts = loc.pathname.split('/') + + if(!group) { + let id = parts.find(part => { + return part.includes('!@!') + }) + cy.get('#' + id.replace('!@!', '-')).click('left') + } else { + let owner = parts.find(part => { + return part.includes('!@!') + }) + let id = parts[parts.length - 1] + cy.get('#' + id + '-' + owner.replace('!@!', '-')).click('left') + } + }) +} + + +describe('Security Admin', () => { + beforeEach(() => { + adminAuthAndVisitUI() + }) + + + it('Add and update attribute to own user entity and delete it', () => { + + cy.get('#navigation').find('button').should('have.length', conf.tabs.length) + cy.get('#navigation').get('button').then(tabs => { + let workingtab = conf.tabs.profile + tabs[workingtab.index].click() + let regex = new RegExp(workingtab.path.replace(/:[a-zA-Z]*/, '.*')) + cy.url().should('match', regex) + expand() + //cy.get('#cypress').should('not.exist') + //cy.get('span').contains('cypress').should('not.exist') + //cy.get('span').contains('cypress.value').should('not.exist') + cy.wait(500) + cy.get('#new-attribute-value').invoke('height').should('be.greaterThan', 0) + //cy.get('#new-attribute-value').should('exist') + //cy.get('#new-attribute-value').should('be.visible') + cy.get('#new-attribute-value').type('cypress.value') + + cy.wait(500) + cy.get('#new-attribute').invoke('height').should('be.greaterThan', 0) + //cy.get('#new-attribute').should('exist') + //cy.get('#new-attribute').should('be.visible') + cy.get('#new-attribute').type('cypress') + + cy.get('#new-attribute-submit').click() + cy.get('#cypress').should('exist') + cy.get('#cypress_value').should('have.value', 'cypress.value') + cy.get('#cypress_value').clear() + cy.get('#cypress_value').type('updated.value') + cy.get('#navigation') + cy.get('#cypress_value').should('have.value', 'updated.value') + cy.get('#delete_cypress').click() + cy.get('#cypress').should('not.exist') + }) + }) + + + + + +}) From 7305ff439958e40803ebbdc794955137a35644cf Mon Sep 17 00:00:00 2001 From: dp Date: Wed, 6 Mar 2019 07:34:50 +0100 Subject: [PATCH 2/5] updates --- cypress/integration/agile-ui-devices.js | 61 ------------------------ cypress/integration/agile-ui-security.js | 4 ++ 2 files changed, 4 insertions(+), 61 deletions(-) delete mode 100644 cypress/integration/agile-ui-devices.js diff --git a/cypress/integration/agile-ui-devices.js b/cypress/integration/agile-ui-devices.js deleted file mode 100644 index f49f605..0000000 --- a/cypress/integration/agile-ui-devices.js +++ /dev/null @@ -1,61 +0,0 @@ -let conf = require('../../conf.json') - -let admin_auth = { - method: 'POST', - url: conf.TOKEN_URL, - auth: { - user: conf.client, - pass: conf.clientsecret - }, - form: true, - body: { - grant_type: 'password', - username: conf.adminuser, - password: conf.adminusersecret - } -} - -function adminAuthAndVisitUI() { - return new Promise(() => { - cy.request(admin_auth).then(res => { - let token = res.body.access_token - cy.visit(conf.UI_URL + '?token=' + token) - }) - }) -} - -function expand() { - return cy.location().then(loc => { - cy.wait(1000) - let parts = loc.pathname.split('/') - let id = parts.find(part => { - return part.includes('!@!') - }) - cy.get('#' + id.replace('!@!', '-')).click('left') - }) -} - -describe('Devices', () => { - beforeEach(() => { - adminAuthAndVisitUI() - cy.wait(3000) //Let react load all state objects - }) - - it('Register device', () => { - cy.get('#navigation').get('button').then(tabs => { - tabs[conf.tabs.discover.index].click() - cy.get('#' + conf.dummy_device.id.replace(/:/g, '-')).should('exist') - cy.get('#register_' + conf.dummy_device.id.replace(/:/g, '-')).should('exist') - cy.get('#register_' + conf.dummy_device.id.replace(/:/g, '-')).click() - cy.get('span[role="menuitem"]').contains(conf.dummy_device.name).click() - }) - - cy.get('#navigation').get('button').then(tabs => { - tabs[conf.tabs.devices.index].click() - const id = conf.dummy_device.name.toLocaleLowerCase() + conf.dummy_device.id.replace(/:/g, '') - cy.get('#' + id).should('exist') - cy.get('#view_' + id).click() - cy.get('#graphdiv' + conf.dummy_device.data).should('be.visible') - }) - }) -}) \ No newline at end of file diff --git a/cypress/integration/agile-ui-security.js b/cypress/integration/agile-ui-security.js index bfbc11a..3b9d5fd 100644 --- a/cypress/integration/agile-ui-security.js +++ b/cypress/integration/agile-ui-security.js @@ -334,7 +334,11 @@ describe('Security User', () => { cy.get('#cypress').should('not.exist') cy.get('span').contains('cypress').should('not.exist') cy.get('span').contains('cypress.value').should('not.exist') + cy.wait(500) + cy.get('#new-attribute').invoke('height').should('be.greaterThan', 0) cy.get('#new-attribute').type('cypress') + cy.wait(500) + cy.get('#new-attribute-value').invoke('height').should('be.greaterThan', 0) cy.get('#new-attribute-value').type('cypress.value') cy.get('#new-attribute-submit').click() cy.get('#cypress').should('exist') From 95067346e84c39df22f0875022b9806c6e91cc0a Mon Sep 17 00:00:00 2001 From: dp Date: Wed, 6 Mar 2019 15:03:41 +0100 Subject: [PATCH 3/5] make sure that the combo box contains something --- conf.json | 3 +++ cypress/integration/agile-ui-security.js | 34 +++--------------------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/conf.json b/conf.json index 598e85c..50cd73e 100644 --- a/conf.json +++ b/conf.json @@ -13,6 +13,9 @@ "name": "Dummy", "data": "DummyData" }, + "auth_types":{ + "count":1 + }, "tabs": { "length" : 7, "discover": { diff --git a/cypress/integration/agile-ui-security.js b/cypress/integration/agile-ui-security.js index 3b9d5fd..b80d94e 100644 --- a/cypress/integration/agile-ui-security.js +++ b/cypress/integration/agile-ui-security.js @@ -156,6 +156,7 @@ describe('Security Admin', () => { cy.get('#new_entity_button').click() cy.location('pathname').should('eq', conf.views.addUser.path) cy.get('#root_user_name').type('cypress') + cy.get('#root_auth_type').find('*').should('have.length', conf.auth_types.count+1) cy.get('#root_auth_type').select('agile-local') cy.get('#root_password').type('secret') cy.get('#root_role').select('admin') @@ -307,6 +308,7 @@ describe('Security User', () => { cy.get('#new_entity_button').click() cy.location('pathname').should('eq', conf.views.addUser.path) cy.get('#root_user_name').type('cypress') + cy.get('#root_auth_type').find('*').should('have.length', conf.auth_types.count+1) cy.get('#root_auth_type').select('agile-local') cy.get('#root_password').type('secret') cy.get('#root_role').select('admin') @@ -322,37 +324,7 @@ describe('Security User', () => { }) }) - it('Add and update attribute to own user entity and delete it', () => { - - cy.get('#navigation').find('button').should('have.length', conf.tabs.length) - cy.get('#navigation').get('button').then(tabs => { - let workingtab = conf.tabs.profile - tabs[workingtab.index].click() - let regex = new RegExp(workingtab.path.replace(/:[a-zA-Z]*/, '.*')) - cy.url().should('match', regex) - expand() - cy.get('#cypress').should('not.exist') - cy.get('span').contains('cypress').should('not.exist') - cy.get('span').contains('cypress.value').should('not.exist') - cy.wait(500) - cy.get('#new-attribute').invoke('height').should('be.greaterThan', 0) - cy.get('#new-attribute').type('cypress') - cy.wait(500) - cy.get('#new-attribute-value').invoke('height').should('be.greaterThan', 0) - cy.get('#new-attribute-value').type('cypress.value') - cy.get('#new-attribute-submit').click() - cy.get('#cypress').should('exist') - cy.get('#cypress_value').should('have.value', 'cypress.value') - cy.get('#cypress_value').clear() - cy.get('#cypress_value').type('updated.value') - cy.get('#navigation') - cy.get('#cypress_value').should('have.value', 'updated.value') - cy.get('#delete_cypress').click() - cy.get('#cypress').should('not.exist') - }) - }) - - + it('Switch to user overview tab and view first user attributes', () => { cy.get('#navigation').find('button').should('have.length', conf.tabs.length) From fe0cc795db15deedad06fa3c409f916801c827d5 Mon Sep 17 00:00:00 2001 From: dp Date: Wed, 6 Mar 2019 16:38:08 +0100 Subject: [PATCH 4/5] update checks to ensure it is a span --- cypress/integration/agile-ui-security.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cypress/integration/agile-ui-security.js b/cypress/integration/agile-ui-security.js index b80d94e..db1b649 100644 --- a/cypress/integration/agile-ui-security.js +++ b/cypress/integration/agile-ui-security.js @@ -109,7 +109,8 @@ describe('Security Admin', () => { cy.get('#view_cypress-group-' + conf.adminuser + '-agile-local').click() expand(true) //cy.wait(1000) - cy.get('#root-entities').should('contain', conf.adminuser + '!@!agile-local') + cy.get('#root-entities').contains('span', conf.adminuser + '!@!agile-local') + //cy.get('#root-entities').should('contain', conf.adminuser + '!@!agile-local') }) //Remove user from group @@ -260,7 +261,8 @@ describe('Security User', () => { cy.get('#view_cypress-group-' + conf.user + '-agile-local').click() expand(true) //cy.wait(1000) - cy.get('#root-entities').should('contain', 'agile!@!agile-local') + cy.get('#root-entities').contains('span', conf.adminuser + '!@!agile-local') + //cy.get('#root-entities').should('contain', 'agile!@!agile-local') }) //Remove user from group @@ -324,7 +326,7 @@ describe('Security User', () => { }) }) - + it('Switch to user overview tab and view first user attributes', () => { cy.get('#navigation').find('button').should('have.length', conf.tabs.length) From fe358290686caf9f6bf2e1e5fed37f9b3f720247 Mon Sep 17 00:00:00 2001 From: dp Date: Wed, 6 Mar 2019 16:56:27 +0100 Subject: [PATCH 5/5] add cheks for combobox --- conf.json | 3 +++ cypress/integration/agile-ui-security.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/conf.json b/conf.json index 50cd73e..30cccfe 100644 --- a/conf.json +++ b/conf.json @@ -16,6 +16,9 @@ "auth_types":{ "count":1 }, + "roles":{ + "count":1 + }, "tabs": { "length" : 7, "discover": { diff --git a/cypress/integration/agile-ui-security.js b/cypress/integration/agile-ui-security.js index db1b649..2350bce 100644 --- a/cypress/integration/agile-ui-security.js +++ b/cypress/integration/agile-ui-security.js @@ -160,6 +160,7 @@ describe('Security Admin', () => { cy.get('#root_auth_type').find('*').should('have.length', conf.auth_types.count+1) cy.get('#root_auth_type').select('agile-local') cy.get('#root_password').type('secret') + cy.get('#root_role').find('*').should('have.length', conf.roles.count+1) cy.get('#root_role').select('admin') cy.get('button[type="submit"]').click() //cy.wait(3000) @@ -313,6 +314,7 @@ describe('Security User', () => { cy.get('#root_auth_type').find('*').should('have.length', conf.auth_types.count+1) cy.get('#root_auth_type').select('agile-local') cy.get('#root_password').type('secret') + cy.get('#root_role').find('*').should('have.length', conf.roles.count+1) cy.get('#root_role').select('admin') cy.get('button[type="submit"]').click() //cy.wait(3000)