summaryrefslogtreecommitdiffstats
path: root/internal/cryptokit/yubicrypt_test.go
diff options
context:
space:
mode:
authorGab Virebent <gabriel1@virebent.art>2026-08-22 20:36:56 +0200
committerGab Virebent <gabriel1@virebent.art>2026-08-22 20:36:56 +0200
commitc1decadb590c4d79d92bcc4df7772119a5c91244 (patch)
tree468f9fa37535dbb90cc5d4061eb20de83912131e /internal/cryptokit/yubicrypt_test.go
downloadaegis-c1decadb590c4d79d92bcc4df7772119a5c91244.tar.gz
aegis-c1decadb590c4d79d92bcc4df7772119a5c91244.tar.xz
aegis-c1decadb590c4d79d92bcc4df7772119a5c91244.zip
Initial Aegis Usenet client release
Diffstat (limited to 'internal/cryptokit/yubicrypt_test.go')
-rw-r--r--internal/cryptokit/yubicrypt_test.go36
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")
+ }
+}