Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should be able to verify JWT authentication on requests to API via custom cookie', (done) => {
const cookie = new Cookie({
key: 'my-cookie',
value: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ'
});
const jar = gatewayRequest.jar();
jar.setCookie(cookie.cookieString(), 'http://localhost:8001');
gatewayRequest.get({
jar: jar,
url: '/secure/get'
}, (error: any, response: any, body: any) => {
expect(response.statusCode).to.equal(200);
done();
});
});
puppeteerCookies.forEach(puppeteerCookie => {
cookies.push(
new Cookie({
key: puppeteerCookie.name,
value: puppeteerCookie.value,
domain: puppeteerCookie.domain,
path: puppeteerCookie.path,
httpOnly: puppeteerCookie.httpOnly,
secure: puppeteerCookie.secure
})
);
});
return cookies;
.map(function(c) {
var cookie;
if (typeof c === 'string')
cookie = Cookie.parse(c);
else
cookie = new Cookie(c);
cookie.domain = cookie.domain || purl.hostname;
cookie.path = cookie.path || '/';
return cookie;
})
.map(helpers.serializeCookie);
async function _getLoginCookie() {
const resCookie = _formatCookie((await request({
method: 'GET',
uri: 'http://www.luoo.net/',
headers: headers,
gzip: true,
resolveWithFullResponse: true
})).headers['set-cookie'][0]);
const cookie = new tough.Cookie({
key: "LUOOSESS",
value: resCookie.LUOOSESS,
domain: resCookie.domain,
path: resCookie.path
});
config.set({ LUOOSESS: cookie });
return cookie;
}
return Promise.mapSeries(this.request_defaults, rd => {
return context.requestDefaultsStore().putCookiePromise(new tough.Cookie(rd));
});
};
Object.keys(cookies).forEach((name) => {
const cookie = new Cookie({
key: name,
value: cookies[name]
})
jar.setCookieSync(cookie, url)
})
}
var cookieString = pool.map(function(c) {
if (typeof c === 'string')
return c;
else
return (new Cookie(c)).cookieString();
}).join('; ');
this.cookies.forEach(cookie => {
if (_.isPlainObject(cookie)) {
this.cookieJar.setCookie(new Cookie(cookie), fullUri)
} else if (_.isString(cookie)) {
this.cookieJar.setCookie(cookie, fullUri)
}
})
}
function _putCookie() {
!isObjectEmpty(config.get('LUOOSESS')) &&
cookieJar.setCookie(new tough.Cookie({
key: "LUOOSESS",
value: config.get('LUOOSESS').value,
domain: config.get('LUOOSESS').domain,
path: config.get('LUOOSESS').path
}), 'http://www.luoo.net');
!isObjectEmpty(config.get('lult')) &&
cookieJar.setCookie(new tough.Cookie({
key: "lult",
value: config.get('lult').value,
domain: config.get('lult').domain,
path: config.get('lult').path
}), 'http://www.luoo.net');
}
function _putCookie() {
!isObjectEmpty(config.get('LUOOSESS')) &&
cookieJar.setCookie(new tough.Cookie({
key: "LUOOSESS",
value: config.get('LUOOSESS').value,
domain: config.get('LUOOSESS').domain,
path: config.get('LUOOSESS').path
}), 'http://www.luoo.net');
!isObjectEmpty(config.get('lult')) &&
cookieJar.setCookie(new tough.Cookie({
key: "lult",
value: config.get('lult').value,
domain: config.get('lult').domain,
path: config.get('lult').path
}), 'http://www.luoo.net');
}