Files
archipelago/secret-engines/sops/main_test.go
T
sam 34bd70f1c1
publish / publish (push) Successful in 2m53s
feat(connectors): host connector with read-only SSH lookups; sops engine on the sops library
The host connector answers filesystem_usage, directory_sizes and old_files on
configured hosts over SSH with pinned host keys, dialling through the egress
tunnel when confined. The sops engine decrypts with the sops library instead
of the CLI, takes its file from settings and an age identity from its secrets.
2026-11-15 22:14:26 +11:00

33 lines
821 B
Go

package main
import (
"errors"
"testing"
"github.com/samcharles93/archipelago/sdk/secretengine"
)
func TestLookup(t *testing.T) {
doc, err := parse("secrets.yaml", []byte("token: s3cret\nport: 5432\nnested: {a: 1}\nempty: \"\"\nnil: null\nkey: |\n line one\n line two\n"))
if err != nil {
t.Fatal(err)
}
for _, tc := range []struct {
key, want string
missing bool
}{
{key: "token", want: "s3cret"},
{key: "port", want: "5432"},
{key: "nested", want: `{"a":1}`},
{key: "key", want: "line one\nline two\n"},
{key: "empty", missing: true},
{key: "nil", missing: true},
{key: `"] --output x`, missing: true},
} {
got, err := lookup(doc, tc.key)
if tc.missing != errors.Is(err, secretengine.ErrNotFound) || got != tc.want {
t.Errorf("lookup(%q) = %q, %v", tc.key, got, err)
}
}
}