-
Notifications
You must be signed in to change notification settings - Fork 3
/
digital_signature_test.go
59 lines (53 loc) · 1.21 KB
/
digital_signature_test.go
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
package gcs
import (
"testing"
"time"
)
func TestValidDigitalSignatureObject(t *testing.T) {
time := time.Now()
dg := &DigitalSignature{
CompanyName: "Microsoft Corporation",
CreatedTimed: &time,
DeveloperUID: "123",
Fingerprints: nil,
IssuerName: "LibreSSL",
SerialNumber: "345",
}
_, err := ValidateDigitalSignature(dg)
if err != nil {
t.Fatalf("Digital Signature should have been valid: %v", err)
}
}
func TestInvalidDigitalSignatureObject(t *testing.T) {
time := time.Now()
dg := &DigitalSignature{
CompanyName: "",
CreatedTimed: &time,
DeveloperUID: "123",
Fingerprints: nil,
IssuerName: "LibreSSL",
SerialNumber: "345",
}
_, err := ValidateDigitalSignature(dg)
if err == nil {
t.Fatalf("Digital Signature should have been invalid: %v", err)
}
}
func BenchmarkValidDigitalSignatureObject(b *testing.B) {
b.ReportAllocs()
time := time.Now()
dg := &DigitalSignature{
CompanyName: "Microsoft Corporation",
CreatedTimed: &time,
DeveloperUID: "123",
Fingerprints: nil,
IssuerName: "LibreSSL",
SerialNumber: "345",
}
for n := 0; n < b.N; n++ {
_, err := ValidateDigitalSignature(dg)
if err != nil {
b.Fatalf("DigitalSignature object is invalid: %v", err)
}
}
}