...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package verification
16
17 import (
18 "crypto"
19 "testing"
20
21 "github.com/digitorus/timestamp"
22 )
23
24 func TestVerifyRequest(t *testing.T) {
25 tsReq := ×tamp.Request{}
26
27 for _, alg := range []crypto.Hash{crypto.SHA256, crypto.SHA384, crypto.SHA512} {
28 tsReq.HashAlgorithm = alg
29 if err := VerifyRequest(tsReq); err != nil {
30 t.Fatalf("unexpected error verifying request, got %v", err)
31 }
32 }
33
34 tsReq.HashAlgorithm = crypto.SHA1
35 if err := VerifyRequest(tsReq); err != ErrWeakHashAlg {
36 t.Fatalf("expected error with weak hash algorithm, got %v", err)
37 }
38 }
39
View as plain text