diff options
Diffstat (limited to 'internal/cryptokit/yubicrypt_test.go')
| -rw-r--r-- | internal/cryptokit/yubicrypt_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/cryptokit/yubicrypt_test.go b/internal/cryptokit/yubicrypt_test.go new file mode 100644 index 0000000..5adaf40 --- /dev/null +++ b/internal/cryptokit/yubicrypt_test.go @@ -0,0 +1,36 @@ +package cryptokit + +import ( + "os" + "path/filepath" + "testing" +) + +func TestFindYubiCryptCLIUsesExplicitExecutable(t *testing.T) { + directory := t.TempDir() + path := filepath.Join(directory, "yubicrypt") + if err := os.WriteFile(path, []byte("#!/bin/sh\nexit 0\n"), 0o700); err != nil { + t.Fatal(err) + } + t.Setenv("AEGIS_YUBICRYPT_CLI", path) + found, err := FindYubiCryptCLI() + if err != nil { + t.Fatal(err) + } + if found != path { + t.Fatalf("found %q, want %q", found, path) + } +} + +func TestRequireYubiPIN(t *testing.T) { + input, err := requireYubiPIN("123456\n") + if err != nil { + t.Fatal(err) + } + if string(input) != "123456\n" { + t.Fatalf("unexpected PIN input %q", input) + } + if _, err := requireYubiPIN(""); err == nil { + t.Fatal("empty PIN accepted") + } +} |
