@@ -25,6 +25,8 @@ def query_params
25
25
scopes : "default"
26
26
end
27
27
28
+ let ( :response_json_body ) { JSON . parse ( response . body ) }
29
+
28
30
before do
29
31
Doorkeeper . configure do
30
32
orm DOORKEEPER_ORM
@@ -111,7 +113,6 @@ def query_params
111
113
post :create , params : { client_id : client . uid , response_type : "token" , redirect_uri : client . redirect_uri }
112
114
end
113
115
114
- let ( :response_json_body ) { JSON . parse ( response . body ) }
115
116
let ( :redirect_uri ) { response_json_body [ "redirect_uri" ] }
116
117
117
118
it "renders success after authorization" do
@@ -154,8 +155,6 @@ def query_params
154
155
}
155
156
end
156
157
157
- let ( :response_json_body ) { JSON . parse ( response . body ) }
158
-
159
158
it "renders success after authorization" do
160
159
expect ( response ) . to be_successful
161
160
end
@@ -200,8 +199,6 @@ def query_params
200
199
}
201
200
end
202
201
203
- let ( :response_json_body ) { JSON . parse ( response . body ) }
204
-
205
202
it "renders 400 error" do
206
203
expect ( response . status ) . to eq 400
207
204
end
@@ -231,8 +228,6 @@ def query_params
231
228
}
232
229
end
233
230
234
- let ( :response_json_body ) { JSON . parse ( response . body ) }
235
-
236
231
it "renders 401 error" do
237
232
expect ( response . status ) . to eq 401
238
233
end
@@ -262,8 +257,6 @@ def query_params
262
257
}
263
258
end
264
259
265
- let ( :response_json_body ) { JSON . parse ( response . body ) }
266
-
267
260
it "renders 401 error" do
268
261
expect ( response . status ) . to eq 401
269
262
end
@@ -355,8 +348,6 @@ def query_params
355
348
}
356
349
end
357
350
358
- let ( :response_json_body ) { JSON . parse ( response . body ) }
359
-
360
351
it "renders 400 error" do
361
352
expect ( response . status ) . to eq 400
362
353
end
@@ -386,8 +377,6 @@ def query_params
386
377
}
387
378
end
388
379
389
- let ( :response_json_body ) { JSON . parse ( response . body ) }
390
-
391
380
it "renders 401 error" do
392
381
expect ( response . status ) . to eq 401
393
382
end
@@ -418,8 +407,6 @@ def query_params
418
407
}
419
408
end
420
409
421
- let ( :response_json_body ) { JSON . parse ( response . body ) }
422
-
423
410
it "renders 401 error" do
424
411
expect ( response . status ) . to eq 401
425
412
end
@@ -451,7 +438,6 @@ def query_params
451
438
}
452
439
end
453
440
454
- let ( :response_json_body ) { JSON . parse ( response . body ) }
455
441
let ( :redirect_uri ) { response_json_body [ "redirect_uri" ] }
456
442
457
443
it "renders 400 error" do
@@ -492,8 +478,6 @@ def query_params
492
478
}
493
479
end
494
480
495
- let ( :response_json_body ) { JSON . parse ( response . body ) }
496
-
497
481
it "renders 400 error" do
498
482
expect ( response . status ) . to eq 400
499
483
end
@@ -838,8 +822,6 @@ def query_params
838
822
}
839
823
end
840
824
841
- let ( :response_json_body ) { JSON . parse ( response . body ) }
842
-
843
825
it "renders success" do
844
826
expect ( response ) . to be_successful
845
827
end
@@ -928,8 +910,6 @@ def query_params
928
910
get :new , params : { an_invalid : "request" }
929
911
end
930
912
931
- let ( :response_json_body ) { JSON . parse ( response . body ) }
932
-
933
913
it "renders bad request" do
934
914
expect ( response ) . to have_http_status ( :bad_request )
935
915
end
@@ -960,8 +940,6 @@ def query_params
960
940
}
961
941
end
962
942
963
- let ( :response_json_body ) { JSON . parse ( response . body ) }
964
-
965
943
it "renders bad request" do
966
944
expect ( response ) . to have_http_status ( :bad_request )
967
945
end
@@ -992,8 +970,6 @@ def query_params
992
970
}
993
971
end
994
972
995
- let ( :response_json_body ) { JSON . parse ( response . body ) }
996
-
997
973
it "renders 400 error" do
998
974
expect ( response . status ) . to eq 400
999
975
end
@@ -1106,4 +1082,26 @@ def query_params
1106
1082
expect ( response ) . to be_successful
1107
1083
end
1108
1084
end
1085
+
1086
+ describe "DELETE #destroy in API mode" do
1087
+ context "with invalid params" do
1088
+ before do
1089
+ allow ( Doorkeeper . config ) . to receive ( :api_only ) . and_return ( true )
1090
+ delete :destroy , params : {
1091
+ client_id : client . uid ,
1092
+ response_type : "blabla" ,
1093
+ redirect_uri : client . redirect_uri ,
1094
+ response_mode : "form_post" ,
1095
+ }
1096
+ end
1097
+
1098
+ it "renders bad request" do
1099
+ expect ( response ) . to have_http_status ( :bad_request )
1100
+ end
1101
+
1102
+ it "includes error in body" do
1103
+ expect ( response_json_body [ "error" ] ) . to eq ( "unsupported_grant_type" )
1104
+ end
1105
+ end
1106
+ end
1109
1107
end
0 commit comments