diff --git a/test/support/pages/common.js b/test/support/pages/common.js index afb4995c6712b..e5d50d4092d77 100644 --- a/test/support/pages/common.js +++ b/test/support/pages/common.js @@ -10,6 +10,9 @@ define(function (require) { var parse = require('intern/dojo/node!url').parse; var format = require('intern/dojo/node!url').format; var path = require('intern/dojo/node!path'); + var ShieldPage = require('../../support/pages/shield_page'); + + var shieldPage; function injectTimestampQuery(func, url) { var formatted = modifyQueryString(url, function (parsed) { @@ -43,6 +46,7 @@ define(function (require) { remote.get.wrapper = injectTimestampQuery; this.remote.getCurrentUrl = _.wrap(this.remote.getCurrentUrl, removeTimestampQuery); } + shieldPage = new ShieldPage(this.remote); } @@ -90,6 +94,20 @@ define(function (require) { .then(function () { return self.remote.getCurrentUrl(); }) + .then(function (currentUrl) { + var loginPage = new RegExp('login').test(currentUrl); + if (loginPage) { + self.debug('Found loginPage = ' + loginPage + ', username = ' + + config.servers.kibana.shield.username); + return shieldPage.login(config.servers.kibana.shield.username, + config.servers.kibana.shield.password) + .then(function () { + return self.remote.getCurrentUrl(); + }); + } else { + return currentUrl; + } + }) .then(function (currentUrl) { currentUrl = currentUrl.replace(/\/\/\w+:\w+@/, '//'); var navSuccessful = new RegExp(appUrl).test(currentUrl); diff --git a/test/support/pages/shield_page.js b/test/support/pages/shield_page.js new file mode 100644 index 0000000000000..0df4b5cddca4c --- /dev/null +++ b/test/support/pages/shield_page.js @@ -0,0 +1,35 @@ +// in test/support/pages/shield_page.js +define(function (require) { + var config = require('intern').config; + var defaultTimeout = config.timeouts.default; + + // the page object is created as a constructor + // so we can provide the remote Command object + // at runtime + function ShieldPage(remote) { + this.remote = remote; + } + + ShieldPage.prototype = { + constructor: ShieldPage, + + login: function login(user, pwd) { + var remote = this.remote; + return remote.setFindTimeout(5000) + .findById('username') + .type(user) + .then(function () { + return remote.findById('password') + .type(pwd); + }) + .then(function () { + return remote.findByCssSelector('.btn') + .click(); + }); + } + + + }; + + return ShieldPage; +});