box_walk: a target table (9202, 9201, tester-1 via a jump through the HP box); the Tester 1 guest is a test box for the admin seed (R-892, decision 158)
gates / gates (push) Successful in 5s
gates / gates (push) Successful in 5s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
@@ -346,6 +346,12 @@ class BoxAdminSeedGuard(unittest.TestCase):
|
||||
self.assertIsNone(got)
|
||||
self.assertIn("test-box admin invite", fx_.tried)
|
||||
|
||||
def test_the_tester_1_box_is_a_test_box_and_demo_hp_9201_is_not(self):
|
||||
self.assertEqual(self.allowed(FakeBoxWalk(hp="tester-1", guest="9201"), self.ENV), (True, ""))
|
||||
ok, why = self.allowed(FakeBoxWalk(hp="demo-hp", guest="9201"), self.ENV)
|
||||
self.assertFalse(ok)
|
||||
self.assertIn("not a test box", why)
|
||||
|
||||
def test_only_a_drill_address_is_invited(self):
|
||||
with self.assertRaises(ValueError):
|
||||
fxbox.box_admin_invite(FakeBoxWalk(), 'x"}; rm -rf /; {"@gate.invalid')
|
||||
@@ -390,6 +396,51 @@ class DefinitionEdge(unittest.TestCase):
|
||||
ut.add_definition_edge("app1", "same")
|
||||
|
||||
|
||||
class BoxWalkTargets(unittest.TestCase):
|
||||
"""R-892: box_walk's target table. Each test imports box_walk afresh under its own TARGET. RED-PROOF (REPORT): drop
|
||||
the `-J` from ssh_args — test_the_tester_1_box_is_reached_through_the_hp_box fails."""
|
||||
|
||||
def load(self, env):
|
||||
import importlib
|
||||
with mock.patch.dict(os.environ, env, clear=False):
|
||||
for k in ("TARGET", "GUEST", "BASE", "DOMAIN"):
|
||||
if k not in env:
|
||||
os.environ.pop(k, None)
|
||||
sys.modules.pop("box_walk", None)
|
||||
return importlib.import_module("box_walk")
|
||||
|
||||
def test_every_row_is_complete(self):
|
||||
bw = self.load({})
|
||||
for name, row in bw.TARGETS.items():
|
||||
self.assertEqual(set(row), {"hp", "ssh", "jump", "guest", "base", "domain"}, name)
|
||||
self.assertTrue(row["base"].startswith("https://"), name)
|
||||
|
||||
def test_the_default_stays_scratch_9202(self):
|
||||
bw = self.load({})
|
||||
self.assertEqual((bw.HP, bw.GUEST, bw.BASE), ("demo-hp", "9202", "https://192.168.0.114"))
|
||||
self.assertEqual(bw.ssh_args()[-1], "demo-hp")
|
||||
self.assertNotIn("-J", bw.ssh_args())
|
||||
|
||||
def test_the_old_guest_switch_still_selects_demo_hp_9201(self):
|
||||
bw = self.load({"GUEST": "9201"})
|
||||
self.assertEqual((bw.HP, bw.GUEST, bw.BASE), ("demo-hp", "9201", "https://192.168.0.155"))
|
||||
|
||||
def test_the_tester_1_box_is_reached_through_the_hp_box(self):
|
||||
bw = self.load({"TARGET": "tester-1"})
|
||||
self.assertEqual((bw.HP, bw.GUEST, bw.DOMAIN), ("tester-1", "9201", "enkicsifelhom.hu"))
|
||||
a = bw.ssh_args()
|
||||
self.assertEqual(a[a.index("-J") + 1], "demo-hp")
|
||||
self.assertEqual(a[-1], "root@192.168.0.154")
|
||||
self.assertIn(("tester-1", "9201"), fxbox.BOX_ADMIN_SEED_GUESTS)
|
||||
|
||||
def test_an_unknown_target_is_refused(self):
|
||||
with self.assertRaises(SystemExit):
|
||||
self.load({"TARGET": "ep0"})
|
||||
|
||||
def tearDown(self):
|
||||
sys.modules.pop("box_walk", None)
|
||||
|
||||
|
||||
class SecretHygiene(unittest.TestCase):
|
||||
"""The run's secrets: .env 0600 and shredded, every evidence file redacted. RED-PROOF (REPORT): make redact_tree
|
||||
return [] without rewriting — test_evidence_files_are_redacted fails."""
|
||||
|
||||
Reference in New Issue
Block a user