AdGuardHome/internal/client/persistent_internal_test.go

194 lines
4.2 KiB
Go
Raw Normal View History

package client
Pull request 2122: AG-27492-client-persistent-ids Squashed commit of the following: commit a0527b86f10596a86357630117607a3c507e4ac2 Merge: 512edaf2d 9694f19ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 17 13:15:18 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-ids commit 512edaf2dc29f19c4fb7860b0c350a5e4180cda4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jan 15 15:50:28 2024 +0300 home: imp docs commit 4d4b3599918aab8ee6315c7f2f35f70db89e4d02 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 20:20:42 2024 +0300 home: imp code commit 8031347b8613cc49a80968e162dd198851eafe7c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 18:46:20 2024 +0300 home: fix typo commit 5932b181fe6a0c0bc605070fd9ddcc6617703ab7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 16:52:49 2024 +0300 home: imp code more commit 9412f5846795acfb68b009491b1045d1e27d8ddc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 15:41:23 2024 +0300 home: imp code commit 855d3201ab1b176ed5fdd32bce933a7795601a6d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 10 20:24:49 2024 +0300 home: add tests commit 112f1bd13acf992b0ba9562c29365b22d5374ec2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 18:29:11 2023 +0300 home: imp code commit 8b295bfa8968c3767bcfaf05c7f109d75af8c961 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 14:58:17 2023 +0300 home: persistent client ids
2024-01-17 10:24:21 +00:00
import (
Pull request 2221: AG-27492-client-persistent-runtime-storage Squashed commit of the following: commit a2b1e829f57fa7411354d882ec67d0c8736efbac Merge: 5fde76bb2 65b7d232a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 25 16:12:17 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 5fde76bb20f818f052fe89dc90c2b3ea790da4d2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Jun 21 16:58:17 2024 +0300 all: imp code commit eae49f91bc1b5eedae3d03b0b6c782afa11896d8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jun 19 20:10:55 2024 +0300 all: use storage commit 2c7efa46099d9b8ffe297ce247aff0aa8f45dff7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 20:14:34 2024 +0300 client: add tests commit d59bd7a24e273e58737c3efa832adabc57495bed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 18:31:23 2024 +0300 client: add tests commit 045b83882380a8e181f6892cc3245944e4c9fd52 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 15:18:08 2024 +0300 client: add tests commit 702467f7cadf3574c4a1b7b441ac02e26581bfcf Merge: 4abc23bf8 1c82be295 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jun 17 18:40:43 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 4abc23bf84dd8de02a1b805afba4d5a724b39d0c Merge: e268abf92 bed86d57f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:47 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit e268abf9268aef7a5386b5e126b01b249c590f49 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:36 2024 +0300 client: add tests commit 5601cfce39599337aaf04688ffe2b14b49f856e5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 27 14:27:53 2024 +0300 client: runtime index commit bde3baa5da85dd5404f78bd79a6a3e85c55cf7fc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 20 14:39:35 2024 +0300 all: persistent client storage
2024-06-26 12:30:02 +01:00
"net/netip"
Pull request 2122: AG-27492-client-persistent-ids Squashed commit of the following: commit a0527b86f10596a86357630117607a3c507e4ac2 Merge: 512edaf2d 9694f19ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 17 13:15:18 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-ids commit 512edaf2dc29f19c4fb7860b0c350a5e4180cda4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jan 15 15:50:28 2024 +0300 home: imp docs commit 4d4b3599918aab8ee6315c7f2f35f70db89e4d02 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 20:20:42 2024 +0300 home: imp code commit 8031347b8613cc49a80968e162dd198851eafe7c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 18:46:20 2024 +0300 home: fix typo commit 5932b181fe6a0c0bc605070fd9ddcc6617703ab7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 16:52:49 2024 +0300 home: imp code more commit 9412f5846795acfb68b009491b1045d1e27d8ddc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 15:41:23 2024 +0300 home: imp code commit 855d3201ab1b176ed5fdd32bce933a7795601a6d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 10 20:24:49 2024 +0300 home: add tests commit 112f1bd13acf992b0ba9562c29365b22d5374ec2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 18:29:11 2023 +0300 home: imp code commit 8b295bfa8968c3767bcfaf05c7f109d75af8c961 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 14:58:17 2023 +0300 home: persistent client ids
2024-01-17 10:24:21 +00:00
"testing"
"github.com/AdguardTeam/golibs/container"
Pull request 2221: AG-27492-client-persistent-runtime-storage Squashed commit of the following: commit a2b1e829f57fa7411354d882ec67d0c8736efbac Merge: 5fde76bb2 65b7d232a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 25 16:12:17 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 5fde76bb20f818f052fe89dc90c2b3ea790da4d2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Jun 21 16:58:17 2024 +0300 all: imp code commit eae49f91bc1b5eedae3d03b0b6c782afa11896d8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jun 19 20:10:55 2024 +0300 all: use storage commit 2c7efa46099d9b8ffe297ce247aff0aa8f45dff7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 20:14:34 2024 +0300 client: add tests commit d59bd7a24e273e58737c3efa832adabc57495bed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 18:31:23 2024 +0300 client: add tests commit 045b83882380a8e181f6892cc3245944e4c9fd52 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 15:18:08 2024 +0300 client: add tests commit 702467f7cadf3574c4a1b7b441ac02e26581bfcf Merge: 4abc23bf8 1c82be295 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jun 17 18:40:43 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 4abc23bf84dd8de02a1b805afba4d5a724b39d0c Merge: e268abf92 bed86d57f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:47 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit e268abf9268aef7a5386b5e126b01b249c590f49 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:36 2024 +0300 client: add tests commit 5601cfce39599337aaf04688ffe2b14b49f856e5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 27 14:27:53 2024 +0300 client: runtime index commit bde3baa5da85dd5404f78bd79a6a3e85c55cf7fc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 20 14:39:35 2024 +0300 all: persistent client storage
2024-06-26 12:30:02 +01:00
"github.com/AdguardTeam/golibs/testutil"
Pull request 2122: AG-27492-client-persistent-ids Squashed commit of the following: commit a0527b86f10596a86357630117607a3c507e4ac2 Merge: 512edaf2d 9694f19ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 17 13:15:18 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-ids commit 512edaf2dc29f19c4fb7860b0c350a5e4180cda4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jan 15 15:50:28 2024 +0300 home: imp docs commit 4d4b3599918aab8ee6315c7f2f35f70db89e4d02 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 20:20:42 2024 +0300 home: imp code commit 8031347b8613cc49a80968e162dd198851eafe7c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 18:46:20 2024 +0300 home: fix typo commit 5932b181fe6a0c0bc605070fd9ddcc6617703ab7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 16:52:49 2024 +0300 home: imp code more commit 9412f5846795acfb68b009491b1045d1e27d8ddc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 15:41:23 2024 +0300 home: imp code commit 855d3201ab1b176ed5fdd32bce933a7795601a6d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 10 20:24:49 2024 +0300 home: add tests commit 112f1bd13acf992b0ba9562c29365b22d5374ec2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 18:29:11 2023 +0300 home: imp code commit 8b295bfa8968c3767bcfaf05c7f109d75af8c961 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 14:58:17 2023 +0300 home: persistent client ids
2024-01-17 10:24:21 +00:00
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Pull request 2221: AG-27492-client-persistent-runtime-storage Squashed commit of the following: commit a2b1e829f57fa7411354d882ec67d0c8736efbac Merge: 5fde76bb2 65b7d232a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 25 16:12:17 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 5fde76bb20f818f052fe89dc90c2b3ea790da4d2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Jun 21 16:58:17 2024 +0300 all: imp code commit eae49f91bc1b5eedae3d03b0b6c782afa11896d8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jun 19 20:10:55 2024 +0300 all: use storage commit 2c7efa46099d9b8ffe297ce247aff0aa8f45dff7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 20:14:34 2024 +0300 client: add tests commit d59bd7a24e273e58737c3efa832adabc57495bed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 18:31:23 2024 +0300 client: add tests commit 045b83882380a8e181f6892cc3245944e4c9fd52 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 15:18:08 2024 +0300 client: add tests commit 702467f7cadf3574c4a1b7b441ac02e26581bfcf Merge: 4abc23bf8 1c82be295 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jun 17 18:40:43 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 4abc23bf84dd8de02a1b805afba4d5a724b39d0c Merge: e268abf92 bed86d57f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:47 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit e268abf9268aef7a5386b5e126b01b249c590f49 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:36 2024 +0300 client: add tests commit 5601cfce39599337aaf04688ffe2b14b49f856e5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 27 14:27:53 2024 +0300 client: runtime index commit bde3baa5da85dd5404f78bd79a6a3e85c55cf7fc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 20 14:39:35 2024 +0300 all: persistent client storage
2024-06-26 12:30:02 +01:00
func TestPersistent_EqualIDs(t *testing.T) {
Pull request 2122: AG-27492-client-persistent-ids Squashed commit of the following: commit a0527b86f10596a86357630117607a3c507e4ac2 Merge: 512edaf2d 9694f19ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 17 13:15:18 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-ids commit 512edaf2dc29f19c4fb7860b0c350a5e4180cda4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jan 15 15:50:28 2024 +0300 home: imp docs commit 4d4b3599918aab8ee6315c7f2f35f70db89e4d02 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 20:20:42 2024 +0300 home: imp code commit 8031347b8613cc49a80968e162dd198851eafe7c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 18:46:20 2024 +0300 home: fix typo commit 5932b181fe6a0c0bc605070fd9ddcc6617703ab7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 16:52:49 2024 +0300 home: imp code more commit 9412f5846795acfb68b009491b1045d1e27d8ddc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 15:41:23 2024 +0300 home: imp code commit 855d3201ab1b176ed5fdd32bce933a7795601a6d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 10 20:24:49 2024 +0300 home: add tests commit 112f1bd13acf992b0ba9562c29365b22d5374ec2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 18:29:11 2023 +0300 home: imp code commit 8b295bfa8968c3767bcfaf05c7f109d75af8c961 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 14:58:17 2023 +0300 home: persistent client ids
2024-01-17 10:24:21 +00:00
const (
ip = "0.0.0.0"
ip1 = "1.1.1.1"
ip2 = "2.2.2.2"
cidr = "0.0.0.0/0"
cidr1 = "1.1.1.1/11"
cidr2 = "2.2.2.2/22"
mac = "00-00-00-00-00-00"
mac1 = "11-11-11-11-11-11"
mac2 = "22-22-22-22-22-22"
cli = "client0"
cli1 = "client1"
cli2 = "client2"
)
testCases := []struct {
want assert.BoolAssertionFunc
Pull request 2122: AG-27492-client-persistent-ids Squashed commit of the following: commit a0527b86f10596a86357630117607a3c507e4ac2 Merge: 512edaf2d 9694f19ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 17 13:15:18 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-ids commit 512edaf2dc29f19c4fb7860b0c350a5e4180cda4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jan 15 15:50:28 2024 +0300 home: imp docs commit 4d4b3599918aab8ee6315c7f2f35f70db89e4d02 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 20:20:42 2024 +0300 home: imp code commit 8031347b8613cc49a80968e162dd198851eafe7c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 18:46:20 2024 +0300 home: fix typo commit 5932b181fe6a0c0bc605070fd9ddcc6617703ab7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 16:52:49 2024 +0300 home: imp code more commit 9412f5846795acfb68b009491b1045d1e27d8ddc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 15:41:23 2024 +0300 home: imp code commit 855d3201ab1b176ed5fdd32bce933a7795601a6d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 10 20:24:49 2024 +0300 home: add tests commit 112f1bd13acf992b0ba9562c29365b22d5374ec2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 18:29:11 2023 +0300 home: imp code commit 8b295bfa8968c3767bcfaf05c7f109d75af8c961 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 14:58:17 2023 +0300 home: persistent client ids
2024-01-17 10:24:21 +00:00
name string
ids []string
prevIDs []string
}{{
name: "single_ip",
ids: []string{ip1},
prevIDs: []string{ip1},
want: assert.True,
}, {
name: "single_ip_not_equal",
ids: []string{ip1},
prevIDs: []string{ip2},
want: assert.False,
}, {
name: "ips_not_equal",
ids: []string{ip1, ip2},
prevIDs: []string{ip1, ip},
want: assert.False,
}, {
name: "ips_mixed_equal",
ids: []string{ip1, ip2},
prevIDs: []string{ip2, ip1},
want: assert.True,
}, {
name: "single_subnet",
ids: []string{cidr1},
prevIDs: []string{cidr1},
want: assert.True,
}, {
name: "subnets_not_equal",
ids: []string{ip1, ip2, cidr1, cidr2},
prevIDs: []string{ip1, ip2, cidr1, cidr},
want: assert.False,
}, {
name: "subnets_mixed_equal",
ids: []string{ip1, ip2, cidr1, cidr2},
prevIDs: []string{cidr2, cidr1, ip2, ip1},
want: assert.True,
}, {
name: "single_mac",
ids: []string{mac1},
prevIDs: []string{mac1},
want: assert.True,
}, {
name: "single_mac_not_equal",
ids: []string{mac1},
prevIDs: []string{mac2},
want: assert.False,
}, {
name: "macs_not_equal",
ids: []string{ip1, ip2, cidr1, cidr2, mac1, mac2},
prevIDs: []string{ip1, ip2, cidr1, cidr2, mac1, mac},
want: assert.False,
}, {
name: "macs_mixed_equal",
ids: []string{ip1, ip2, cidr1, cidr2, mac1, mac2},
prevIDs: []string{mac2, mac1, cidr2, cidr1, ip2, ip1},
want: assert.True,
}, {
name: "single_client_id",
ids: []string{cli1},
prevIDs: []string{cli1},
want: assert.True,
}, {
name: "single_client_id_not_equal",
ids: []string{cli1},
prevIDs: []string{cli2},
want: assert.False,
}, {
name: "client_ids_not_equal",
ids: []string{ip1, ip2, cidr1, cidr2, mac1, mac2, cli1, cli2},
prevIDs: []string{ip1, ip2, cidr1, cidr2, mac1, mac2, cli1, cli},
want: assert.False,
}, {
name: "client_ids_mixed_equal",
ids: []string{ip1, ip2, cidr1, cidr2, mac1, mac2, cli1, cli2},
prevIDs: []string{cli2, cli1, mac2, mac1, cidr2, cidr1, ip2, ip1},
want: assert.True,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
c := &Persistent{}
err := c.SetIDs(tc.ids)
Pull request 2122: AG-27492-client-persistent-ids Squashed commit of the following: commit a0527b86f10596a86357630117607a3c507e4ac2 Merge: 512edaf2d 9694f19ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 17 13:15:18 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-ids commit 512edaf2dc29f19c4fb7860b0c350a5e4180cda4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jan 15 15:50:28 2024 +0300 home: imp docs commit 4d4b3599918aab8ee6315c7f2f35f70db89e4d02 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 20:20:42 2024 +0300 home: imp code commit 8031347b8613cc49a80968e162dd198851eafe7c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 18:46:20 2024 +0300 home: fix typo commit 5932b181fe6a0c0bc605070fd9ddcc6617703ab7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 16:52:49 2024 +0300 home: imp code more commit 9412f5846795acfb68b009491b1045d1e27d8ddc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 15:41:23 2024 +0300 home: imp code commit 855d3201ab1b176ed5fdd32bce933a7795601a6d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 10 20:24:49 2024 +0300 home: add tests commit 112f1bd13acf992b0ba9562c29365b22d5374ec2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 18:29:11 2023 +0300 home: imp code commit 8b295bfa8968c3767bcfaf05c7f109d75af8c961 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 14:58:17 2023 +0300 home: persistent client ids
2024-01-17 10:24:21 +00:00
require.NoError(t, err)
prev := &Persistent{}
err = prev.SetIDs(tc.prevIDs)
Pull request 2122: AG-27492-client-persistent-ids Squashed commit of the following: commit a0527b86f10596a86357630117607a3c507e4ac2 Merge: 512edaf2d 9694f19ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 17 13:15:18 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-ids commit 512edaf2dc29f19c4fb7860b0c350a5e4180cda4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jan 15 15:50:28 2024 +0300 home: imp docs commit 4d4b3599918aab8ee6315c7f2f35f70db89e4d02 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 20:20:42 2024 +0300 home: imp code commit 8031347b8613cc49a80968e162dd198851eafe7c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 18:46:20 2024 +0300 home: fix typo commit 5932b181fe6a0c0bc605070fd9ddcc6617703ab7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 16:52:49 2024 +0300 home: imp code more commit 9412f5846795acfb68b009491b1045d1e27d8ddc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 15:41:23 2024 +0300 home: imp code commit 855d3201ab1b176ed5fdd32bce933a7795601a6d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 10 20:24:49 2024 +0300 home: add tests commit 112f1bd13acf992b0ba9562c29365b22d5374ec2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 18:29:11 2023 +0300 home: imp code commit 8b295bfa8968c3767bcfaf05c7f109d75af8c961 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 14:58:17 2023 +0300 home: persistent client ids
2024-01-17 10:24:21 +00:00
require.NoError(t, err)
tc.want(t, c.EqualIDs(prev))
Pull request 2122: AG-27492-client-persistent-ids Squashed commit of the following: commit a0527b86f10596a86357630117607a3c507e4ac2 Merge: 512edaf2d 9694f19ef Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 17 13:15:18 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-ids commit 512edaf2dc29f19c4fb7860b0c350a5e4180cda4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jan 15 15:50:28 2024 +0300 home: imp docs commit 4d4b3599918aab8ee6315c7f2f35f70db89e4d02 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 20:20:42 2024 +0300 home: imp code commit 8031347b8613cc49a80968e162dd198851eafe7c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 18:46:20 2024 +0300 home: fix typo commit 5932b181fe6a0c0bc605070fd9ddcc6617703ab7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 16:52:49 2024 +0300 home: imp code more commit 9412f5846795acfb68b009491b1045d1e27d8ddc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jan 11 15:41:23 2024 +0300 home: imp code commit 855d3201ab1b176ed5fdd32bce933a7795601a6d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 10 20:24:49 2024 +0300 home: add tests commit 112f1bd13acf992b0ba9562c29365b22d5374ec2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 18:29:11 2023 +0300 home: imp code commit 8b295bfa8968c3767bcfaf05c7f109d75af8c961 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Dec 29 14:58:17 2023 +0300 home: persistent client ids
2024-01-17 10:24:21 +00:00
})
}
}
Pull request 2221: AG-27492-client-persistent-runtime-storage Squashed commit of the following: commit a2b1e829f57fa7411354d882ec67d0c8736efbac Merge: 5fde76bb2 65b7d232a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 25 16:12:17 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 5fde76bb20f818f052fe89dc90c2b3ea790da4d2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Jun 21 16:58:17 2024 +0300 all: imp code commit eae49f91bc1b5eedae3d03b0b6c782afa11896d8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jun 19 20:10:55 2024 +0300 all: use storage commit 2c7efa46099d9b8ffe297ce247aff0aa8f45dff7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 20:14:34 2024 +0300 client: add tests commit d59bd7a24e273e58737c3efa832adabc57495bed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 18:31:23 2024 +0300 client: add tests commit 045b83882380a8e181f6892cc3245944e4c9fd52 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 15:18:08 2024 +0300 client: add tests commit 702467f7cadf3574c4a1b7b441ac02e26581bfcf Merge: 4abc23bf8 1c82be295 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jun 17 18:40:43 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 4abc23bf84dd8de02a1b805afba4d5a724b39d0c Merge: e268abf92 bed86d57f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:47 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit e268abf9268aef7a5386b5e126b01b249c590f49 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:36 2024 +0300 client: add tests commit 5601cfce39599337aaf04688ffe2b14b49f856e5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 27 14:27:53 2024 +0300 client: runtime index commit bde3baa5da85dd5404f78bd79a6a3e85c55cf7fc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 20 14:39:35 2024 +0300 all: persistent client storage
2024-06-26 12:30:02 +01:00
func TestPersistent_Validate(t *testing.T) {
const (
allowedTag = "allowed_tag"
notAllowedTag = "not_allowed_tag"
)
allowedTags := container.NewMapSet(allowedTag)
Pull request 2221: AG-27492-client-persistent-runtime-storage Squashed commit of the following: commit a2b1e829f57fa7411354d882ec67d0c8736efbac Merge: 5fde76bb2 65b7d232a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 25 16:12:17 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 5fde76bb20f818f052fe89dc90c2b3ea790da4d2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Jun 21 16:58:17 2024 +0300 all: imp code commit eae49f91bc1b5eedae3d03b0b6c782afa11896d8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jun 19 20:10:55 2024 +0300 all: use storage commit 2c7efa46099d9b8ffe297ce247aff0aa8f45dff7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 20:14:34 2024 +0300 client: add tests commit d59bd7a24e273e58737c3efa832adabc57495bed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 18:31:23 2024 +0300 client: add tests commit 045b83882380a8e181f6892cc3245944e4c9fd52 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 15:18:08 2024 +0300 client: add tests commit 702467f7cadf3574c4a1b7b441ac02e26581bfcf Merge: 4abc23bf8 1c82be295 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jun 17 18:40:43 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 4abc23bf84dd8de02a1b805afba4d5a724b39d0c Merge: e268abf92 bed86d57f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:47 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit e268abf9268aef7a5386b5e126b01b249c590f49 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:36 2024 +0300 client: add tests commit 5601cfce39599337aaf04688ffe2b14b49f856e5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 27 14:27:53 2024 +0300 client: runtime index commit bde3baa5da85dd5404f78bd79a6a3e85c55cf7fc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 20 14:39:35 2024 +0300 all: persistent client storage
2024-06-26 12:30:02 +01:00
testCases := []struct {
name string
cli *Persistent
wantErrMsg string
}{{
name: "success",
Pull request 2221: AG-27492-client-persistent-runtime-storage Squashed commit of the following: commit a2b1e829f57fa7411354d882ec67d0c8736efbac Merge: 5fde76bb2 65b7d232a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 25 16:12:17 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 5fde76bb20f818f052fe89dc90c2b3ea790da4d2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Jun 21 16:58:17 2024 +0300 all: imp code commit eae49f91bc1b5eedae3d03b0b6c782afa11896d8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jun 19 20:10:55 2024 +0300 all: use storage commit 2c7efa46099d9b8ffe297ce247aff0aa8f45dff7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 20:14:34 2024 +0300 client: add tests commit d59bd7a24e273e58737c3efa832adabc57495bed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 18:31:23 2024 +0300 client: add tests commit 045b83882380a8e181f6892cc3245944e4c9fd52 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 15:18:08 2024 +0300 client: add tests commit 702467f7cadf3574c4a1b7b441ac02e26581bfcf Merge: 4abc23bf8 1c82be295 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jun 17 18:40:43 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 4abc23bf84dd8de02a1b805afba4d5a724b39d0c Merge: e268abf92 bed86d57f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:47 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit e268abf9268aef7a5386b5e126b01b249c590f49 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:36 2024 +0300 client: add tests commit 5601cfce39599337aaf04688ffe2b14b49f856e5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 27 14:27:53 2024 +0300 client: runtime index commit bde3baa5da85dd5404f78bd79a6a3e85c55cf7fc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 20 14:39:35 2024 +0300 all: persistent client storage
2024-06-26 12:30:02 +01:00
cli: &Persistent{
Name: "basic",
IPs: []netip.Addr{
netip.MustParseAddr("1.2.3.4"),
},
UID: MustNewUID(),
},
wantErrMsg: "",
}, {
name: "empty_name",
cli: &Persistent{
Name: "",
},
wantErrMsg: "empty name",
}, {
name: "no_id",
cli: &Persistent{
Name: "no_id",
},
wantErrMsg: "id required",
}, {
name: "no_uid",
cli: &Persistent{
Name: "no_uid",
IPs: []netip.Addr{
netip.MustParseAddr("1.2.3.4"),
},
},
wantErrMsg: "uid required",
}, {
name: "not_allowed_tag",
cli: &Persistent{
Name: "basic",
IPs: []netip.Addr{
netip.MustParseAddr("1.2.3.4"),
},
UID: MustNewUID(),
Tags: []string{
notAllowedTag,
},
},
wantErrMsg: `invalid tag: "` + notAllowedTag + `"`,
Pull request 2221: AG-27492-client-persistent-runtime-storage Squashed commit of the following: commit a2b1e829f57fa7411354d882ec67d0c8736efbac Merge: 5fde76bb2 65b7d232a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 25 16:12:17 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 5fde76bb20f818f052fe89dc90c2b3ea790da4d2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Jun 21 16:58:17 2024 +0300 all: imp code commit eae49f91bc1b5eedae3d03b0b6c782afa11896d8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jun 19 20:10:55 2024 +0300 all: use storage commit 2c7efa46099d9b8ffe297ce247aff0aa8f45dff7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 20:14:34 2024 +0300 client: add tests commit d59bd7a24e273e58737c3efa832adabc57495bed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 18:31:23 2024 +0300 client: add tests commit 045b83882380a8e181f6892cc3245944e4c9fd52 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 15:18:08 2024 +0300 client: add tests commit 702467f7cadf3574c4a1b7b441ac02e26581bfcf Merge: 4abc23bf8 1c82be295 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jun 17 18:40:43 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 4abc23bf84dd8de02a1b805afba4d5a724b39d0c Merge: e268abf92 bed86d57f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:47 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit e268abf9268aef7a5386b5e126b01b249c590f49 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:36 2024 +0300 client: add tests commit 5601cfce39599337aaf04688ffe2b14b49f856e5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 27 14:27:53 2024 +0300 client: runtime index commit bde3baa5da85dd5404f78bd79a6a3e85c55cf7fc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 20 14:39:35 2024 +0300 all: persistent client storage
2024-06-26 12:30:02 +01:00
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := tc.cli.validate(allowedTags)
Pull request 2221: AG-27492-client-persistent-runtime-storage Squashed commit of the following: commit a2b1e829f57fa7411354d882ec67d0c8736efbac Merge: 5fde76bb2 65b7d232a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 25 16:12:17 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 5fde76bb20f818f052fe89dc90c2b3ea790da4d2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Jun 21 16:58:17 2024 +0300 all: imp code commit eae49f91bc1b5eedae3d03b0b6c782afa11896d8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jun 19 20:10:55 2024 +0300 all: use storage commit 2c7efa46099d9b8ffe297ce247aff0aa8f45dff7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 20:14:34 2024 +0300 client: add tests commit d59bd7a24e273e58737c3efa832adabc57495bed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 18:31:23 2024 +0300 client: add tests commit 045b83882380a8e181f6892cc3245944e4c9fd52 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jun 18 15:18:08 2024 +0300 client: add tests commit 702467f7cadf3574c4a1b7b441ac02e26581bfcf Merge: 4abc23bf8 1c82be295 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jun 17 18:40:43 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit 4abc23bf84dd8de02a1b805afba4d5a724b39d0c Merge: e268abf92 bed86d57f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:47 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-runtime-storage commit e268abf9268aef7a5386b5e126b01b249c590f49 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jun 13 15:19:36 2024 +0300 client: add tests commit 5601cfce39599337aaf04688ffe2b14b49f856e5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 27 14:27:53 2024 +0300 client: runtime index commit bde3baa5da85dd5404f78bd79a6a3e85c55cf7fc Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 20 14:39:35 2024 +0300 all: persistent client storage
2024-06-26 12:30:02 +01:00
testutil.AssertErrorMsg(t, tc.wantErrMsg, err)
})
}
}