MCPcopy
hub / github.com/golang-jwt/jwt / TestSplitToken

Function TestSplitToken

jwt_test.go:7–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5)
6
7func TestSplitToken(t *testing.T) {
8 t.Parallel()
9
10 tests := []struct {
11 name string
12 input string
13 expected []string
14 isValid bool
15 }{
16 {
17 name: "valid token with three parts",
18 input: "header.claims.signature",
19 expected: []string{"header", "claims", "signature"},
20 isValid: true,
21 },
22 {
23 name: "invalid token with two parts only",
24 input: "header.claims",
25 expected: nil,
26 isValid: false,
27 },
28 {
29 name: "invalid token with one part only",
30 input: "header",
31 expected: nil,
32 isValid: false,
33 },
34 {
35 name: "invalid token with extra delimiter",
36 input: "header.claims.signature.extra",
37 expected: nil,
38 isValid: false,
39 },
40 {
41 name: "invalid empty token",
42 input: "",
43 expected: nil,
44 isValid: false,
45 },
46 {
47 name: "valid token with empty parts",
48 input: "..signature",
49 expected: []string{"", "", "signature"},
50 isValid: true,
51 },
52 {
53 // We are just splitting the token into parts, so we don't care about the actual values.
54 // It is up to the caller to validate the parts.
55 name: "valid token with all parts empty",
56 input: "..",
57 expected: []string{"", "", ""},
58 isValid: true,
59 },
60 {
61 name: "invalid token with just delimiters and extra part",
62 input: "...",
63 expected: nil,
64 isValid: false,

Callers

nothing calls this directly

Calls 1

splitTokenFunction · 0.85

Tested by

no test coverage detected