feat(git-gate): remove git remote host override plumbing
This commit is contained in:
@@ -9,14 +9,12 @@ from bot_bottle.git_gate import (
|
||||
GitGate,
|
||||
GitGatePlan,
|
||||
GitGateUpstream,
|
||||
git_gate_aggregate_extra_hosts,
|
||||
git_gate_known_hosts_line,
|
||||
git_gate_render_access_hook,
|
||||
git_gate_render_entrypoint,
|
||||
git_gate_render_hook,
|
||||
git_gate_upstreams_for_bottle,
|
||||
)
|
||||
from bot_bottle.log import Die
|
||||
from bot_bottle.manifest import Manifest
|
||||
from tests.fixtures import fixture_minimal, fixture_with_git
|
||||
|
||||
@@ -46,86 +44,6 @@ class TestUpstreamsForBottle(unittest.TestCase):
|
||||
self.assertEqual((), git_gate_upstreams_for_bottle(bottle))
|
||||
|
||||
|
||||
class TestExtraHostsPlumbing(unittest.TestCase):
|
||||
def test_upstream_carries_extra_hosts_from_manifest(self):
|
||||
m = Manifest.from_json_obj({
|
||||
"bottles": {
|
||||
"dev": {
|
||||
"git": {"remotes": {
|
||||
"gitea.dideric.is": {
|
||||
"Name": "bot-bottle",
|
||||
"Upstream": "ssh://git@gitea.dideric.is:30009/didericis/bot-bottle.git",
|
||||
"IdentityFile": "/dev/null",
|
||||
"ExtraHosts": {"gitea.dideric.is": "100.78.141.42"},
|
||||
},
|
||||
}},
|
||||
},
|
||||
},
|
||||
"agents": {"demo": {"skills": [], "prompt": "", "bottle": "dev"}},
|
||||
})
|
||||
ups = git_gate_upstreams_for_bottle(m.bottles["dev"])
|
||||
self.assertEqual(
|
||||
{"gitea.dideric.is": "100.78.141.42"}, dict(ups[0].extra_hosts)
|
||||
)
|
||||
|
||||
def test_aggregator_merges_distinct_hostnames(self):
|
||||
ups = (
|
||||
GitGateUpstream(
|
||||
name="a", upstream_url="", upstream_host="", upstream_port="",
|
||||
identity_file="", known_host_key="",
|
||||
extra_hosts={"a.example": "10.0.0.1"},
|
||||
),
|
||||
GitGateUpstream(
|
||||
name="b", upstream_url="", upstream_host="", upstream_port="",
|
||||
identity_file="", known_host_key="",
|
||||
extra_hosts={"b.example": "10.0.0.2"},
|
||||
),
|
||||
)
|
||||
self.assertEqual(
|
||||
{"a.example": "10.0.0.1", "b.example": "10.0.0.2"},
|
||||
git_gate_aggregate_extra_hosts(ups),
|
||||
)
|
||||
|
||||
def test_aggregator_allows_same_host_same_ip(self):
|
||||
# Two entries listing the same host:ip is harmless duplication,
|
||||
# not a conflict. The gate's /etc/hosts ends up with one line.
|
||||
ups = (
|
||||
GitGateUpstream(
|
||||
name="a", upstream_url="", upstream_host="", upstream_port="",
|
||||
identity_file="", known_host_key="",
|
||||
extra_hosts={"gitea.dideric.is": "100.78.141.42"},
|
||||
),
|
||||
GitGateUpstream(
|
||||
name="b", upstream_url="", upstream_host="", upstream_port="",
|
||||
identity_file="", known_host_key="",
|
||||
extra_hosts={"gitea.dideric.is": "100.78.141.42"},
|
||||
),
|
||||
)
|
||||
self.assertEqual(
|
||||
{"gitea.dideric.is": "100.78.141.42"},
|
||||
git_gate_aggregate_extra_hosts(ups),
|
||||
)
|
||||
|
||||
def test_aggregator_rejects_conflicting_ips(self):
|
||||
ups = (
|
||||
GitGateUpstream(
|
||||
name="a", upstream_url="", upstream_host="", upstream_port="",
|
||||
identity_file="", known_host_key="",
|
||||
extra_hosts={"gitea.dideric.is": "100.78.141.42"},
|
||||
),
|
||||
GitGateUpstream(
|
||||
name="b", upstream_url="", upstream_host="", upstream_port="",
|
||||
identity_file="", known_host_key="",
|
||||
extra_hosts={"gitea.dideric.is": "10.0.0.99"},
|
||||
),
|
||||
)
|
||||
with self.assertRaises(Die):
|
||||
git_gate_aggregate_extra_hosts(ups)
|
||||
|
||||
def test_aggregator_empty_is_empty(self):
|
||||
self.assertEqual({}, git_gate_aggregate_extra_hosts(()))
|
||||
|
||||
|
||||
class TestKnownHostsLine(unittest.TestCase):
|
||||
def test_default_port_unbracketed(self):
|
||||
line = git_gate_known_hosts_line("github.com", "22", "ssh-ed25519 AAAA")
|
||||
|
||||
Reference in New Issue
Block a user