mirror of
https://github.com/Kong/insomnia.git
synced 2026-09-18 02:56:36 -04:00
* fix: limit cookie template rendering to manually-set cookies and narrow template file access * fix: only expand nested templates for variable substitution, not direct tag output * test: cover OAuth2 access token exposure via the request tag for nested-template regression * sec: exclude response-sourced cookies from WebSocket/Socket.IO connect rendering * test: fix mTLS/cert smoke tests relying on secure-read-file path-prefix bug * test: scope mtls smoke test locator to avoid strict-mode collision * sec: close hard-link bypass of reserved NeDB database file check * fix: avoid doubled path separator when allowlisted folder is a filesystem root
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import type { CookieJar } from 'insomnia-data';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
import { migrate } from './cookie-jar';
|
|
|
|
function makeCookieJar(cookies: Partial<CookieJar['cookies'][number]>[]): CookieJar {
|
|
return { cookies } as CookieJar;
|
|
}
|
|
|
|
describe('migrateCookieSource()', () => {
|
|
it('grandfathers a pre-existing cookie with no source field in as manual', () => {
|
|
const jar = makeCookieJar([{ id: 'c1', key: 'legacy', value: '{{ _.base_url }}' }]);
|
|
const result = migrate(jar);
|
|
|
|
expect(result.cookies[0].source).toBe('manual');
|
|
});
|
|
|
|
it('leaves a cookie that already has a source untouched', () => {
|
|
const jar = makeCookieJar([{ id: 'c1', key: 'fromServer', source: 'response' }]);
|
|
const result = migrate(jar);
|
|
|
|
expect(result.cookies[0].source).toBe('response');
|
|
});
|
|
|
|
it('is idempotent across repeated migrations', () => {
|
|
const jar = makeCookieJar([{ id: 'c1', key: 'legacy' }]);
|
|
const once = migrate(jar);
|
|
const twice = migrate(once);
|
|
|
|
expect(twice.cookies[0].source).toBe('manual');
|
|
});
|
|
});
|
|
|
|
describe('migrateCookieId()', () => {
|
|
it('assigns an id to a cookie missing one', () => {
|
|
const jar = makeCookieJar([{ key: 'noId' }]);
|
|
const result = migrate(jar);
|
|
|
|
expect(result.cookies[0].id).toBeTruthy();
|
|
});
|
|
|
|
it('keeps an existing id unchanged', () => {
|
|
const jar = makeCookieJar([{ id: 'keep-me', key: 'hasId' }]);
|
|
const result = migrate(jar);
|
|
|
|
expect(result.cookies[0].id).toBe('keep-me');
|
|
});
|
|
});
|