-
-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathskel_test.go
More file actions
61 lines (47 loc) · 1.27 KB
/
skel_test.go
File metadata and controls
61 lines (47 loc) · 1.27 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//go:build full || e2e
package main
import (
"encoding/base64"
"testing"
)
func TestTrustedUserCAKeysDecode(t *testing.T) {
ca := "ca-key"
p := pipe{
TrustedUserCAKeys: base64.StdEncoding.EncodeToString([]byte(ca)),
PrivateKey: base64.StdEncoding.EncodeToString([]byte("key")),
}
w := skelpipeWrapper{pipe: &p}
froms := w.From()
if len(froms) != 1 {
t.Fatalf("expected one from wrapper, got %d", len(froms))
}
pub, ok := froms[0].(*skelpipePublicKeyWrapper)
if !ok {
t.Fatalf("expected public key wrapper, got %T", froms[0])
}
data, err := pub.TrustedUserCAKeys(nil)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if string(data) != ca {
t.Fatalf("unexpected trusted ca data, got %q", string(data))
}
}
func TestTrustedUserCAKeysDecodeError(t *testing.T) {
p := pipe{
TrustedUserCAKeys: "!!not-base64!!",
PrivateKey: base64.StdEncoding.EncodeToString([]byte("key")),
}
w := skelpipeWrapper{pipe: &p}
froms := w.From()
if len(froms) != 1 {
t.Fatalf("expected one from wrapper, got %d", len(froms))
}
pub, ok := froms[0].(*skelpipePublicKeyWrapper)
if !ok {
t.Fatalf("expected public key wrapper, got %T", froms[0])
}
if _, err := pub.TrustedUserCAKeys(nil); err == nil {
t.Fatalf("expected decode error, got nil")
}
}