@@ -45,21 +45,28 @@ func TestOAuth2Tokeninfo(t *testing.T) {
45
45
expected int
46
46
expectRequests int32
47
47
}{{
48
- msg : "invalid token" ,
48
+ msg : "oauthTokeninfoAnyScope: invalid token" ,
49
49
authType : filters .OAuthTokeninfoAnyScopeName ,
50
50
args : []interface {}{"not-matching-scope" },
51
51
auth : "invalid-token" ,
52
52
expected : http .StatusUnauthorized ,
53
53
expectRequests : N ,
54
54
}, {
55
- msg : "invalid scope" ,
55
+ msg : "oauthTokeninfoAnyScope: one invalid scope" ,
56
56
authType : filters .OAuthTokeninfoAnyScopeName ,
57
57
args : []interface {}{"not-matching-scope" },
58
58
auth : testToken ,
59
59
expected : http .StatusForbidden ,
60
60
expectRequests : N ,
61
61
}, {
62
- msg : "missing token" ,
62
+ msg : "oauthTokeninfoAnyScope: two invalid scopes" ,
63
+ authType : filters .OAuthTokeninfoAnyScopeName ,
64
+ args : []interface {}{"not-matching-scope1" , "not-matching-scope2" },
65
+ auth : testToken ,
66
+ expected : http .StatusForbidden ,
67
+ expectRequests : N ,
68
+ }, {
69
+ msg : "oauthTokeninfoAnyScope: missing token" ,
63
70
authType : filters .OAuthTokeninfoAnyScopeName ,
64
71
args : []interface {}{testScope },
65
72
auth : "" ,
@@ -73,98 +80,119 @@ func TestOAuth2Tokeninfo(t *testing.T) {
73
80
expected : http .StatusOK ,
74
81
expectRequests : N ,
75
82
}, {
76
- msg : "OAuthTokeninfoAnyScopeName : valid token, one valid scope, one invalid scope" ,
83
+ msg : "oauthTokeninfoAnyScope : valid token, one valid scope, one invalid scope" ,
77
84
authType : filters .OAuthTokeninfoAnyScopeName ,
78
85
args : []interface {}{testScope , "other-scope" },
79
86
auth : testToken ,
80
87
expected : http .StatusOK ,
81
88
expectRequests : N ,
82
89
}, {
83
- msg : "oauthTokeninfoAllScope(): valid token, valid scopes" ,
90
+ msg : "oauthTokeninfoAnyScope: valid token, one invalid scope, one valid scope" ,
91
+ authType : filters .OAuthTokeninfoAnyScopeName ,
92
+ args : []interface {}{"other-scope" , testScope },
93
+ auth : testToken ,
94
+ expected : http .StatusOK ,
95
+ expectRequests : N ,
96
+ }, {
97
+ msg : "oauthTokeninfoAllScope: valid token, all valid scopes" ,
84
98
authType : filters .OAuthTokeninfoAllScopeName ,
85
99
args : []interface {}{testScope , testScope2 , testScope3 },
86
100
auth : testToken ,
87
101
expected : http .StatusOK ,
88
102
expectRequests : N ,
89
103
}, {
90
- msg : "oauthTokeninfoAllScope(): valid token, one valid scope, one invalid scope" ,
104
+ msg : "oauthTokeninfoAllScope: valid token, two valid scopes" ,
105
+ authType : filters .OAuthTokeninfoAllScopeName ,
106
+ args : []interface {}{testScope , testScope2 },
107
+ auth : testToken ,
108
+ expected : http .StatusOK ,
109
+ expectRequests : N ,
110
+ }, {
111
+ msg : "oauthTokeninfoAllScope: valid token, one valid scope" ,
112
+ authType : filters .OAuthTokeninfoAllScopeName ,
113
+ args : []interface {}{testScope },
114
+ auth : testToken ,
115
+ expected : http .StatusOK ,
116
+ expectRequests : N ,
117
+ }, {
118
+ msg : "oauthTokeninfoAllScope: valid token, one valid scope, one invalid scope" ,
91
119
authType : filters .OAuthTokeninfoAllScopeName ,
92
120
args : []interface {}{testScope , "other-scope" },
93
121
auth : testToken ,
94
122
expected : http .StatusForbidden ,
95
123
expectRequests : N ,
96
124
}, {
97
- msg : "anyKV() : valid token, one valid key, wrong value" ,
125
+ msg : "oauthTokeninfoAnyKV : valid token, one valid key, wrong value" ,
98
126
authType : filters .OAuthTokeninfoAnyKVName ,
99
127
args : []interface {}{testKey , "other-value" },
100
128
auth : testToken ,
101
129
expected : http .StatusForbidden ,
102
130
expectRequests : N ,
103
131
}, {
104
- msg : "anyKV() : valid token, one valid key value pair" ,
132
+ msg : "oauthTokeninfoAnyKV : valid token, one valid key value pair" ,
105
133
authType : filters .OAuthTokeninfoAnyKVName ,
106
134
args : []interface {}{testKey , testValue },
107
135
auth : testToken ,
108
136
expected : http .StatusOK ,
109
137
expectRequests : N ,
110
138
}, {
111
- msg : "anyKV() : valid token, one valid kv, multiple key value pairs1" ,
139
+ msg : "oauthTokeninfoAnyKV : valid token, one valid kv, multiple key value pairs1" ,
112
140
authType : filters .OAuthTokeninfoAnyKVName ,
113
141
args : []interface {}{testKey , testValue , "wrongKey" , "wrongValue" },
114
142
auth : testToken ,
115
143
expected : http .StatusOK ,
116
144
expectRequests : N ,
117
145
}, {
118
- msg : "anyKV() : valid token, one valid kv, multiple key value pairs2" ,
146
+ msg : "oauthTokeninfoAnyKV : valid token, one valid kv, multiple key value pairs2" ,
119
147
authType : filters .OAuthTokeninfoAnyKVName ,
120
148
args : []interface {}{"wrongKey" , "wrongValue" , testKey , testValue },
121
149
auth : testToken ,
122
150
expected : http .StatusOK ,
123
151
expectRequests : N ,
124
152
}, {
125
- msg : "anyKV() : valid token, one valid kv, same key multiple times should pass" ,
153
+ msg : "oauthTokeninfoAnyKV : valid token, one valid kv, same key multiple times should pass" ,
126
154
authType : filters .OAuthTokeninfoAnyKVName ,
127
155
args : []interface {}{testKey , testValue , testKey , "someValue" },
128
156
auth : testToken ,
129
157
expected : http .StatusOK ,
130
158
expectRequests : N ,
131
159
}, {
132
- msg : "allKV() : valid token, one valid key, wrong value" ,
160
+ msg : "oauthTokeninfoAllKV : valid token, one valid key, wrong value" ,
133
161
authType : filters .OAuthTokeninfoAllKVName ,
134
162
args : []interface {}{testKey , "other-value" },
135
163
auth : testToken ,
136
164
expected : http .StatusForbidden ,
137
165
expectRequests : N ,
138
166
}, {
139
- msg : "allKV() : valid token, one valid key value pair" ,
167
+ msg : "oauthTokeninfoAllKV : valid token, one valid key value pair" ,
140
168
authType : filters .OAuthTokeninfoAllKVName ,
141
169
args : []interface {}{testKey , testValue },
142
170
auth : testToken ,
143
171
expected : http .StatusOK ,
144
172
expectRequests : N ,
145
173
}, {
146
- msg : "allKV() : valid token, one valid key value pair, check realm" ,
174
+ msg : "oauthTokeninfoAllKV : valid token, one valid key value pair, check realm" ,
147
175
authType : filters .OAuthTokeninfoAllKVName ,
148
176
args : []interface {}{testRealmKey , testRealm , testKey , testValue },
149
177
auth : testToken ,
150
178
expected : http .StatusOK ,
151
179
expectRequests : N ,
152
180
}, {
153
- msg : "allKV() : valid token, valid key value pairs" ,
181
+ msg : "oauthTokeninfoAllKV : valid token, valid key value pairs" ,
154
182
authType : filters .OAuthTokeninfoAllKVName ,
155
183
args : []interface {}{testKey , testValue , testKey , testValue },
156
184
auth : testToken ,
157
185
expected : http .StatusOK ,
158
186
expectRequests : N ,
159
187
}, {
160
- msg : "allKV() : valid token, one valid kv, multiple key value pairs1" ,
188
+ msg : "oauthTokeninfoAllKV : valid token, one valid kv, multiple key value pairs1" ,
161
189
authType : filters .OAuthTokeninfoAllKVName ,
162
190
args : []interface {}{testKey , testValue , "wrongKey" , "wrongValue" },
163
191
auth : testToken ,
164
192
expected : http .StatusForbidden ,
165
193
expectRequests : N ,
166
194
}, {
167
- msg : "allKV() : valid token, one valid kv, multiple key value pairs2" ,
195
+ msg : "oauthTokeninfoAllKV : valid token, one valid kv, multiple key value pairs2" ,
168
196
authType : filters .OAuthTokeninfoAllKVName ,
169
197
args : []interface {}{"wrongKey" , "wrongValue" , testKey , testValue },
170
198
auth : testToken ,
0 commit comments