From 11da45888314b4ad31318a629bb0e6d683ecd992 Mon Sep 17 00:00:00 2001 From: Jon Chery Date: Tue, 4 Aug 2026 12:04:28 +0000 Subject: [PATCH] test(cli): --host-key-fingerprint non-proxmox validation (T02.11, REQ-058) ---ci--- project: orca phase: 2 milestone: v0.8 status: execute ---/ci--- --- internal/cli/node_test.go | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/internal/cli/node_test.go b/internal/cli/node_test.go index 2b4f4a2..3b54334 100644 --- a/internal/cli/node_test.go +++ b/internal/cli/node_test.go @@ -437,3 +437,60 @@ func seedProxmoxNode(t *testing.T, name, addr string) string { } return n.ID } + +// TestNodeJoinHostKeyFingerprintRequiresProxmox verifies T02.11: +// `orca node join --type linux --host-key-fingerprint SHA256:...` +// fails with a clear error from the D-044 RunE check. Exercises the +// cobra Execute() error path end-to-end. +func TestNodeJoinHostKeyFingerprintRequiresProxmox(t *testing.T) { + _, cleanup := initTestEnv(t) + defer cleanup() + resetRootFlags(t) + var buf bytes.Buffer + rootCmd.SetOut(&buf) + rootCmd.SetErr(&buf) + rootCmd.SetArgs([]string{ + "node", "join", + "--type", "linux", + "--name", "linux-node", + "--host-key-fingerprint", "SHA256:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", + }) + err := rootCmd.Execute() + if err == nil { + t.Fatal("expected error for --host-key-fingerprint without --type proxmox, got nil") + } + if !strings.Contains(err.Error(), "--host-key-fingerprint requires --type proxmox") { + t.Errorf("error should mention the --host-key-fingerprint/--type proxmox requirement, got: %v", err) + } +} + +// TestNodeJoinHostKeyFingerprintProxmoxAccepted verifies that +// --host-key-fingerprint IS accepted for --type proxmox (the RunE check +// does not reject a proxmox-type join that pins the host key). This is +// the negative-space companion to TestNodeJoinHostKeyFingerprintRequiresProxmox +// (T02.11): the validation must only reject non-proxmox types. +// +// We can't run the full bootstrap without a real SSH server, so we +// assert that the RunE check passes (no "requires --type proxmox" +// error) and the failure — if any — comes from a later stage (missing +// --host / password), not the D-044 guard. +func TestNodeJoinHostKeyFingerprintProxmoxAccepted(t *testing.T) { + _, cleanup := initTestEnv(t) + defer cleanup() + resetRootFlags(t) + var buf bytes.Buffer + rootCmd.SetOut(&buf) + rootCmd.SetErr(&buf) + rootCmd.SetArgs([]string{ + "node", "join", + "--type", "proxmox", + "--host-key-fingerprint", "SHA256:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", + }) + err := rootCmd.Execute() + if err == nil { + t.Fatal("expected a later-stage error (missing --host), got nil") + } + if strings.Contains(err.Error(), "requires --type proxmox") { + t.Errorf("D-044 guard wrongly rejected proxmox type: %v", err) + } +}