-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv3loc_test.go
52 lines (43 loc) · 1.04 KB
/
v3loc_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
package paseto
import (
"encoding/hex"
"strings"
"testing"
)
func TestV3Loc_Encrypt(t *testing.T) {
t.Skip()
testCases := loadGoldenFile("testdata/v3.json")
for _, tc := range testCases.Tests {
if tc.Key == "" || !strings.HasPrefix(tc.Token, v3locHeader) {
continue
}
t.Run(tc.Name, func(t *testing.T) {
key := mustHex(tc.Key)
payload := mustJSON(tc.Payload)
footer := mustJSON(tc.Footer)
imp := tc.ImplicitAssertion
nonce := mustHex(tc.Nonce)
token, err := V3Encrypt(key, payload, footer, imp, nonce)
if err != nil {
t.Fatal(err)
}
mustEqual(t, token, tc.Token)
})
}
}
func TestV3Loc_Decrypt(t *testing.T) {
t.Skip()
testCases := loadGoldenFile("testdata/v3.json")
for _, tc := range testCases.Tests {
if tc.Key == "" || !strings.HasPrefix(tc.Token, v3locHeader) {
continue
}
t.Run(tc.Name, func(t *testing.T) {
imp := tc.ImplicitAssertion
key := must(hex.DecodeString(tc.Key))
var payload, footer any
err := V3Decrypt(tc.Token, key, payload, footer, imp)
mustOk(t, err)
})
}
}