29 lines
971 B
Python
29 lines
971 B
Python
"""Test get secret."""
|
|
|
|
import pytest
|
|
|
|
from .types import ClientRegistry, CommandRunner
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_secret(ssh_command_runner: CommandRunner, client_registry: ClientRegistry) -> None:
|
|
"""Test that we can get a secret."""
|
|
|
|
await client_registry['add_client']("test-client", ["mysecret"])
|
|
|
|
result = await ssh_command_runner("test-client", "get_secret mysecret")
|
|
|
|
assert result.stdout is not None
|
|
assert isinstance(result.stdout, str)
|
|
assert result.stdout.rstrip() == "mocked-secret-mysecret"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_invalid_secret_name(ssh_command_runner: CommandRunner, client_registry: ClientRegistry) -> None:
|
|
"""Test getting an invalid secret name."""
|
|
|
|
await client_registry['add_client']("test-client")
|
|
|
|
result = await ssh_command_runner("test-client", "get_secret mysecret")
|
|
assert result.exit_status == 1
|
|
assert result.stderr == "Error: No secret available with the given name."
|