Остання активність 1 month ago

nuno ревизій цього gist 1 month ago. До ревизії

1 file changed, 65 insertions

gistfile1.txt(файл створено)

@@ -0,0 +1,65 @@
1 + function cmd::test::section_destructive() {
2 + test::section "Destructive (modifying state)"
3 +
4 + # Cleanup from any previous failed run
5 + "$WGCTL_BINARY" remove --name phone-testunit --force > /dev/null 2>&1 || true
6 + "$WGCTL_BINARY" group remove --name testgroup --force > /dev/null 2>&1 || true
7 +
8 + # Add test peer
9 + cmd::test::run_cmd "add phone peer" "added successfully" \
10 + add --name testunit --type phone
11 + # Block/unblock
12 + cmd::test::run_cmd "block peer" "blocked" \
13 + block --name phone-testunit
14 + cmd::test::run_cmd "list shows blocked" "blocked" \
15 + list --blocked
16 + cmd::test::run_cmd "unblock peer" "unblocked" \
17 + unblock --name phone-testunit
18 +
19 + # Rule assign/unassign
20 + cmd::test::run_cmd "rule assign" "Assigned" \
21 + rule assign --name user --peer phone-testunit
22 + cmd::test::run_cmd "rule unassign" "Unassigned" \
23 + rule unassign --peer phone-testunit
24 + # Re-assign user rule (default) for cleanup
25 + /usr/local/bin/wgctl rule assign --name user --peer phone-testunit \
26 + > /dev/null 2>&1 || true
27 +
28 + # Group operations
29 + cmd::test::run_cmd "group add" "created" \
30 + group add --name testgroup --desc "Test group"
31 + cmd::test::run_cmd "group peer add" "Added" \
32 + group peer add --name testgroup --peer phone-testunit
33 + cmd::test::run_cmd "group block" "have been blocked" \
34 + group block --name testgroup
35 + cmd::test::run_cmd "group unblock" "have been unblocked" \
36 + group unblock --name testgroup
37 + cmd::test::run_cmd "group remove" "removed" \
38 + group remove --name testgroup --force
39 +
40 + # Block/unblock with group tracking
41 + cmd::test::run_cmd "group block tracks groups" "" \
42 + group block --name testgroup
43 +
44 + # Verify peer stays blocked after partial unblock
45 + "$WGCTL_BINARY" group add --name testgroup2 > /dev/null 2>&1
46 + "$WGCTL_BINARY" group peer add --name testgroup2 \
47 + --peer phone-testunit > /dev/null 2>&1
48 + "$WGCTL_BINARY" group block --name testgroup2 > /dev/null 2>&1
49 + "$WGCTL_BINARY" group unblock --name testgroup > /dev/null 2>&1
50 +
51 + # Peer should STILL be blocked (testgroup2 is still blocking)
52 + cmd::test::run_cmd "peer stays blocked after partial unblock" \
53 + "blocked" list --blocked
54 +
55 + # Full unblock
56 + cmd::test::run_cmd "group unblock removes all" "" \
57 + group unblock --name testgroup2
58 +
59 + "$WGCTL_BINARY" group remove --name testgroup --force > /dev/null 2>&1 || true
60 + "$WGCTL_BINARY" group remove --name testgroup2 --force > /dev/null 2>&1
61 +
62 + # Remove test peer
63 + cmd::test::run_cmd "remove phone peer" "removed" \
64 + remove --name phone-testunit --force
65 + }
Новіше Пізніше