Spaces:
Sleeping
Sleeping
Download src/lib/__tests__/browser-security.test.ts from tao-shen/HuggingClaw-MissionControl: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/tao-shen/HuggingClaw-MissionControl/resolve/main/src/lib/__tests__/browser-security.test.ts
- Command line
-
hf download hf://spaces/tao-shen/HuggingClaw-MissionControl/src/lib/__tests__/browser-security.test.ts
-
curl -L -o browser-security.test.ts https://huggingface.co/spaces/tao-shen/HuggingClaw-MissionControl/resolve/main/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) | |
| }) | |
| }) | |