Files
OBLITERATUS/tests/test_remote_boundaries.py
T

37 lines
1.2 KiB
Python

"""Offline contracts for strict SSH command construction."""
from __future__ import annotations
from obliteratus.remote import RemoteConfig, RemoteRunner
def test_remote_commands_require_strict_host_key_verification(tmp_path):
key = tmp_path / "key"
known_hosts = tmp_path / "known_hosts"
config = RemoteConfig(
host="compute.example",
user="runner",
port=2222,
ssh_key=str(key),
known_hosts_file=str(known_hosts),
)
runner = RemoteRunner(config)
for command in (runner._ssh_base_cmd(), runner._scp_base_cmd()):
assert "StrictHostKeyChecking=yes" in command
assert f"UserKnownHostsFile={known_hosts}" in command
assert "StrictHostKeyChecking=no" not in command
assert str(key) in command
def test_remote_config_accepts_versioned_known_hosts_setting():
config = RemoteConfig.from_dict(
{
"host": "compute.example",
"user": "runner",
"known_hosts_file": "/secure/known_hosts",
"unknown": "ignored",
}
)
assert config.known_hosts_file == "/secure/known_hosts"
assert config.ssh_target == "runner@compute.example"