-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathsocksProxy.test.ts
37 lines (29 loc) · 1.13 KB
/
socksProxy.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { describe, expect, it } from '@jest/globals';
import { isLocalOrReservedIP } from './socksProxy';
describe('isLocalOrReservedIP', () => {
it('should return true for localhost', () => {
expect(isLocalOrReservedIP('localhost:8080')).toBeTruthy();
});
it('should return true for private IP', () => {
expect(isLocalOrReservedIP('192.168.1.1')).toBeTruthy();
});
it('should return true for loopback IP', () => {
expect(isLocalOrReservedIP('127.0.0.1')).toBeTruthy();
expect(isLocalOrReservedIP('::1')).toBeTruthy();
});
it('should return false for public IP', () => {
expect(isLocalOrReservedIP('8.8.8.8')).toBeFalsy();
});
it('should return false for invalid IP', () => {
expect(isLocalOrReservedIP('invalid.ip')).toBeFalsy();
});
it('should return true for unique local addresses', () => {
expect(isLocalOrReservedIP('fc00::')).toBeTruthy();
});
it('should return true for multicast addresses', () => {
expect(isLocalOrReservedIP('ff00::')).toBeTruthy();
});
it('should return false when IP address is not provided', () => {
expect(isLocalOrReservedIP('')).toBeFalsy();
});
});