Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const auth = url.auth.split(':');
this.auth(auth[0], auth[1]);
}
if (this.username && this.password) {
this.auth(this.username, this.password);
}
for (const key in this.header) {
if (this.header.hasOwnProperty(key))
req.setHeader(key, this.header[key]);
}
// add cookies
if (this.cookies) {
if(this.header.hasOwnProperty('cookie')) {
// merge
const tmpJar = new CookieJar.CookieJar();
tmpJar.setCookies(this.header.cookie.split(';'));
tmpJar.setCookies(this.cookies.split(';'));
req.setHeader('Cookie',tmpJar.getCookies(CookieJar.CookieAccessInfo.All).toValueString());
} else {
req.setHeader('Cookie', this.cookies);
}
}
return req;
};
const auth = url.auth.split(':');
this.auth(auth[0], auth[1]);
}
if (this.username && this.password) {
this.auth(this.username, this.password);
}
for (const key in this.header) {
if (this.header.hasOwnProperty(key))
req.setHeader(key, this.header[key]);
}
// add cookies
if (this.cookies) {
if(this.header.hasOwnProperty('cookie')) {
// merge
const tmpJar = new CookieJar.CookieJar();
tmpJar.setCookies(this.header.cookie.split(';'));
tmpJar.setCookies(this.cookies.split(';'));
req.setHeader('Cookie',tmpJar.getCookies(CookieJar.CookieAccessInfo.All).toValueString());
} else {
req.setHeader('Cookie', this.cookies);
}
}
return req;
};
it('should set cookies', function () { // eslint-disable-line jasmine/no-spec-dupes
var accessInfo, cookies;
accessInfo = new CookieAccessInfo(domain, '/', true, false);
cookies = agent.cookieJar.getCookies(accessInfo);
cookies.length.should.eql(1);
});
});
"proxy" : typeof(desiredCapabilities.proxy) === "undefined" ?
_defaultCapabilities.proxy :
desiredCapabilities.proxy
},
// NOTE: This value is needed for Timeouts Upper-bound limit.
// "setTimeout/setInterval" accept only 32 bit integers, even though Number are all Doubles (go figure!)
// Interesting details here: {@link http://stackoverflow.com/a/4995054}.
_max32bitInt = Math.pow(2, 31) -1, //< Max 32bit Int
_timeouts = {
"script" : _max32bitInt,
"implicit" : 200, //< 200ms
"page load" : _max32bitInt,
},
_windows = {}, //< NOTE: windows are "webpage" in Phantom-dialect
_currentWindowHandle = null,
_cookieJar = require('cookiejar').create(),
_id = require("./third_party/uuid.js").v1(),
_inputs = ghostdriver.Inputs(),
_capsPageSettingsPref = "phantomjs.page.settings.",
_capsPageCustomHeadersPref = "phantomjs.page.customHeaders.",
_capsPageSettingsProxyPref = "proxy",
_pageSettings = {},
_additionalPageSettings = {
userName: null,
password: null
},
_pageCustomHeaders = {},
_log = ghostdriver.logger.create("Session [" + _id + "]"),
k, settingKey, headerKey, proxySettings;
var
/**
"webSecurityEnabled" : typeof(desiredCapabilities.webSecurityEnabled) === "undefined" ?
_defaultCapabilities.webSecurityEnabled :
desiredCapabilities.webSecurityEnabled
},
// NOTE: This value is needed for Timeouts Upper-bound limit.
// "setTimeout/setInterval" accept only 32 bit integers, even though Number are all Doubles (go figure!)
// Interesting details here: {@link http://stackoverflow.com/a/4995054}.
_max32bitInt = Math.pow(2, 31) -1, //< Max 32bit Int
_timeouts = {
"script" : 30000,
"implicit" : 0,
"page load" : 300000,
},
_windows = {}, //< NOTE: windows are "webpage" in Phantom-dialect
_currentWindowHandle = null,
_cookieJar = require('cookiejar').create(),
_id = require("./third_party/uuid.js").v1(),
_inputs = ghostdriver.Inputs(),
_capsPageSettingsPref = "phantomjs.page.settings.",
_capsPageCustomHeadersPref = "phantomjs.page.customHeaders.",
_capsPageZoomFactor = "phantomjs.page.zoomFactor",
_capsPageBlacklistPref = "phantomjs.page.blacklist",
_capsPageWhitelistPref = "phantomjs.page.whitelist",
_capsUnhandledPromptBehavior = "unhandledPromptBehavior",
_capsLoggingPref = "loggingPrefs",
_capsBrowserLoggerPref = "OFF",
_capsHarLoggerPref = "OFF",
_pageBlacklistFilter,
_pageWhitelistFilter,
_capsPageSettingsProxyPref = "proxy",
_pageSettings = {},
_pageZoomFactor = 1,
.then(res => {
const sessionCookie = new Cookie(res.header['set-cookie'][0]);
const cookieValue = decodeURIComponent(sessionCookie.value);
cookieValue.substr(0, 2).should.equal('s:');
return signature.unsign(cookieValue.substr(2), secret);
})
.then(decodedCookie => queryPromise('SELECT sid FROM session WHERE sid = $1', [decodedCookie]))
Assertion.addMethod('cookie', function (key, value) {
var header = getHeader(this._obj, 'set-cookie')
, cookie;
if (!header) {
header = (getHeader(this._obj, 'cookie') || '').split(';');
}
cookie = Cookie.CookieJar();
cookie.setCookies(header);
cookie = cookie.getCookie(key, new Cookie.CookieAccessInfo());
if (arguments.length === 2) {
this.assert(
cookie.value == value
, 'expected cookie \'' + key + '\' to have value #{exp} but got #{act}'
, 'expected cookie \'' + key + '\' to not have value #{exp}'
, value
, cookie.value
);
} else {
this.assert(
'undefined' !== typeof cookie || null === cookie
, 'expected cookie \'' + key + '\' to exist'
, 'expected cookie \'' + key + '\' to not exist'
Assertion.addMethod('cookie', function (key, value) {
var header = getHeader(this._obj, 'set-cookie')
, cookie;
if (!header) {
header = (getHeader(this._obj, 'cookie') || '').split(';');
}
if (this._obj instanceof chai.request.agent && this._obj.jar) {
cookie = this._obj.jar.getCookie(key, Cookie.CookieAccessInfo.All);
} else {
cookie = Cookie.CookieJar();
cookie.setCookies(header);
cookie = cookie.getCookie(key, Cookie.CookieAccessInfo.All);
}
if (arguments.length === 2) {
this.assert(
cookie.value == value
, 'expected cookie \'' + key + '\' to have value #{exp} but got #{act}'
, 'expected cookie \'' + key + '\' to not have value #{exp}'
, value
, cookie.value
);
} else {
this.assert(
'undefined' !== typeof cookie || null === cookie
, 'expected cookie \'' + key + '\' to exist'
Assertion.addMethod('cookie', function (key, value) {
var header = getHeader(this._obj, 'set-cookie')
, cookie;
if (!header) {
header = (getHeader(this._obj, 'cookie') || '').split(';');
}
if (this._obj instanceof chai.request.agent && this._obj.jar) {
cookie = this._obj.jar.getCookie(key, Cookie.CookieAccessInfo.All);
} else {
cookie = Cookie.CookieJar();
cookie.setCookies(header);
cookie = cookie.getCookie(key, Cookie.CookieAccessInfo.All);
}
if (arguments.length === 2) {
this.assert(
cookie.value == value
, 'expected cookie \'' + key + '\' to have value #{exp} but got #{act}'
, 'expected cookie \'' + key + '\' to not have value #{exp}'
, value
, cookie.value
);
} else {
this.assert(
'undefined' !== typeof cookie || null === cookie
, 'expected cookie \'' + key + '\' to exist'
this.cache.getHeaders(url, function (c) {
if (c) {
if (c['last-modifed']) {
h['if-modified-since'] = c['last-modified'];
}
if (c.etag) {
h['if-none-match'] = c.etag;
}
}
var cookies = self.jar.getCookies(cookiejar.CookieAccessInfo(u.host, u.pathname));
if (cookies) {
h.cookie = cookies.join(";");
}
request.get({url:url, headers:h, pool:self.pool}, function (e, resp, body) {
self.emit('log', debug, 'Response received for '+url+'.')
if (e) {
self.emit('log', error, e);
return;
}
if (resp.statusCode === 304) {
self.cache.get(url, function (c_) {
self._handler(url, referer, {fromCache:true, headers:c_.headers, body:c_.body})
});
return;
} else if (resp.statusCode !== 200) {