Matteo Scandolo | d3b57a1 | 2017-04-20 14:33:04 -0700 | [diff] [blame] | 1 | const fs = require('fs'); |
| 2 | const config = require('./config'); |
| 3 | const P = require('bluebird'); |
| 4 | |
| 5 | const username = 'xosadmin@opencord.org'; |
| 6 | |
| 7 | const getPwd = () => { |
| 8 | |
| 9 | if (process.env.UI_PWD) { |
| 10 | return process.env.UI_PWD; |
| 11 | } |
| 12 | |
| 13 | const pwdFile = fs.readFileSync('../../build/platform-install/credentials/xosadmin@opencord.org', 'utf8'); |
| 14 | return pwdFile; |
| 15 | }; |
| 16 | |
| 17 | exports.pwd = getPwd(); |
| 18 | |
| 19 | exports.username = username; |
| 20 | |
| 21 | exports.login = P.promisify((done) => { |
| 22 | browser.get(`${config.url}/login`); |
| 23 | |
| 24 | browser.getCurrentUrl() |
| 25 | .then((url) => { |
| 26 | // NOTE login only if it is not yet |
| 27 | if (url.indexOf('login') !== -1) { |
| 28 | const loginPage = require('../login/login.po'); |
| 29 | loginPage.sendUsername(username); |
| 30 | loginPage.sendPassword(getPwd()); |
| 31 | loginPage.submit(); |
| 32 | } |
| 33 | browser.waitForAngular(); |
| 34 | done(); |
| 35 | }); |
| 36 | }); |