diff --git a/integrationTests/adminFunctions.js b/integrationTests/adminFunctions.js index 36dad08d..aa1c322f 100644 --- a/integrationTests/adminFunctions.js +++ b/integrationTests/adminFunctions.js @@ -44,7 +44,8 @@ module.exports = class AdminFunctions{ await driver.wait(until.elementLocated(By.linkText(this.testuserName)),5000); await driver.findElement(By.linkText(this.testuserName)).click(); await driver.get(config.baseUrl + config.jenkinsContextPath + "/user/" + this.testuserName + "/delete"); - await driver.findElement(By.id("yui-gen2-button")).click();}; + await driver.findElement(By.id("yui-gen2-button")).click(); + }; async giveAdminRights(){ @@ -83,7 +84,6 @@ module.exports = class AdminFunctions{ async testUserLogin(driver) { await driver.wait(until.elementLocated(By.id('password')), 5000); - await driver.findElement(By.id('username')).sendKeys(this.testuserName); await driver.findElement(By.id('password')).sendKeys(this.testuserPasswort); await driver.findElement(By.css('input[name="submit"]')).click(); @@ -97,7 +97,6 @@ module.exports = class AdminFunctions{ }; async accessUsersJson(expectStatus){ - await request(config.baseUrl) .get(config.jenkinsContextPath+"/pluginManager/api/json") .auth(this.testuserName, this.testuserPasswort) diff --git a/integrationTests/cas-browser.spec.js b/integrationTests/cas-browser.spec.js index e7dda8a4..c39314b8 100644 --- a/integrationTests/cas-browser.spec.js +++ b/integrationTests/cas-browser.spec.js @@ -22,31 +22,31 @@ afterEach(() => { describe('cas browser login', () => { test('automatic redirect to cas login', async () => { - driver.get(config.baseUrl + config.jenkinsContextPath); + await driver.get(config.baseUrl + config.jenkinsContextPath); const url = await driver.getCurrentUrl(); expect(url).toMatch(loginUrl); }); test('login', async() => { - driver.get(utils.getCasUrl(driver)); - utils.login(driver); + await driver.get(utils.getCasUrl(driver)); + await utils.login(driver); const username = await driver.findElement(By.className('login')).getText(); expect(username).toContain(config.displayName); }); test('logout front channel', async() => { - driver.get(utils.getCasUrl(driver)); - utils.login(driver); - driver.findElement(By.xpath("//div[@id='header']/div[2]/span/a[2]/b")).click(); + await driver.get(utils.getCasUrl(driver)); + await utils.login(driver); + await driver.findElement(By.xpath("//div[@id='header']/div[2]/span/a[2]/b")).click(); const url = await driver.getCurrentUrl(); expect(url).toMatch(logoutUrl); }); test('logout back channel', async() => { - driver.get(utils.getCasUrl(driver)); - utils.login(driver); - driver.get(config.baseUrl + logoutUrl); - driver.get(config.baseUrl + config.jenkinsContextPath); + await driver.get(utils.getCasUrl(driver)); + await utils.login(driver); + await driver.get(config.baseUrl + logoutUrl); + await driver.get(config.baseUrl + config.jenkinsContextPath); const url = await driver.getCurrentUrl(); expect(url).toMatch(loginUrl); }); @@ -57,9 +57,9 @@ describe('cas browser login', () => { describe('browser attributes', () => { test('front channel user attributes', async () => { - driver.get(utils.getCasUrl(driver)); - utils.login(driver); - driver.get(config.baseUrl + config.jenkinsContextPath + "/user/" + config.username + "/configure"); + await driver.get(utils.getCasUrl(driver)); + await utils.login(driver); + await driver.get(config.baseUrl + config.jenkinsContextPath + "/user/" + config.username + "/configure"); const emailAddressInput = await driver.findElement(By.name("email.address")); const emailAddress = await emailAddressInput.getAttribute("value"); const usernameInput= await driver.findElement(By.name('_.fullName')); @@ -69,9 +69,9 @@ describe('browser attributes', () => { }); test('front channel user administrator', async () => { - driver.get(utils.getCasUrl(driver)); - utils.login(driver); - var isAdministrator = await utils.isAdministrator(driver); + await driver.get(utils.getCasUrl(driver)); + await utils.login(driver); + const isAdministrator = await utils.isAdministrator(driver); expect(isAdministrator).toBe(true); }); diff --git a/integrationTests/cas-rest.spec.js b/integrationTests/cas-rest.spec.js index 1a197f2f..76a46e57 100644 --- a/integrationTests/cas-rest.spec.js +++ b/integrationTests/cas-rest.spec.js @@ -32,11 +32,11 @@ describe('cas rest basic authentication', () => { /*login -> click on username -> configure -> show api token*/ test('authentication with API key', async () => { - driver.get(utils.getCasUrl(driver)); - utils.login(driver); - driver.get(config.baseUrl + config.jenkinsContextPath + "/user/" + config.username + "/configure"); - driver.wait(until.elementLocated(By.id('yui-gen1-button')), 5000); - driver.findElement(By.id("yui-gen1-button")).click(); + await driver.get(utils.getCasUrl(driver)); + await utils.login(driver); + await driver.get(config.baseUrl + config.jenkinsContextPath + "/user/" + config.username + "/configure"); + await driver.wait(until.elementLocated(By.id('yui-gen1-button')), 5000); + await driver.findElement(By.id("yui-gen1-button")).click(); const input = await driver.findElement(By.id("apiToken")); const apikey = await input.getAttribute("value"); await request(config.baseUrl) diff --git a/integrationTests/package.json b/integrationTests/package.json index 5d448e19..603e2570 100644 --- a/integrationTests/package.json +++ b/integrationTests/package.json @@ -10,7 +10,7 @@ "chromedriver": "^2.33.2", "jest": "^21.2.1", "jest-junit": "^3.1.0", - "selenium-webdriver": "^3.6.0", + "selenium-webdriver": "4.0.0-alpha.1", "supertest": "^3.0.0", "yarn": "^1.3.2" }, diff --git a/integrationTests/permissions-rest.spec.js b/integrationTests/permissions-rest.spec.js index 9d275e87..efd45dd0 100644 --- a/integrationTests/permissions-rest.spec.js +++ b/integrationTests/permissions-rest.spec.js @@ -1,12 +1,7 @@ - -const request = require('supertest'); const config = require('./config'); const AdminFunctions = require('./adminFunctions'); const utils = require('./utils'); const webdriver = require('selenium-webdriver'); -const By = webdriver.By; -const keys = webdriver.Key; -const until = webdriver.until; jest.setTimeout(30000); let driver; @@ -22,7 +17,6 @@ beforeEach(async() => { }); afterEach(async() => { - await adminFunctions.removeUser(driver); await driver.quit(); }); @@ -39,17 +33,16 @@ describe('administration rest tests', () => { }); test('rest - user (testUser) has no admin privileges', async() => { - driver.get(utils.getCasUrl(driver)); + await driver.get(utils.getCasUrl(driver)); await adminFunctions.accessUsersJson(403); }); test('rest - user (testUser) remove admin privileges', async() => { - - driver.get(utils.getCasUrl(driver)); - adminFunctions.testUserLogin(driver); + await driver.get(utils.getCasUrl(driver)); + await adminFunctions.testUserLogin(driver); await adminFunctions.testUserLogout(driver); - adminFunctions.takeAdminRights(); + await adminFunctions.takeAdminRights(); await driver.get(utils.getCasUrl(driver)); await adminFunctions.accessUsersJson(403); }); diff --git a/integrationTests/permissions.spec.js b/integrationTests/permissions.spec.js index a288393a..ace71ec7 100644 --- a/integrationTests/permissions.spec.js +++ b/integrationTests/permissions.spec.js @@ -15,7 +15,7 @@ let driver; let adminFunctions; beforeEach(async() => { - driver = utils.createDriver(webdriver); + driver = await utils.createDriver(webdriver); adminFunctions = new AdminFunctions('testUser', 'testUser', 'testUser', 'testUser@test.de', 'testuserpassword'); await adminFunctions.createUser(); }); @@ -34,7 +34,7 @@ describe('user permissions', () => { await adminFunctions.giveAdminRights(); await adminFunctions.testUserLogin(driver); await driver.wait(until.elementLocated(By.className('login')), 5000); - var adminPermissions = await utils.isAdministrator(driver); + const adminPermissions = await utils.isAdministrator(driver); expect(adminPermissions).toBe(true); }); @@ -42,7 +42,7 @@ describe('user permissions', () => { await driver.get(utils.getCasUrl(driver)); await adminFunctions.testUserLogin(driver); await driver.wait(until.elementLocated(By.className('login')), 5000); - var adminPermissions = await utils.isAdministrator(driver); + const adminPermissions = await utils.isAdministrator(driver); expect(adminPermissions).toBe(false); }); @@ -57,7 +57,7 @@ describe('user permissions', () => { await driver.get(utils.getCasUrl(driver)); await adminFunctions.testUserLogin(driver); await driver.wait(until.elementLocated(By.className('login')), 5000); - var adminPermissions = await utils.isAdministrator(driver); + const adminPermissions = await utils.isAdministrator(driver); expect(adminPermissions).toBe(false); }); diff --git a/integrationTests/utils.js b/integrationTests/utils.js index 895da152..9303b971 100644 --- a/integrationTests/utils.js +++ b/integrationTests/utils.js @@ -25,16 +25,16 @@ function createLocalDriver() { exports.getCasUrl = async function getCasUrl(driver){ - driver.get(config.baseUrl + config.jenkinsContextPath); + await driver.get(config.baseUrl + config.jenkinsContextPath); return driver.getCurrentUrl(); }; exports.login = async function login(driver) { - driver.wait(until.elementLocated(By.id('password')), 5000); - driver.wait(until.elementLocated(By.id('username')), 5000); + await driver.wait(until.elementLocated(By.id('password')), 5000); + await driver.wait(until.elementLocated(By.id('username')), 5000); - driver.findElement(By.id('username')).sendKeys(config.username); - driver.findElement(By.id('password')).sendKeys(config.password); + await driver.findElement(By.id('username')).sendKeys(config.username); + await driver.findElement(By.id('password')).sendKeys(config.password); return driver.findElement(By.css('input[name="submit"]')).click(); };