test(cli): --host-key-fingerprint non-proxmox validation (T02.11, REQ-058)
---ci--- project: orca phase: 2 milestone: v0.8 status: execute ---/ci---
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user