feat(sre): enforce typed host ansible handoffs
This commit is contained in:
@@ -94,6 +94,50 @@ async def test_ssh_execute_normalizes_host_before_allowed_check(monkeypatch):
|
||||
assert isinstance(captured["timeout"], int)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"tool_name,parameters",
|
||||
[
|
||||
(
|
||||
"ssh_systemctl_restart",
|
||||
{"service": "node_exporter"},
|
||||
),
|
||||
("ssh_reload_nginx", {}),
|
||||
],
|
||||
)
|
||||
async def test_systemd_tools_are_compatibility_only_no_ssh(
|
||||
monkeypatch,
|
||||
tool_name,
|
||||
parameters,
|
||||
):
|
||||
provider = SSHProvider()
|
||||
ssh_exec_called = False
|
||||
|
||||
async def fail_if_called(*_args, **_kwargs):
|
||||
nonlocal ssh_exec_called
|
||||
ssh_exec_called = True
|
||||
raise AssertionError("direct systemctl SSH must remain disabled")
|
||||
|
||||
monkeypatch.setattr(provider, "_ssh_exec", fail_if_called)
|
||||
|
||||
result = await provider.execute(
|
||||
tool_name,
|
||||
{
|
||||
"host": "192.168.0.110",
|
||||
"trust_score": 1.0,
|
||||
**parameters,
|
||||
},
|
||||
)
|
||||
|
||||
assert result.success is False
|
||||
assert result.error == (
|
||||
f"{tool_name}_disabled_use_host_ansible_controlled_executor"
|
||||
)
|
||||
assert ssh_exec_called is False
|
||||
with pytest.raises(ValueError, match="host_ansible_controlled_executor"):
|
||||
provider._build_command(tool_name, parameters)
|
||||
|
||||
|
||||
def test_ssh_container_status_accepts_legacy_container_name_alias():
|
||||
provider = SSHProvider()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user