(t *testing.T)
| 56 | } |
| 57 | |
| 58 | func 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{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…