@@ -124,7 +124,7 @@ func TestNewAccessRequest(t *testing.T) {
124
124
store .EXPECT ().GetClient (gomock .Eq ("foo" )).Return (client , nil )
125
125
client .EXPECT ().GetHashedSecret ().Return ([]byte ("foo" ))
126
126
hasher .EXPECT ().Compare (gomock .Eq ([]byte ("foo" )), gomock .Eq ([]byte ("bar" ))).Return (nil )
127
- handler .EXPECT ().ValidateTokenEndpointRequest (gomock .Any (), gomock .Any (), gomock .Any ()).Return (ErrServerError )
127
+ handler .EXPECT ().HandleTokenEndpointRequest (gomock .Any (), gomock .Any (), gomock .Any ()).Return (ErrServerError )
128
128
},
129
129
handlers : TokenEndpointHandlers {handler },
130
130
},
@@ -136,48 +136,11 @@ func TestNewAccessRequest(t *testing.T) {
136
136
form : url.Values {
137
137
"grant_type" : {"foo" },
138
138
},
139
- expectErr : ErrUnsupportedGrantType ,
140
139
mock : func () {
141
140
store .EXPECT ().GetClient (gomock .Eq ("foo" )).Return (client , nil )
142
141
client .EXPECT ().GetHashedSecret ().Return ([]byte ("foo" ))
143
142
hasher .EXPECT ().Compare (gomock .Eq ([]byte ("foo" )), gomock .Eq ([]byte ("bar" ))).Return (nil )
144
- handler .EXPECT ().ValidateTokenEndpointRequest (gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil )
145
- },
146
- handlers : TokenEndpointHandlers {handler },
147
- },
148
- {
149
- header : http.Header {
150
- "Authorization" : {basicAuth ("foo" , "bar" )},
151
- },
152
- method : "POST" ,
153
- form : url.Values {
154
- "grant_type" : {"foo" },
155
- },
156
- expectErr : ErrUnsupportedGrantType ,
157
- mock : func () {
158
- store .EXPECT ().GetClient (gomock .Eq ("foo" )).Return (client , nil )
159
- client .EXPECT ().GetHashedSecret ().Return ([]byte ("foo" ))
160
- hasher .EXPECT ().Compare (gomock .Eq ([]byte ("foo" )), gomock .Eq ([]byte ("bar" ))).Return (nil )
161
- handler .EXPECT ().ValidateTokenEndpointRequest (gomock .Any (), gomock .Any (), gomock .Any ()).Do (func (_ context.Context , _ * http.Request , a AccessRequester ) {
162
- a .SetGrantTypeHandled ("bar" )
163
- }).Return (nil )
164
- },
165
- handlers : TokenEndpointHandlers {handler },
166
- },
167
- {
168
- header : http.Header {
169
- "Authorization" : {basicAuth ("foo" , "bar" )},
170
- },
171
- method : "POST" ,
172
- form : url.Values {
173
- "grant_type" : {"foo" },
174
- },
175
- mock : func () {
176
- store .EXPECT ().GetClient (gomock .Eq ("foo" )).Return (client , nil )
177
- client .EXPECT ().GetHashedSecret ().Return ([]byte ("foo" ))
178
- hasher .EXPECT ().Compare (gomock .Eq ([]byte ("foo" )), gomock .Eq ([]byte ("bar" ))).Return (nil )
179
- handler .EXPECT ().ValidateTokenEndpointRequest (gomock .Any (), gomock .Any (), gomock .Any ()).Do (func (_ context.Context , _ * http.Request , a AccessRequester ) {
180
- a .SetGrantTypeHandled ("foo" )
143
+ handler .EXPECT ().HandleTokenEndpointRequest (gomock .Any (), gomock .Any (), gomock .Any ()).Do (func (_ context.Context , _ * http.Request , a AccessRequester ) {
181
144
a .SetScopes ([]string {"asdfasdf" })
182
145
}).Return (nil )
183
146
},
@@ -196,15 +159,13 @@ func TestNewAccessRequest(t *testing.T) {
196
159
store .EXPECT ().GetClient (gomock .Eq ("foo" )).Return (client , nil )
197
160
client .EXPECT ().GetHashedSecret ().Return ([]byte ("foo" ))
198
161
hasher .EXPECT ().Compare (gomock .Eq ([]byte ("foo" )), gomock .Eq ([]byte ("bar" ))).Return (nil )
199
- handler .EXPECT ().ValidateTokenEndpointRequest (gomock .Any (), gomock .Any (), gomock .Any ()).Do (func (_ context.Context , _ * http.Request , a AccessRequester ) {
200
- a .SetGrantTypeHandled ("foo" )
162
+ handler .EXPECT ().HandleTokenEndpointRequest (gomock .Any (), gomock .Any (), gomock .Any ()).Do (func (_ context.Context , _ * http.Request , a AccessRequester ) {
201
163
a .SetScopes ([]string {DefaultRequiredScopeName })
202
164
}).Return (nil )
203
165
},
204
166
handlers : TokenEndpointHandlers {handler },
205
167
expect : & AccessRequest {
206
- GrantTypes : Arguments {"foo" },
207
- HandledGrantType : []string {"foo" },
168
+ GrantTypes : Arguments {"foo" },
208
169
Request : Request {
209
170
Client : client ,
210
171
},
@@ -227,7 +188,7 @@ func TestNewAccessRequest(t *testing.T) {
227
188
t .Logf ("Error occured: %s" , err .(* errors.Error ).ErrorStack ())
228
189
}
229
190
if err == nil {
230
- pkg .AssertObjectKeysEqual (t , c .expect , ar , "GrantType " , "Client" )
191
+ pkg .AssertObjectKeysEqual (t , c .expect , ar , "GrantTypes " , "Client" )
231
192
assert .NotNil (t , ar .GetRequestedAt ())
232
193
}
233
194
t .Logf ("Passed test case %d" , k )
0 commit comments