feat(desktop): support remote runtime headers
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { sanitizeRuntimeRequestHeaders } from './runtime-request-headers.mjs';
|
||||
|
||||
describe('sanitizeRuntimeRequestHeaders', () => {
|
||||
test('preserves safe custom headers', () => {
|
||||
expect(sanitizeRuntimeRequestHeaders({
|
||||
' CF-Access-Client-Id ': ' client-id ',
|
||||
'X-Custom-Header': 'value',
|
||||
})).toEqual({
|
||||
'CF-Access-Client-Id': 'client-id',
|
||||
'X-Custom-Header': 'value',
|
||||
});
|
||||
});
|
||||
|
||||
test('drops invalid and reserved headers', () => {
|
||||
expect(sanitizeRuntimeRequestHeaders({
|
||||
Authorization: 'Bearer proxy-token',
|
||||
'authorization': 'Bearer lower-token',
|
||||
'Bad:Name': 'value',
|
||||
'Bad\nName': 'value',
|
||||
'Bad-Value': 'line\nbreak',
|
||||
Empty: '',
|
||||
Good: 'ok',
|
||||
})).toEqual({ Good: 'ok' });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user