mirror of
https://github.com/Kong/insomnia.git
synced 2026-11-08 14:03:29 -05:00
43 lines
1.8 KiB
TypeScript
43 lines
1.8 KiB
TypeScript
import { faker } from '@faker-js/faker';
|
|
import { ProjectType } from '@package/enums/project-types';
|
|
import { DEFAULT_TIMEOUT, test, WS_SERVER } from '@package/misc/fixtures';
|
|
import { Collection } from '@package/models/collection';
|
|
import { Project } from '@package/models/project';
|
|
import { expect } from "@playwright/test";
|
|
|
|
test('Verify WebSocket Connection Sends the Basic Authentication Header Until Authentication Is Set to None', async ({
|
|
user,
|
|
}) => {
|
|
const { webSocketRequestFlow, workspaceFlow } = user.flowManager;
|
|
|
|
const project = await workspaceFlow.createProject(new Project(faker.string.alphanumeric(10), ProjectType.Local));
|
|
const collection = await workspaceFlow.createCollection(project, new Collection(faker.string.alphanumeric(10)));
|
|
|
|
const username = faker.string.alphanumeric(8);
|
|
const password = faker.string.alphanumeric(12);
|
|
const request = await webSocketRequestFlow.create(collection, {
|
|
name: faker.string.alphanumeric(10),
|
|
url: WS_SERVER,
|
|
authentication: { type: 'basic', username, password },
|
|
});
|
|
await webSocketRequestFlow.send(request);
|
|
const authenticatedResponse = await webSocketRequestFlow.disconnect(request);
|
|
|
|
await expect
|
|
.poll(() => authenticatedResponse.console(), {
|
|
timeout: DEFAULT_TIMEOUT,
|
|
})
|
|
.toContain(`authorization: Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`);
|
|
|
|
await webSocketRequestFlow.setAuthentication(request, { type: 'none' });
|
|
await webSocketRequestFlow.send(request);
|
|
const unauthenticatedResponse = await webSocketRequestFlow.disconnect(request);
|
|
|
|
await expect
|
|
.poll(() => unauthenticatedResponse.console(), {
|
|
timeout: DEFAULT_TIMEOUT,
|
|
})
|
|
.toContain('host:');
|
|
expect(await unauthenticatedResponse.console()).not.toContain('authorization:');
|
|
});
|