Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions tests/test_ssh_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,17 +792,17 @@ def test_remove_ip_address(self, temp_known_hosts):

def test_remove_multiple_entries(self, temp_known_hosts):
"""Test removing hostname and IP address together."""
existing = """tobcloud.myhost ssh-ed25519 AAAA...
existing = """dropkit.myhost ssh-ed25519 AAAA...
100.80.123.45 ssh-ed25519 AAAA...
otherhost ssh-rsa AAAA...
"""
Path(temp_known_hosts).write_text(existing)

result = remove_known_hosts_entry(temp_known_hosts, ["tobcloud.myhost", "100.80.123.45"])
result = remove_known_hosts_entry(temp_known_hosts, ["dropkit.myhost", "100.80.123.45"])

assert result == 2
content = Path(temp_known_hosts).read_text()
assert "tobcloud.myhost" not in content
assert "dropkit.myhost" not in content
assert "100.80.123.45" not in content
assert "otherhost" in content

Expand Down Expand Up @@ -966,20 +966,18 @@ def test_remove_all_entries(self, temp_known_hosts):
content = Path(temp_known_hosts).read_text()
assert content.strip() == ""

def test_tobcloud_hostname_format(self, temp_known_hosts):
"""Test removing tobcloud-style hostname."""
existing = """tobcloud.my-droplet ssh-ed25519 AAAA...
def test_dropkit_hostname_format(self, temp_known_hosts):
"""Test removing dropkit-style hostname."""
existing = """dropkit.my-droplet ssh-ed25519 AAAA...
100.80.123.45 ssh-ed25519 AAAA...
otherhost ssh-rsa AAAA...
"""
Path(temp_known_hosts).write_text(existing)

result = remove_known_hosts_entry(
temp_known_hosts, ["tobcloud.my-droplet", "100.80.123.45"]
)
result = remove_known_hosts_entry(temp_known_hosts, ["dropkit.my-droplet", "100.80.123.45"])

assert result == 2
content = Path(temp_known_hosts).read_text()
assert "tobcloud.my-droplet" not in content
assert "dropkit.my-droplet" not in content
assert "100.80.123.45" not in content
assert "otherhost" in content