feat: Enable go2rtc live stream proxying (#2159)

- Closes #1984
This commit is contained in:
Dermot Duffy
2025-08-28 21:19:19 -07:00
committed by GitHub
parent c3d95a5b32
commit bc5022ef1a
29 changed files with 479 additions and 282 deletions
+21
View File
@@ -7,6 +7,7 @@ import {
arrayMove,
aspectRatioToStyle,
contentsChanged,
convertHTTPAdressToWebsocket,
dayToDate,
desparsifyArrays,
errorToConsole,
@@ -514,3 +515,23 @@ describe('generateFloatApproximatelyEqualsCustomizer', () => {
});
});
});
describe('convertHTTPAdressToWebsocket', () => {
it('should convert http to ws', () => {
expect(convertHTTPAdressToWebsocket('http://example.com')).toBe('ws://example.com');
});
it('should convert https to ws', () => {
expect(convertHTTPAdressToWebsocket('https://example.com')).toBe(
'wss://example.com',
);
});
it('should not change ws url', () => {
expect(convertHTTPAdressToWebsocket('ws://example.com')).toBe('ws://example.com');
});
it('should not change wss url', () => {
expect(convertHTTPAdressToWebsocket('wss://example.com')).toBe('wss://example.com');
});
it('should handle mixed case', () => {
expect(convertHTTPAdressToWebsocket('HtTp://example.com')).toBe('ws://example.com');
});
});
-60
View File
@@ -1,60 +0,0 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
import { homeAssistantSignPath } from '../../src/ha/sign-path.js';
import { convertEndpointAddressToSignedWebsocket } from '../../src/utils/endpoint';
import { createHASS } from '../test-utils';
vi.mock('../../src/ha/sign-path.js');
describe('convertEndpointAddressToSignedWebsocket', () => {
it('without signing', async () => {
expect(
await convertEndpointAddressToSignedWebsocket(createHASS(), {
endpoint: 'http://example.com',
sign: false,
}),
).toBe('http://example.com');
});
describe('with signing', () => {
afterEach(() => {
vi.clearAllMocks();
});
it('successful', async () => {
vi.mocked(homeAssistantSignPath).mockResolvedValue('http://signed.com');
expect(
await convertEndpointAddressToSignedWebsocket(createHASS(), {
endpoint: 'http://example.com',
sign: true,
}),
).toBe('ws://signed.com');
});
it('with null response', async () => {
vi.mocked(homeAssistantSignPath).mockResolvedValue(null);
expect(
await convertEndpointAddressToSignedWebsocket(createHASS(), {
endpoint: 'http://example.com',
sign: true,
}),
).toBeNull();
});
it('with exception on signing', async () => {
const consoleSpy = vi.spyOn(global.console, 'warn').mockReturnValue(undefined);
vi.mocked(homeAssistantSignPath).mockRejectedValue(new Error());
expect(
await convertEndpointAddressToSignedWebsocket(createHASS(), {
endpoint: 'http://example.com',
sign: true,
}),
).toBeNull();
expect(consoleSpy).toBeCalled();
});
});
});