mirror of
https://github.com/DeBrosOfficial/orama.git
synced 2026-03-17 06:43:01 +00:00
Replaces plaintext password-based SSH authentication (sshpass) across the entire Go CLI with wallet-derived ed25519 keys via RootWallet. - Add `rw vault ssh agent-load` command to RootWallet CLI for SSH agent forwarding in push fanout - Create wallet.go bridge: PrepareNodeKeys resolves keys from `rw vault ssh get --priv`, writes temp PEMs (0600), zero-overwrites on cleanup - Remove Password field from Node struct, update config parser to new 3-field format (env|user@host|role) - Remove all sshpass branches from inspector/ssh.go and remotessh/ssh.go, require SSHKey on all SSH paths - Add WithAgentForward() option to RunSSHStreaming for hub fanout - Add PrepareNodeKeys + defer cleanup to all 7 entry points: inspect, monitor, push, upgrade, clean, recover, install - Update push fanout to use SSH agent forwarding instead of sshpass on hub - Delete install/ssh.go duplicate, replace with remotessh calls - Create nodes.conf from remote-nodes.conf (topology only, no secrets) - Update all config defaults and help text from remote-nodes.conf to nodes.conf - Use StrictHostKeyChecking=accept-new consistently everywhere
74 lines
1.9 KiB
Go
74 lines
1.9 KiB
Go
package checks
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/DeBrosOfficial/network/pkg/inspector"
|
|
)
|
|
|
|
// makeNode creates a test Node with the given host and role.
|
|
func makeNode(host, role string) inspector.Node {
|
|
return inspector.Node{
|
|
Environment: "devnet",
|
|
User: "ubuntu",
|
|
Host: host,
|
|
Role: role,
|
|
}
|
|
}
|
|
|
|
// makeNodeData creates a NodeData with a node but no subsystem data.
|
|
func makeNodeData(host, role string) *inspector.NodeData {
|
|
return &inspector.NodeData{
|
|
Node: makeNode(host, role),
|
|
}
|
|
}
|
|
|
|
// makeCluster creates a ClusterData from a map of host → NodeData.
|
|
func makeCluster(nodes map[string]*inspector.NodeData) *inspector.ClusterData {
|
|
return &inspector.ClusterData{
|
|
Nodes: nodes,
|
|
Duration: 1 * time.Second,
|
|
}
|
|
}
|
|
|
|
// countByStatus counts results with the given status.
|
|
func countByStatus(results []inspector.CheckResult, status inspector.Status) int {
|
|
n := 0
|
|
for _, r := range results {
|
|
if r.Status == status {
|
|
n++
|
|
}
|
|
}
|
|
return n
|
|
}
|
|
|
|
// findCheck returns a pointer to the first check matching the given ID, or nil.
|
|
func findCheck(results []inspector.CheckResult, id string) *inspector.CheckResult {
|
|
for i := range results {
|
|
if results[i].ID == id {
|
|
return &results[i]
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// requireCheck finds a check by ID and fails the test if not found.
|
|
func requireCheck(t *testing.T, results []inspector.CheckResult, id string) inspector.CheckResult {
|
|
t.Helper()
|
|
c := findCheck(results, id)
|
|
if c == nil {
|
|
t.Fatalf("check %q not found in %d results", id, len(results))
|
|
}
|
|
return *c
|
|
}
|
|
|
|
// expectStatus asserts that a check with the given ID has the expected status.
|
|
func expectStatus(t *testing.T, results []inspector.CheckResult, id string, status inspector.Status) {
|
|
t.Helper()
|
|
c := requireCheck(t, results, id)
|
|
if c.Status != status {
|
|
t.Errorf("check %q: want status=%s, got status=%s (msg=%s)", id, status, c.Status, c.Message)
|
|
}
|
|
}
|