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") } }