+ client: Move the client access check to the server-side
Squashed commit of the following: commit 1aab0f62e94ce665a1b996552fac41dc4e769b4d Merge: cdf5eb6ec1f5fdaeAuthor: ArtemBaskal <a.baskal@adguard.com> Date: Thu Sep 24 15:36:05 2020 +0300 Merge branch '1920-client-find' into feature/1925 commit cdf5eb6ea67a665d21a3155d8cf89bba9a5a9948 Merge: b6c20b1c10f67bd3Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Sep 23 20:28:51 2020 +0300 Merge branch 'master' into feature/1925 commit b6c20b1c7359a0e5902405b0551712f936848a80 Merge: 97d388ef96512433Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue Sep 15 10:44:25 2020 +0300 Merge branch 'master' into feature/1925 commit 97d388ef6571d590f21da00f86d889e881ca0c3d Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue Sep 15 10:30:50 2020 +0300 Extract buttons commit ca45fde11fc2b2812ff2b84dbd67aff0b5341be1 Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu Sep 10 12:46:09 2020 +0300 Handle errors in updateLogs commit f15e03c2e5a7115db984f70f72b0ddd870ece73d Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu Sep 10 12:39:34 2020 +0300 Update mobile block status on click commit 033b28db3b324f6d529ac1a0ef657886cdbe02bd Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Sep 9 20:53:42 2020 +0300 Fix mobile block buttons, auto open page on web serve start commit 2730937b23309167a066b9154728ac53ffe81a49 Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Sep 9 13:58:37 2020 +0300 Disable allow this client button when isNotInAllowedList is true commit 818cf869d63654c184762ad2701c4429a3e3011e Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Sep 9 13:06:01 2020 +0300 Update client block state on option click commit a072b8983757f419645c0207ea78e6e867c440cb Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue Sep 8 20:17:16 2020 +0300 Adapt to api changes commit 28ab2bd8b3f14f60bc822b5a69fa1801db67d816 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue Sep 8 14:12:20 2020 +0300 Change query log block confirm messages commit 9b0b6f6f9b1ec168fa71dbedd036152da59006e3 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue Sep 8 12:00:46 2020 +0300 Refactor inner work with disallowed commit 05f76154b8f489738d032fdaa835edb371ce70c7 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Sep 7 16:11:37 2020 +0300 + client: Move the client access check to the server-side
This commit is contained in:
@@ -1,136 +1,5 @@
|
||||
import {
|
||||
countClientsStatistics, findAddressType, getIpMatchListStatus, sortIp,
|
||||
} from '../helpers/helpers';
|
||||
import { ADDRESS_TYPES, IP_MATCH_LIST_STATUS } from '../helpers/constants';
|
||||
|
||||
describe('getIpMatchListStatus', () => {
|
||||
describe('IPv4', () => {
|
||||
test('should return EXACT on find the exact ip match', () => {
|
||||
const list = `127.0.0.2
|
||||
2001:db8:11a3:9d7:0:0:0:0
|
||||
192.168.0.1/8
|
||||
127.0.0.1
|
||||
127.0.0.3`;
|
||||
expect(getIpMatchListStatus('127.0.0.1', list))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.EXACT);
|
||||
});
|
||||
|
||||
test('should return CIDR on find the cidr match', () => {
|
||||
const list = `127.0.0.2
|
||||
2001:db8:11a3:9d7:0:0:0:0
|
||||
192.168.0.1/8
|
||||
127.0.0.0/24
|
||||
127.0.0.3`;
|
||||
expect(getIpMatchListStatus('127.0.0.1', list))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.CIDR);
|
||||
});
|
||||
|
||||
test('should return NOT_FOUND if the ip is not in the list', () => {
|
||||
const list = `127.0.0.1
|
||||
2001:db8:11a3:9d7:0:0:0:0
|
||||
192.168.0.1/8
|
||||
127.0.0.2
|
||||
127.0.0.3`;
|
||||
expect(getIpMatchListStatus('127.0.0.4', list))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.NOT_FOUND);
|
||||
});
|
||||
|
||||
test('should return the first EXACT or CIDR match in the list', () => {
|
||||
const list1 = `2001:db8:11a3:9d7:0:0:0:0
|
||||
127.0.0.1
|
||||
127.0.0.8/24
|
||||
127.0.0.3`;
|
||||
expect(getIpMatchListStatus('127.0.0.1', list1))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.EXACT);
|
||||
|
||||
const list2 = `2001:db8:11a3:9d7:ffff:ffff:ffff:ffff
|
||||
2001:0db8:11a3:09d7:0000:0000:0000:0000/64
|
||||
127.0.0.0/24
|
||||
127.0.0.1
|
||||
127.0.0.8/24
|
||||
127.0.0.3`;
|
||||
expect(getIpMatchListStatus('127.0.0.1', list2))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.CIDR);
|
||||
});
|
||||
});
|
||||
|
||||
describe('IPv6', () => {
|
||||
test('should return EXACT on find the exact ip match', () => {
|
||||
const list = `127.0.0.0
|
||||
2001:db8:11a3:9d7:0:0:0:0
|
||||
2001:db8:11a3:9d7:ffff:ffff:ffff:ffff
|
||||
127.0.0.1`;
|
||||
expect(getIpMatchListStatus('2001:db8:11a3:9d7:0:0:0:0', list))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.EXACT);
|
||||
});
|
||||
|
||||
test('should return EXACT on find the exact ip match of short and long notation', () => {
|
||||
const list = `127.0.0.0
|
||||
192.168.0.1/8
|
||||
2001:db8::
|
||||
127.0.0.2`;
|
||||
expect(getIpMatchListStatus('2001:db8:0:0:0:0:0:0', list))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.EXACT);
|
||||
});
|
||||
|
||||
test('should return CIDR on find the cidr match', () => {
|
||||
const list1 = `2001:0db8:11a3:09d7:0000:0000:0000:0000/64
|
||||
127.0.0.1
|
||||
127.0.0.2`;
|
||||
expect(getIpMatchListStatus('2001:db8:11a3:9d7:0:0:0:0', list1))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.CIDR);
|
||||
|
||||
const list2 = `2001:0db8::/16
|
||||
127.0.0.0
|
||||
2001:db8:11a3:9d7:0:0:0:0
|
||||
2001:db8::
|
||||
2001:db8:11a3:9d7:ffff:ffff:ffff:ffff
|
||||
127.0.0.1`;
|
||||
expect(getIpMatchListStatus('2001:db1::', list2))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.CIDR);
|
||||
});
|
||||
|
||||
test('should return NOT_FOUND if the ip is not in the list', () => {
|
||||
const list = `2001:db8:11a3:9d7:0:0:0:0
|
||||
2001:0db8:11a3:09d7:0000:0000:0000:0000/64
|
||||
127.0.0.1
|
||||
127.0.0.2`;
|
||||
expect(getIpMatchListStatus('::', list))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.NOT_FOUND);
|
||||
});
|
||||
|
||||
test('should return the first EXACT or CIDR match in the list', () => {
|
||||
const list1 = `2001:db8:11a3:9d7:0:0:0:0
|
||||
2001:0db8:11a3:09d7:0000:0000:0000:0000/64
|
||||
127.0.0.3`;
|
||||
expect(getIpMatchListStatus('2001:db8:11a3:9d7:0:0:0:0', list1))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.EXACT);
|
||||
|
||||
const list2 = `2001:0db8:11a3:09d7:0000:0000:0000:0000/64
|
||||
2001:db8:11a3:9d7:0:0:0:0
|
||||
127.0.0.3`;
|
||||
expect(getIpMatchListStatus('2001:db8:11a3:9d7:0:0:0:0', list2))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.CIDR);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Empty list or IP', () => {
|
||||
test('should return NOT_FOUND on empty ip', () => {
|
||||
const list = `127.0.0.0
|
||||
2001:db8:11a3:9d7:0:0:0:0
|
||||
2001:db8:11a3:9d7:ffff:ffff:ffff:ffff
|
||||
127.0.0.1`;
|
||||
expect(getIpMatchListStatus('', list))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.NOT_FOUND);
|
||||
});
|
||||
|
||||
test('should return NOT_FOUND on empty list', () => {
|
||||
const list = '';
|
||||
expect(getIpMatchListStatus('127.0.0.1', list))
|
||||
.toEqual(IP_MATCH_LIST_STATUS.NOT_FOUND);
|
||||
});
|
||||
});
|
||||
});
|
||||
import { sortIp, countClientsStatistics, findAddressType } from '../helpers/helpers';
|
||||
import { ADDRESS_TYPES } from '../helpers/constants';
|
||||
|
||||
describe('sortIp', () => {
|
||||
describe('ipv4', () => {
|
||||
|
||||
Reference in New Issue
Block a user