Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/insomnia/src/network/__tests__/network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,32 @@ describe('getCurrentUrl for tough-cookie', () => {
});
});

describe('getOrInheritAuthentication', () => {
it('should prefer the closest parent folder auth over higher-level folder auth', () => {
const request = { authentication: {} };
const requestGroups = [
{ authentication: { type: 'basic', username: 'closest', password: 'closest-pass' } },
{ authentication: { type: 'basic', username: 'root', password: 'root-pass' } },
];

expect(networkUtils.getOrInheritAuthentication({ request, requestGroups })).toEqual({
type: 'basic',
username: 'closest',
password: 'closest-pass',
});
});

it("should stop inheritance when the closest parent folder auth is { type: 'none' }", () => {
const request = { authentication: {} };
const requestGroups = [
{ authentication: { type: 'none' } },
{ authentication: { type: 'basic', username: 'root', password: 'root-pass' } },
];

expect(networkUtils.getOrInheritAuthentication({ request, requestGroups })).toEqual({ type: 'none' });
});
});

describe('getOrInheritHeaders', () => {
it('should combine headers', () => {
const requestGroups = [{ headers: [{ name: 'foo', value: 'bar' }] }, { headers: [{ name: 'baz', value: 'qux' }] }];
Expand Down
Loading