46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
"""Test the help command."""
|
|
|
|
import re
|
|
import allure
|
|
import pytest
|
|
|
|
from .types import ClientRegistry, CommandRunner
|
|
|
|
@allure.title("Test the help command.")
|
|
@pytest.mark.asyncio
|
|
async def test_help_command(ssh_command_runner: CommandRunner, client_registry: ClientRegistry) -> None:
|
|
"""Run the help command and verify the output."""
|
|
await client_registry["add_client"]("test-client", ["mysecret"])
|
|
|
|
result = await ssh_command_runner("test-client", "help")
|
|
|
|
assert result.exit_status == 0
|
|
assert isinstance(result.stdout, str)
|
|
|
|
re_cmd = re.compile(r"^\s{2}([^\s]+)\s.*", re.MULTILINE)
|
|
commands = re_cmd.findall(result.stdout)
|
|
expected = ["get_secret", "ls", "ping", "list", "store", "lookup", "delete"]
|
|
assert sorted(commands) == sorted(expected)
|
|
|
|
print(result.stdout)
|
|
|
|
|
|
@allure.title("Test the help command with registration enabled.")
|
|
@pytest.mark.enable_registration(True)
|
|
@pytest.mark.asyncio
|
|
async def test_help_registration_command(ssh_command_runner: CommandRunner, client_registry: ClientRegistry) -> None:
|
|
"""Run the help command and verify the output."""
|
|
await client_registry["add_client"]("test-client", ["mysecret"])
|
|
|
|
result = await ssh_command_runner("test-client", "help")
|
|
|
|
assert result.exit_status == 0
|
|
assert isinstance(result.stdout, str)
|
|
|
|
re_cmd = re.compile(r"^\s{2}([^\s]+)\s.*", re.MULTILINE)
|
|
commands = re_cmd.findall(result.stdout)
|
|
expected = ["get_secret", "ls", "register", "ping", "list", "store", "lookup", "delete"]
|
|
assert sorted(commands) == sorted(expected)
|
|
|
|
print(result.stdout)
|