From c1decadb590c4d79d92bcc4df7772119a5c91244 Mon Sep 17 00:00:00 2001 From: Gab Virebent Date: Sat, 22 Aug 2026 20:36:56 +0200 Subject: Initial Aegis Usenet client release --- internal/cryptokit/yubicrypt_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 internal/cryptokit/yubicrypt_test.go (limited to 'internal/cryptokit/yubicrypt_test.go') 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") + } +} -- cgit v1.2.3