Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
currentUrl = urlResolve(currentUrl, newLocation.value);
}
}
// Update jar with Set-Cookie headers
for (const setCookieStr of setCookieStrings) {
try {
jar.setCookieSync(setCookieStr, currentUrl);
} catch (err) {
addTimelineText(`Rejected cookie: ${err.message}`);
}
}
// Update cookie jar if we need to and if we found any cookies
if (renderedRequest.settingStoreCookies && setCookieStrings.length) {
const cookies = await cookiesFromJar(jar);
await models.cookieJar.update(renderedRequest.cookieJar, { cookies });
}
// Print informational message
if (setCookieStrings.length > 0) {
const n = setCookieStrings.length;
if (renderedRequest.settingStoreCookies) {
addTimelineText(`Saved ${n} cookie${n === 1 ? '' : 's'}`);
} else {
addTimelineText(`Ignored ${n} cookie${n === 1 ? '' : 's'}`);
}
}
// Return the response data
const responsePatch = {
headers,
it('should get cookie by name', async () => {
const jar = jarFromCookies([]);
jar.setCookieSync(
[
'foo=bar',
'path=/',
'domain=.insomnia.rest',
'HttpOnly Cache-Control: public, no-cache',
].join('; '),
'https://insomnia.rest',
);
const cookies = await cookiesFromJar(jar);
const requests = [{ _id: 'req_1', parameters: [], url: 'https://insomnia.rest/foo/bar' }];
const jars = [{ _id: 'jar_1', parentId: 'wrk_1', cookies }];
const context = _getTestContext([{ _id: 'wrk_1' }], requests, jars);
try {
await tag.run(context, 'https://google.com/', '');
} catch (err) {
expect(err.message).toContain('No cookies in store for url "https://google.com/');
}
});
});