mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Fixed test.
This commit is contained in:
parent
b5795a8b3f
commit
6135ef9dd2
1 changed files with 8 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import * as detect from '../detect';
|
import { getIpAddress } from '../ip';
|
||||||
|
|
||||||
const IP = '127.0.0.1';
|
const IP = '127.0.0.1';
|
||||||
const BAD_IP = '127.127.127.127';
|
const BAD_IP = '127.127.127.127';
|
||||||
|
|
@ -6,23 +6,23 @@ const BAD_IP = '127.127.127.127';
|
||||||
test('getIpAddress: Custom header', () => {
|
test('getIpAddress: Custom header', () => {
|
||||||
process.env.CLIENT_IP_HEADER = 'x-custom-ip-header';
|
process.env.CLIENT_IP_HEADER = 'x-custom-ip-header';
|
||||||
|
|
||||||
expect(detect.getIpAddress(new Headers({ 'x-custom-ip-header': IP }))).toEqual(IP);
|
expect(getIpAddress(new Headers({ 'x-custom-ip-header': IP }))).toEqual(IP);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getIpAddress: CloudFlare header', () => {
|
test('getIpAddress: CloudFlare header', () => {
|
||||||
expect(detect.getIpAddress(new Headers({ 'cf-connecting-ip': IP }))).toEqual(IP);
|
expect(getIpAddress(new Headers({ 'cf-connecting-ip': IP }))).toEqual(IP);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getIpAddress: Standard header', () => {
|
test('getIpAddress: Standard header', () => {
|
||||||
expect(detect.getIpAddress(new Headers({ 'x-forwarded-for': IP }))).toEqual(IP);
|
expect(getIpAddress(new Headers({ 'x-forwarded-for': IP }))).toEqual(IP);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getIpAddress: CloudFlare header is lower priority than standard header', () => {
|
test('getIpAddress: CloudFlare header is lower priority than standard header', () => {
|
||||||
expect(
|
expect(getIpAddress(new Headers({ 'cf-connecting-ip': BAD_IP, 'x-forwarded-for': IP }))).toEqual(
|
||||||
detect.getIpAddress(new Headers({ 'cf-connecting-ip': BAD_IP, 'x-forwarded-for': IP })),
|
IP,
|
||||||
).toEqual(IP);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getIpAddress: No header', () => {
|
test('getIpAddress: No header', () => {
|
||||||
expect(detect.getIpAddress(new Headers())).toEqual(null);
|
expect(getIpAddress(new Headers())).toEqual(null);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue