|
93 | 93 | mock_response(
|
94 | 94 | :post,
|
95 | 95 | 'https://server.example.com/oauth2/token',
|
96 |
| - 'tokens/bearer.json', |
| 96 | + 'tokens/bearer', |
97 | 97 | request_header: {
|
98 | 98 | 'Authorization' => 'Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ='
|
99 | 99 | }
|
|
109 | 109 | mock_response(
|
110 | 110 | :post,
|
111 | 111 | 'https://server.example.com/oauth2/token',
|
112 |
| - 'tokens/bearer.json', |
| 112 | + 'tokens/bearer', |
113 | 113 | request_header: {
|
114 | 114 | 'Authorization' => 'Basic aHR0cHMlM0ElMkYlMkZjbGllbnQuZXhhbXBsZS5jb206Y2xpZW50X3NlY3JldA=='
|
115 | 115 | }
|
|
127 | 127 | mock_response(
|
128 | 128 | :post,
|
129 | 129 | 'https://server.example.com/oauth2/token',
|
130 |
| - 'tokens/bearer.json', |
| 130 | + 'tokens/bearer', |
131 | 131 | request_header: {
|
132 | 132 | 'Authorization' => 'Basic aHR0cHM6Ly9jbGllbnQuZXhhbXBsZS5jb206Y2xpZW50X3NlY3JldA=='
|
133 | 133 | }
|
|
143 | 143 | mock_response(
|
144 | 144 | :post,
|
145 | 145 | 'https://server.example.com/oauth2/token',
|
146 |
| - 'tokens/bearer.json', |
| 146 | + 'tokens/bearer', |
147 | 147 | params: {
|
148 | 148 | client_assertion: /^eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9\..+/, # NOTE: HS256
|
149 | 149 | client_assertion_type: Rack::OAuth2::URN::ClientAssertionType::JWT_BEARER,
|
|
171 | 171 | mock_response(
|
172 | 172 | :post,
|
173 | 173 | 'https://server.example.com/oauth2/token',
|
174 |
| - 'tokens/bearer.json', |
| 174 | + 'tokens/bearer', |
175 | 175 | params: {
|
176 | 176 | client_assertion: /^eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9\..+/, # NOTE: RS256
|
177 | 177 | client_assertion_type: Rack::OAuth2::URN::ClientAssertionType::JWT_BEARER,
|
|
198 | 198 | mock_response(
|
199 | 199 | :post,
|
200 | 200 | 'https://server.example.com/oauth2/token',
|
201 |
| - 'tokens/bearer.json', |
| 201 | + 'tokens/bearer', |
202 | 202 | params: {
|
203 | 203 | client_assertion: /^eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9\..+/, # NOTE: ES256
|
204 | 204 | client_assertion_type: Rack::OAuth2::URN::ClientAssertionType::JWT_BEARER,
|
|
225 | 225 | mock_response(
|
226 | 226 | :post,
|
227 | 227 | 'https://server.example.com/oauth2/token',
|
228 |
| - 'tokens/bearer.json', |
| 228 | + 'tokens/bearer', |
229 | 229 | params: {
|
230 | 230 | client_assertion: 'any.jwt.assertion',
|
231 | 231 | client_assertion_type: Rack::OAuth2::URN::ClientAssertionType::JWT_BEARER,
|
|
244 | 244 | mock_response(
|
245 | 245 | :post,
|
246 | 246 | 'https://server.example.com/oauth2/token',
|
247 |
| - 'tokens/bearer.json', |
| 247 | + 'tokens/bearer', |
248 | 248 | params: {
|
249 | 249 | client_id: 'client_id',
|
250 | 250 | client_secret: 'client_secret',
|
|
262 | 262 | mock_response(
|
263 | 263 | :post,
|
264 | 264 | 'https://server.example.com/oauth2/token',
|
265 |
| - 'tokens/bearer.json', |
| 265 | + 'tokens/bearer', |
266 | 266 | params: {
|
267 | 267 | client_id: 'client_id',
|
268 | 268 | client_secret: 'client_secret',
|
|
282 | 282 | mock_response(
|
283 | 283 | :post,
|
284 | 284 | 'https://server.example.com/oauth2/token',
|
285 |
| - 'tokens/bearer.json', |
| 285 | + 'tokens/bearer', |
286 | 286 | params: {
|
287 | 287 | grant_type: 'client_credentials',
|
288 | 288 | scope: 'a b'
|
|
298 | 298 | mock_response(
|
299 | 299 | :post,
|
300 | 300 | 'https://server.example.com/oauth2/token',
|
301 |
| - 'tokens/bearer.json', |
| 301 | + 'tokens/bearer', |
302 | 302 | params: {
|
303 | 303 | grant_type: 'client_credentials',
|
304 | 304 | resource: 'something'
|
|
314 | 314 | mock_response(
|
315 | 315 | :post,
|
316 | 316 | 'https://server.example.com/oauth2/token',
|
317 |
| - 'tokens/bearer.json', |
| 317 | + 'tokens/bearer', |
318 | 318 | request_header: {
|
319 | 319 | 'Authorization' => 'Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=',
|
320 | 320 | 'X-Foo' => 'bar'
|
|
332 | 332 | mock_response(
|
333 | 333 | :post,
|
334 | 334 | 'https://server.example.com/oauth2/token',
|
335 |
| - 'tokens/bearer.json' |
| 335 | + 'tokens/bearer' |
336 | 336 | )
|
337 | 337 | end
|
338 | 338 | it { should be_instance_of Rack::OAuth2::AccessToken::Bearer }
|
|
347 | 347 | mock_response(
|
348 | 348 | :post,
|
349 | 349 | 'https://server.example.com/oauth2/token',
|
350 |
| - 'tokens/_Bearer.json' |
| 350 | + 'tokens/_Bearer' |
351 | 351 | )
|
352 | 352 | end
|
353 | 353 | it { should be_instance_of Rack::OAuth2::AccessToken::Bearer }
|
354 | 354 | its(:token_type) { should == :bearer }
|
355 | 355 | end
|
356 | 356 | end
|
357 | 357 |
|
358 |
| - context 'when no-type token is given (JSON)' do |
359 |
| - before do |
360 |
| - client.authorization_code = 'code' |
361 |
| - mock_response( |
362 |
| - :post, |
363 |
| - 'https://server.example.com/oauth2/token', |
364 |
| - 'tokens/legacy.json' |
365 |
| - ) |
366 |
| - end |
367 |
| - it { should be_instance_of Rack::OAuth2::AccessToken::Legacy } |
368 |
| - its(:token_type) { should == :legacy } |
369 |
| - its(:access_token) { should == 'access_token' } |
370 |
| - its(:refresh_token) { should == 'refresh_token' } |
371 |
| - its(:expires_in) { should == 3600 } |
372 |
| - |
373 |
| - context 'when token_type is forced' do |
374 |
| - before do |
375 |
| - client.force_token_type! :bearer |
376 |
| - end |
377 |
| - it { should be_instance_of Rack::OAuth2::AccessToken::Bearer } |
378 |
| - its(:token_type) { should == :bearer } |
379 |
| - end |
380 |
| - end |
381 |
| - |
382 |
| - context 'when no-type token is given (key-value)' do |
383 |
| - before do |
384 |
| - mock_response( |
385 |
| - :post, |
386 |
| - 'https://server.example.com/oauth2/token', |
387 |
| - 'tokens/legacy.txt' |
388 |
| - ) |
389 |
| - end |
390 |
| - it { should be_instance_of Rack::OAuth2::AccessToken::Legacy } |
391 |
| - its(:token_type) { should == :legacy } |
392 |
| - its(:access_token) { should == 'access_token' } |
393 |
| - its(:expires_in) { should == 3600 } |
394 |
| - |
395 |
| - context 'when expires_in is not given' do |
396 |
| - before do |
397 |
| - mock_response( |
398 |
| - :post, |
399 |
| - 'https://server.example.com/oauth2/token', |
400 |
| - 'tokens/legacy_without_expires_in.txt' |
401 |
| - ) |
402 |
| - end |
403 |
| - its(:expires_in) { should be_nil } |
404 |
| - end |
405 |
| - end |
406 |
| - |
407 | 358 | context 'when unknown-type token is given' do
|
408 | 359 | before do
|
409 | 360 | client.authorization_code = 'code'
|
410 | 361 | mock_response(
|
411 | 362 | :post,
|
412 | 363 | 'https://server.example.com/oauth2/token',
|
413 |
| - 'tokens/unknown.json' |
| 364 | + 'tokens/unknown' |
414 | 365 | )
|
415 | 366 | end
|
416 | 367 | it do
|
|
423 | 374 | mock_response(
|
424 | 375 | :post,
|
425 | 376 | 'https://server.example.com/oauth2/token',
|
426 |
| - 'errors/invalid_request.json', |
| 377 | + 'errors/invalid_request', |
427 | 378 | status: 400
|
428 | 379 | )
|
429 | 380 | end
|
|
439 | 390 | :post,
|
440 | 391 | 'https://server.example.com/oauth2/token',
|
441 | 392 | 'blank',
|
| 393 | + format: 'txt', |
442 | 394 | status: 400
|
443 | 395 | )
|
444 | 396 | end
|
|
456 | 408 | :post,
|
457 | 409 | 'https://server.example.com/oauth2/revoke',
|
458 | 410 | 'blank',
|
| 411 | + format: 'txt', |
459 | 412 | status: 200,
|
460 | 413 | body: {
|
461 | 414 | token: 'access_token',
|
|
478 | 431 | :post,
|
479 | 432 | 'https://server.example.com/oauth2/revoke',
|
480 | 433 | 'blank',
|
| 434 | + format: 'txt', |
481 | 435 | status: 200,
|
482 | 436 | body: {
|
483 | 437 | token: 'access_token',
|
|
496 | 450 | :post,
|
497 | 451 | 'https://server.example.com/oauth2/revoke',
|
498 | 452 | 'blank',
|
| 453 | + format: 'txt', |
499 | 454 | status: 200,
|
500 | 455 | body: {
|
501 | 456 | token: 'refresh_token',
|
|
523 | 478 | mock_response(
|
524 | 479 | :post,
|
525 | 480 | 'https://server.example.com/oauth2/revoke',
|
526 |
| - 'errors/invalid_request.json', |
| 481 | + 'errors/invalid_request', |
527 | 482 | status: 400
|
528 | 483 | )
|
529 | 484 | end
|
|
0 commit comments