mirror of
https://github.com/umami-software/umami.git
synced 2026-05-30 06:47:25 +00:00
23 lines
645 B
TypeScript
23 lines
645 B
TypeScript
import { expect, test } from 'vitest';
|
|
import { getIpAddress } from './ip';
|
|
|
|
const IP = '127.0.0.1';
|
|
|
|
test('getIpAddress: Custom header', () => {
|
|
process.env.CLIENT_IP_HEADER = 'x-custom-ip-header';
|
|
|
|
expect(getIpAddress(new Headers({ 'x-custom-ip-header': IP }))).toEqual(IP);
|
|
});
|
|
|
|
test('getIpAddress: CloudFlare header', () => {
|
|
expect(getIpAddress(new Headers({ 'cf-connecting-ip': IP }))).toEqual(IP);
|
|
});
|
|
|
|
test('getIpAddress: Standard header', () => {
|
|
expect(getIpAddress(new Headers({ 'x-forwarded-for': IP }))).toEqual(IP);
|
|
});
|
|
|
|
test('getIpAddress: No header', () => {
|
|
expect(getIpAddress(new Headers())).toEqual(undefined);
|
|
});
|