MCPcopy Create free account
hub / github.com/zalando/skipper / Test_spec_Create

Function Test_spec_Create

predicates/auth/jwt_test.go:58–198  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func Test_spec_Create(t *testing.T) {
59 tests := []struct {
60 name string
61 spec routing.PredicateSpec
62 args []interface{}
63 want routing.Predicate
64 wantErr bool
65 }{{
66 name: "invalid number of args",
67 spec: NewJWTPayloadAllKV(),
68 args: []interface{}{"foo"},
69 want: nil,
70 wantErr: true,
71 }, {
72 name: "invalid type of args",
73 spec: NewJWTPayloadAllKV(),
74 args: []interface{}{3, 5},
75 want: nil,
76 wantErr: true,
77 }, {
78 name: "one valid kv pair of args",
79 spec: NewJWTPayloadAllKV(),
80 args: []interface{}{"uid", "sszuecs"},
81 want: &predicate{
82 kv: map[string][]valueMatcher{
83 "uid": {exact("sszuecs")},
84 },
85 matchBehavior: matchBehaviorAll,
86 },
87 wantErr: false,
88 }, {
89 name: "one valid kv pair of args",
90 spec: NewJWTPayloadAnyKV(),
91 args: []interface{}{"uid", "sszuecs"},
92 want: &predicate{
93 kv: map[string][]valueMatcher{
94 "uid": {exact("sszuecs")},
95 },
96 matchBehavior: matchBehaviorAny,
97 },
98 wantErr: false,
99 }, {
100 name: "valid kv pair of args of the same key",
101 spec: NewJWTPayloadAnyKV(),
102 args: []interface{}{"uid", "sszuecs", "uid", "foo"},
103 want: &predicate{
104 kv: map[string][]valueMatcher{
105 "uid": {exact("sszuecs"), exact("foo")},
106 },
107 matchBehavior: matchBehaviorAny,
108 },
109 wantErr: false,
110 }, {
111 name: "many valid kv pair of args",
112 spec: NewJWTPayloadAllKV(),
113 args: []interface{}{"uid", "sszuecs", "claim1", "claimValue1", "claim2", "claimValue2"},
114 want: &predicate{
115 kv: map[string][]valueMatcher{

Callers

nothing calls this directly

Calls 8

NewJWTPayloadAllKVFunction · 0.85
exactFunction · 0.85
NewJWTPayloadAnyKVFunction · 0.85
NewJWTPayloadAllKVRegexpFunction · 0.85
regexFunction · 0.85
NewJWTPayloadAnyKVRegexpFunction · 0.85
ErrorfMethod · 0.65
CreateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…