From edce7ffb4a3292c4f70e7cbfe3433641d381a6dc Mon Sep 17 00:00:00 2001 From: Ramon Ramirez Date: Thu, 4 Dec 2014 17:38:13 +0100 Subject: [PATCH] primitive auth workaround --- lib/dalek/actions.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/dalek/actions.js b/lib/dalek/actions.js index 9301c31..9542200 100644 --- a/lib/dalek/actions.js +++ b/lib/dalek/actions.js @@ -27,6 +27,7 @@ var Q = require('q'); var uuid = require('./uuid'); var cheerio = require('cheerio'); +var urlParser = require('url'); // int. global var reporter = null; @@ -170,10 +171,15 @@ Actions.prototype.mouseEvent = function (type, selector) { * @return {Actions} */ -Actions.prototype.setHttpAuth = function (username, password) { - var hash = uuid(); - var cb = this._generateCallbackAssertion('setHttpAuth', 'setHttpAuth', username, password, hash); - this._addToActionQueue([username, password, hash], 'setHttpAuth', cb); +Actions.prototype.setHttpAuth = function (username, password, location) { + if(username !== '' || password !== ''){ + var tmpUrl = urlParser.parse(location); + tmpUrl.auth = username + ':' + password; + location = urlParser.format(tmpUrl); + var hash = uuid(); + var cb = this._generateCallbackAssertion('open', 'open', location, hash); + this._addToActionQueue([location, hash], 'open', cb); + } return this; };