Add more tests
This commit is contained in:
45
tests/packages/sshd/test_help.py
Normal file
45
tests/packages/sshd/test_help.py
Normal file
@ -0,0 +1,45 @@
|
||||
"""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']
|
||||
assert commands == 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"]
|
||||
assert sorted(commands) == sorted(expected)
|
||||
|
||||
print(result.stdout)
|
||||
Reference in New Issue
Block a user