mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-27 06:34:06 +00:00
* fix(websocket): add API Key query params support and OAuth2 inheritance warning * add: playwright test
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
// Mock dependencies before requiring the module
|
|
const { prepareWsRequest } = require('../../src/ipc/network/ws-event-handlers');
|
|
|
|
describe('prepareWsRequest: API Key Query Params', () => {
|
|
const createMockItem = (authConfig = {}) => ({
|
|
uid: 'test-item-uid',
|
|
request: {
|
|
url: 'ws://localhost:3001',
|
|
headers: [],
|
|
body: {
|
|
mode: 'raw',
|
|
ws: []
|
|
},
|
|
auth: authConfig,
|
|
vars: { req: [], res: [] },
|
|
script: { req: '', res: '' }
|
|
}
|
|
});
|
|
|
|
const createMockCollection = (collectionAuth = null) => ({
|
|
uid: 'test-collection-uid',
|
|
pathname: '/test/path',
|
|
root: {
|
|
request: {
|
|
headers: [],
|
|
auth: collectionAuth || { mode: 'none' }
|
|
}
|
|
},
|
|
brunoConfig: {},
|
|
globalEnvironmentVariables: {},
|
|
promptVariables: {},
|
|
items: []
|
|
});
|
|
|
|
describe('API Key with Query Params placement', () => {
|
|
it('should append API key to URL when placement is queryparams', async () => {
|
|
const item = createMockItem({
|
|
mode: 'apikey',
|
|
apikey: {
|
|
key: 'apiKey',
|
|
value: 'test-api-key-123',
|
|
placement: 'queryparams'
|
|
}
|
|
});
|
|
const collection = createMockCollection();
|
|
const environment = { variables: [] };
|
|
const runtimeVariables = {};
|
|
|
|
const result = await prepareWsRequest(item, collection, environment, runtimeVariables);
|
|
|
|
expect(result.url).toContain('apiKey=test-api-key-123');
|
|
expect(result.url).toBe('ws://localhost:3001/?apiKey=test-api-key-123');
|
|
});
|
|
});
|
|
});
|