Skip to content

Commit 9e27ab6

Browse files
committed
test(firewall): add test for skip-confirmation=0 behavior
Verifies that --skip-confirmation 0 correctly requires confirmation even for a single rule modification, ensuring users can always opt into manual confirmation for safety.
1 parent 022453c commit 9e27ab6

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

internal/commands/server/firewall/rule_disable_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func TestRuleDisableCommand(t *testing.T) {
2424
Direction: "in",
2525
Action: "accept",
2626
Protocol: "tcp",
27+
Comment: "Test rule",
2728
},
2829
{
2930
Position: 2,
@@ -119,6 +120,12 @@ func TestRuleDisableCommand(t *testing.T) {
119120
arg: serverUUID,
120121
expectedErr: "firewall rule at position 99 not found on server",
121122
},
123+
{
124+
name: "Skip confirmation set to 0 requires confirmation for single rule",
125+
flags: []string{"--comment", "Test", "--skip-confirmation", "0"},
126+
arg: serverUUID,
127+
expectedErr: "would disable 1 rules (exceeds skip-confirmation=0)",
128+
},
122129
} {
123130
t.Run(test.name, func(t *testing.T) {
124131
mService := smock.Service{}

internal/commands/server/firewall/rule_enable_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func TestRuleEnableCommand(t *testing.T) {
2424
Direction: "in",
2525
Action: "drop",
2626
Protocol: "tcp",
27+
Comment: "Test rule",
2728
},
2829
{
2930
Position: 2,
@@ -97,6 +98,12 @@ func TestRuleEnableCommand(t *testing.T) {
9798
arg: serverUUID,
9899
expectedErr: "firewall rule at position 99 not found on server",
99100
},
101+
{
102+
name: "Skip confirmation set to 0 requires confirmation for single rule",
103+
flags: []string{"--comment", "Test", "--skip-confirmation", "0"},
104+
arg: serverUUID,
105+
expectedErr: "would enable 1 rules (exceeds skip-confirmation=0)",
106+
},
100107
} {
101108
t.Run(test.name, func(t *testing.T) {
102109
mService := smock.Service{}

0 commit comments

Comments
 (0)