blob: 5adaf4030821aa61520c95f07cdc45506298111f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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")
}
}
|