Commit 5cb2c8b6b0d4f3e87b664b5cb2980fa3490b4e6d
1 parent
6f55bd04
Exists in
master
• add content type to error responses
• add spec coverage for content type
Showing
2 changed files
with
85 additions
and
1 deletions
Show diff stats
app/controllers/concerns/scim_rails/response.rb
spec/controllers/scim_rails/scim_users_controller_spec.rb
... | ... | @@ -9,6 +9,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do |
9 | 9 | let(:company) { create(:company) } |
10 | 10 | |
11 | 11 | context "when unauthorized" do |
12 | + it "returns scim+json content type" do | |
13 | + get :index | |
14 | + | |
15 | + expect(response.content_type).to eq "application/scim+json, application/json" | |
16 | + end | |
17 | + | |
12 | 18 | it "fails with no credentials" do |
13 | 19 | get :index |
14 | 20 | |
... | ... | @@ -29,6 +35,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do |
29 | 35 | http_login(company) |
30 | 36 | end |
31 | 37 | |
38 | + it "returns scim+json content type" do | |
39 | + get :index | |
40 | + | |
41 | + expect(response.content_type).to eq "application/scim+json, application/json" | |
42 | + end | |
43 | + | |
32 | 44 | it "is successful with valid credentials" do |
33 | 45 | get :index |
34 | 46 | |
... | ... | @@ -134,6 +146,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do |
134 | 146 | let(:company) { create(:company) } |
135 | 147 | |
136 | 148 | context "when unauthorized" do |
149 | + it "returns scim+json content type" do | |
150 | + get :show, params: { id: 1 } | |
151 | + | |
152 | + expect(response.content_type).to eq "application/scim+json, application/json" | |
153 | + end | |
154 | + | |
137 | 155 | it "fails with no credentials" do |
138 | 156 | get :show, params: { id: 1 } |
139 | 157 | |
... | ... | @@ -154,6 +172,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do |
154 | 172 | http_login(company) |
155 | 173 | end |
156 | 174 | |
175 | + it "returns scim+json content type" do | |
176 | + get :show, params: { id: 1 } | |
177 | + | |
178 | + expect(response.content_type).to eq "application/scim+json, application/json" | |
179 | + end | |
180 | + | |
157 | 181 | it "is successful with valid credentials" do |
158 | 182 | create(:user, id: 1, company: company) |
159 | 183 | get :show, params: { id: 1 } |
... | ... | @@ -183,6 +207,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do |
183 | 207 | let(:company) { create(:company) } |
184 | 208 | |
185 | 209 | context "when unauthorized" do |
210 | + it "returns scim+json content type" do | |
211 | + post :create | |
212 | + | |
213 | + expect(response.content_type).to eq "application/scim+json, application/json" | |
214 | + end | |
215 | + | |
186 | 216 | it "fails with no credentials" do |
187 | 217 | post :create |
188 | 218 | |
... | ... | @@ -203,6 +233,22 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do |
203 | 233 | http_login(company) |
204 | 234 | end |
205 | 235 | |
236 | + it "returns scim+json content type" do | |
237 | + post :create, params: { | |
238 | + name: { | |
239 | + givenName: "New", | |
240 | + familyName: "User" | |
241 | + }, | |
242 | + emails: [ | |
243 | + { | |
244 | + value: "new@example.com" | |
245 | + } | |
246 | + ] | |
247 | + } | |
248 | + | |
249 | + expect(response.content_type).to eq "application/scim+json, application/json" | |
250 | + end | |
251 | + | |
206 | 252 | it "is successful with valid credentials" do |
207 | 253 | post :create, params: { |
208 | 254 | name: { |
... | ... | @@ -307,6 +353,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do |
307 | 353 | let(:company) { create(:company) } |
308 | 354 | |
309 | 355 | context "when unauthorized" do |
356 | + it "returns scim+json content type" do | |
357 | + put :put_update, params: { id: 1 } | |
358 | + | |
359 | + expect(response.content_type).to eq "application/scim+json, application/json" | |
360 | + end | |
361 | + | |
310 | 362 | it "fails with no credentials" do |
311 | 363 | put :put_update, params: { id: 1 } |
312 | 364 | |
... | ... | @@ -329,6 +381,25 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do |
329 | 381 | http_login(company) |
330 | 382 | end |
331 | 383 | |
384 | + it "returns scim+json content type" do | |
385 | + put :put_update, params: { | |
386 | + id: 1, | |
387 | + userName: "test@example.com", | |
388 | + name: { | |
389 | + givenName: "Test", | |
390 | + familyName: "User" | |
391 | + }, | |
392 | + emails: [ | |
393 | + { | |
394 | + value: "test@example.com" | |
395 | + }, | |
396 | + ], | |
397 | + active: "true" | |
398 | + } | |
399 | + | |
400 | + expect(response.content_type).to eq "application/scim+json, application/json" | |
401 | + end | |
402 | + | |
332 | 403 | it "is successful with with valid credentials" do |
333 | 404 | put :put_update, params: { |
334 | 405 | id: 1, |
... | ... | @@ -385,6 +456,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do |
385 | 456 | let(:company) { create(:company) } |
386 | 457 | |
387 | 458 | context "when unauthorized" do |
459 | + it "returns scim+json content type" do | |
460 | + patch :patch_update, params: { id: 1 } | |
461 | + | |
462 | + expect(response.content_type).to eq "application/scim+json, application/json" | |
463 | + end | |
464 | + | |
388 | 465 | it "fails with no credentials" do |
389 | 466 | patch :patch_update, params: { id: 1 } |
390 | 467 | |
... | ... | @@ -407,6 +484,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do |
407 | 484 | http_login(company) |
408 | 485 | end |
409 | 486 | |
487 | + it "returns scim+json content type" do | |
488 | + patch :patch_update, params: { id: 1 } | |
489 | + | |
490 | + expect(response.content_type).to eq "application/scim+json, application/json" | |
491 | + end | |
492 | + | |
410 | 493 | it "is successful with valid credentials" do |
411 | 494 | patch :patch_update, params: { id: 1 } |
412 | 495 | ... | ... |