Spaces:
Runtime error
Runtime error
Download src/lib/__tests__/browser-security.test.ts from Powerman9x/HuggingClaw-MissionControl: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/Powerman9x/HuggingClaw-MissionControl/resolve/123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/src/lib/__tests__/browser-security.test.ts
- Command line
-
hf download hf://spaces/Powerman9x/HuggingClaw-MissionControl@123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/src/lib/__tests__/browser-security.test.ts
-
curl -L -o browser-security.test.ts https://huggingface.co/spaces/Powerman9x/HuggingClaw-MissionControl/resolve/123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/src/lib/__tests__/browser-security.test.ts
1.13 kB
| import { describe, expect, it } from 'vitest' | |
| import { isLocalDashboardHost, shouldRedirectDashboardToHttps } from '@/lib/browser-security' | |
| describe('isLocalDashboardHost', () => { | |
| it('treats localhost variants as local', () => { | |
| expect(isLocalDashboardHost('localhost')).toBe(true) | |
| expect(isLocalDashboardHost('127.0.0.1')).toBe(true) | |
| expect(isLocalDashboardHost('test.local')).toBe(true) | |
| }) | |
| }) | |
| describe('shouldRedirectDashboardToHttps', () => { | |
| it('does not redirect remote HTTP dashboards unless explicitly forced', () => { | |
| expect(shouldRedirectDashboardToHttps({ | |
| protocol: 'http:', | |
| hostname: '192.168.1.20', | |
| forceHttps: false, | |
| })).toBe(false) | |
| }) | |
| it('redirects remote HTTP dashboards only when forceHttps is enabled', () => { | |
| expect(shouldRedirectDashboardToHttps({ | |
| protocol: 'http:', | |
| hostname: 'example.tailnet.ts.net', | |
| forceHttps: true, | |
| })).toBe(true) | |
| }) | |
| it('never redirects localhost', () => { | |
| expect(shouldRedirectDashboardToHttps({ | |
| protocol: 'http:', | |
| hostname: 'localhost', | |
| forceHttps: true, | |
| })).toBe(false) | |
| }) | |
| }) | |