Files
cleveragents-core/features/tui_shell_exec_coverage.feature
T
CleverAgents Bot 29c5a2edfa
CI / push-validation (pull_request) Successful in 30s
CI / load-versions (pull_request) Failing after 13m31s
CI / lint (pull_request) Has been cancelled
CI / typecheck (pull_request) Has been cancelled
CI / security (pull_request) Has been cancelled
CI / quality (pull_request) Has been cancelled
CI / unit_tests (pull_request) Has been cancelled
CI / integration_tests (pull_request) Has been cancelled
CI / coverage (pull_request) Has been cancelled
CI / build (pull_request) Has been cancelled
CI / docker (pull_request) Has been cancelled
CI / helm (pull_request) Has been cancelled
CI / status-check (pull_request) Has been cancelled
fix(tui): align shell safety regex execution
2026-06-18 06:49:56 -04:00

83 lines
3.8 KiB
Gherkin

Feature: TUI Shell Exec Coverage
Scenarios that exercise previously uncovered code paths
in the tui/input/shell_exec module (lines 48-49, 52-56, 61, 77-82).
Background:
Given the shell_exec module is imported
Scenario: Empty command returns error result
When I run a shell command with an empty string
Then the shell result exit code should be 2
And the shell result stderr should be "empty command"
And the shell result stdout should be empty
Scenario: Whitespace-only command returns error result
When I run a shell command with only whitespace " "
Then the shell result exit code should be 2
And the shell result stderr should be "empty command"
Scenario: Shell mode disabled via env var set to 1
Given the environment variable CLEVERAGENTS_DISABLE_SHELL_MODE is set to "1"
When I run a shell command "echo hello"
Then the shell result exit code should be 2
And the shell result stderr should be "shell mode is disabled"
Scenario: Shell mode disabled via env var set to true
Given the environment variable CLEVERAGENTS_DISABLE_SHELL_MODE is set to "true"
When I run a shell command "echo hello"
Then the shell result exit code should be 2
And the shell result stderr should be "shell mode is disabled"
Scenario: Dangerous command confirmed via callback proceeds to execution
Given a confirm_dangerous callback that returns True
When I run a dangerous command "rm -rf /" with the callback
Then the dangerous command should have been confirmed
And the shell result should reflect the executed command
Scenario: Dangerous command confirmed but callback returns False is still blocked
Given a confirm_dangerous callback that returns False
When I run a dangerous command "rm -rf /" with the callback
Then the shell result exit code should be 1
And the shell result stderr should be "blocked dangerous shell command"
Scenario: Command that exceeds timeout returns timeout result
Given subprocess run is mocked to raise TimeoutExpired
When I run a shell command "sleep 999" with a 1 second timeout
Then the shell result exit code should be 124
And the shell result stderr should contain "command timed out after"
Scenario: Dangerous command with double space is blocked
When I run a shell command "rm -rf /"
Then the shell result exit code should be 1
And the shell result stderr should be "blocked dangerous shell command"
Scenario: Dangerous command with tab character is blocked
When I run a shell command "rm -rf /"
Then the shell result exit code should be 1
And the shell result stderr should be "blocked dangerous shell command"
Scenario: Dangerous command with sudo prefix is blocked
When I run a shell command "sudo rm -rf /"
Then the shell result exit code should be 1
And the shell result stderr should be "blocked dangerous shell command"
Scenario: Dangerous command with mixed spacing is blocked
When I run a shell command "rm -rf /"
Then the shell result exit code should be 1
And the shell result stderr should be "blocked dangerous shell command"
Scenario: Git push force with spacing variations is blocked
When I run a shell command "git push --force"
Then the shell result exit code should be 1
And the shell result stderr should be "blocked dangerous shell command"
Scenario: mkfs with spacing variations is blocked
When I run a shell command "mkfs.ext4 /dev/sdb1"
Then the shell result exit code should be 1
And the shell result stderr should be "blocked dangerous shell command"
Scenario: dd if= with spacing variations is blocked
When I run a shell command "dd if=/dev/zero"
Then the shell result exit code should be 1
And the shell result stderr should be "blocked dangerous shell command"