scimitar 2.5.0 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,13 +26,17 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
26
26
 
27
27
  context '#index' do
28
28
  context 'with no items' do
29
- it 'returns empty list' do
29
+ before :each do
30
30
  MockUser.delete_all
31
+ end
31
32
 
33
+ it 'returns empty list' do
32
34
  expect_any_instance_of(MockUsersController).to receive(:index).once.and_call_original
33
35
  get '/Users', params: { format: :scim }
34
36
 
35
- expect(response.status).to eql(200)
37
+ expect(response.status ).to eql(200)
38
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
39
+
36
40
  result = JSON.parse(response.body)
37
41
 
38
42
  expect(result['totalResults']).to eql(0)
@@ -46,7 +50,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
46
50
  it 'returns all items' do
47
51
  get '/Users', params: { format: :scim }
48
52
 
49
- expect(response.status).to eql(200)
53
+ expect(response.status ).to eql(200)
54
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
55
+
50
56
  result = JSON.parse(response.body)
51
57
 
52
58
  expect(result['totalResults']).to eql(3)
@@ -64,7 +70,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
64
70
  it 'returns all items' do
65
71
  get '/Groups', params: { format: :scim }
66
72
 
67
- expect(response.status).to eql(200)
73
+ expect(response.status ).to eql(200)
74
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
75
+
68
76
  result = JSON.parse(response.body)
69
77
 
70
78
  expect(result['totalResults']).to eql(3)
@@ -84,7 +92,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
84
92
  filter: 'name.givenName eq "FOO" and name.familyName pr and emails ne "home_1@test.com"'
85
93
  }
86
94
 
87
- expect(response.status).to eql(200)
95
+ expect(response.status ).to eql(200)
96
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
97
+
88
98
  result = JSON.parse(response.body)
89
99
 
90
100
  expect(result['totalResults']).to eql(1)
@@ -103,7 +113,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
103
113
  filter: 'name.GIVENNAME eq "Foo" and name.Familyname pr and emails ne "home_1@test.com"'
104
114
  }
105
115
 
106
- expect(response.status).to eql(200)
116
+ expect(response.status ).to eql(200)
117
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
118
+
107
119
  result = JSON.parse(response.body)
108
120
 
109
121
  expect(result['totalResults']).to eql(1)
@@ -126,7 +138,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
126
138
  filter: "id eq \"#{@u3.primary_key}\""
127
139
  }
128
140
 
129
- expect(response.status).to eql(200)
141
+ expect(response.status ).to eql(200)
142
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
143
+
130
144
  result = JSON.parse(response.body)
131
145
 
132
146
  expect(result['totalResults']).to eql(1)
@@ -145,7 +159,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
145
159
  filter: "externalID eq \"#{@u2.scim_uid}\""
146
160
  }
147
161
 
148
- expect(response.status).to eql(200)
162
+ expect(response.status ).to eql(200)
163
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
164
+
149
165
  result = JSON.parse(response.body)
150
166
 
151
167
  expect(result['totalResults']).to eql(1)
@@ -164,7 +180,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
164
180
  filter: "Meta.LastModified eq \"#{@u3.updated_at}\""
165
181
  }
166
182
 
167
- expect(response.status).to eql(200)
183
+ expect(response.status ).to eql(200)
184
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
185
+
168
186
  result = JSON.parse(response.body)
169
187
 
170
188
  expect(result['totalResults']).to eql(1)
@@ -184,7 +202,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
184
202
  count: 2
185
203
  }
186
204
 
187
- expect(response.status).to eql(200)
205
+ expect(response.status ).to eql(200)
206
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
207
+
188
208
  result = JSON.parse(response.body)
189
209
 
190
210
  expect(result['totalResults']).to eql(3)
@@ -203,7 +223,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
203
223
  startIndex: 2
204
224
  }
205
225
 
206
- expect(response.status).to eql(200)
226
+ expect(response.status ).to eql(200)
227
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
228
+
207
229
  result = JSON.parse(response.body)
208
230
 
209
231
  expect(result['totalResults']).to eql(3)
@@ -224,8 +246,11 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
224
246
  filter: 'name.givenName'
225
247
  }
226
248
 
227
- expect(response.status).to eql(400)
249
+ expect(response.status ).to eql(400)
250
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
251
+
228
252
  result = JSON.parse(response.body)
253
+
229
254
  expect(result['scimType']).to eql('invalidFilter')
230
255
  end
231
256
  end # "context 'with bad calls' do"
@@ -239,7 +264,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
239
264
  expect_any_instance_of(MockUsersController).to receive(:show).once.and_call_original
240
265
  get "/Users/#{@u2.primary_key}", params: { format: :scim }
241
266
 
242
- expect(response.status).to eql(200)
267
+ expect(response.status ).to eql(200)
268
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
269
+
243
270
  result = JSON.parse(response.body)
244
271
 
245
272
  expect(result['id']).to eql(@u2.primary_key.to_s)
@@ -254,7 +281,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
254
281
  expect_any_instance_of(MockGroupsController).to receive(:show).once.and_call_original
255
282
  get "/Groups/#{@g2.id}", params: { format: :scim }
256
283
 
257
- expect(response.status).to eql(200)
284
+ expect(response.status ).to eql(200)
285
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
286
+
258
287
  result = JSON.parse(response.body)
259
288
 
260
289
  expect(result['id']).to eql(@g2.id.to_s) # Note - ID was converted String; not Integer
@@ -266,8 +295,11 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
266
295
  it 'renders 404' do
267
296
  get '/Users/xyz', params: { format: :scim }
268
297
 
269
- expect(response.status).to eql(404)
298
+ expect(response.status ).to eql(404)
299
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
300
+
270
301
  result = JSON.parse(response.body)
302
+
271
303
  expect(result['status']).to eql('404')
272
304
  end
273
305
  end # "context '#show' do"
@@ -291,7 +323,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
291
323
  mock_after = MockUser.all.to_a
292
324
  new_mock = (mock_after - mock_before).first
293
325
 
294
- expect(response.status).to eql(201)
326
+ expect(response.status ).to eql(201)
327
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
328
+
295
329
  result = JSON.parse(response.body)
296
330
 
297
331
  expect(result['id']).to eql(new_mock.primary_key.to_s)
@@ -332,7 +366,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
332
366
  mock_after = MockUser.all.to_a
333
367
  new_mock = (mock_after - mock_before).first
334
368
 
335
- expect(response.status).to eql(201)
369
+ expect(response.status ).to eql(201)
370
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
371
+
336
372
  result = JSON.parse(response.body)
337
373
 
338
374
  expect(result['id']).to eql(new_mock.id.to_s)
@@ -363,8 +399,11 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
363
399
  }
364
400
  }.to_not change { MockUser.count }
365
401
 
366
- expect(response.status).to eql(409)
402
+ expect(response.status ).to eql(409)
403
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
404
+
367
405
  result = JSON.parse(response.body)
406
+
368
407
  expect(result['scimType']).to eql('uniqueness')
369
408
  expect(result['detail']).to include('already been taken')
370
409
  end
@@ -377,8 +416,11 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
377
416
  }
378
417
  }.to_not change { MockUser.count }
379
418
 
380
- expect(response.status).to eql(400)
419
+ expect(response.status ).to eql(400)
420
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
421
+
381
422
  result = JSON.parse(response.body)
423
+
382
424
  expect(result['scimType']).to eql('invalidValue')
383
425
  expect(result['detail']).to include('is required')
384
426
  end
@@ -391,12 +433,32 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
391
433
  }
392
434
  }.to_not change { MockUser.count }
393
435
 
394
- expect(response.status).to eql(400)
436
+ expect(response.status ).to eql(400)
437
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
438
+
395
439
  result = JSON.parse(response.body)
396
440
 
397
441
  expect(result['scimType']).to eql('invalidValue')
398
442
  expect(result['detail']).to include('is reserved')
399
443
  end
444
+
445
+ it 'invokes a block if given one' do
446
+ mock_before = MockUser.all.to_a
447
+ attributes = { userName: '5' } # Minimum required by schema
448
+
449
+ expect_any_instance_of(CustomSaveMockUsersController).to receive(:create).once.and_call_original
450
+ expect {
451
+ post "/CustomSaveUsers", params: attributes.merge(format: :scim)
452
+ }.to change { MockUser.count }.by(1)
453
+
454
+ mock_after = MockUser.all.to_a
455
+ new_mock = (mock_after - mock_before).first
456
+
457
+ expect(response.status ).to eql(201)
458
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
459
+
460
+ expect(new_mock.username).to eql(CustomSaveMockUsersController::CUSTOM_SAVE_BLOCK_USERNAME_INDICATOR)
461
+ end
400
462
  end # "context '#create' do"
401
463
 
402
464
  # ===========================================================================
@@ -412,7 +474,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
412
474
  put "/Users/#{@u2.primary_key}", params: attributes.merge(format: :scim)
413
475
  }.to_not change { MockUser.count }
414
476
 
415
- expect(response.status).to eql(200)
477
+ expect(response.status ).to eql(200)
478
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
479
+
416
480
  result = JSON.parse(response.body)
417
481
 
418
482
  expect(result['id']).to eql(@u2.primary_key.to_s)
@@ -443,8 +507,11 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
443
507
  }
444
508
  }.to_not change { MockUser.count }
445
509
 
446
- expect(response.status).to eql(400)
510
+ expect(response.status ).to eql(400)
511
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
512
+
447
513
  result = JSON.parse(response.body)
514
+
448
515
  expect(result['scimType']).to eql('invalidValue')
449
516
  expect(result['detail']).to include('is required')
450
517
 
@@ -464,7 +531,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
464
531
  }
465
532
  }.to_not change { MockUser.count }
466
533
 
467
- expect(response.status).to eql(400)
534
+ expect(response.status ).to eql(400)
535
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
536
+
468
537
  result = JSON.parse(response.body)
469
538
 
470
539
  expect(result['scimType']).to eql('invalidValue')
@@ -486,8 +555,11 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
486
555
  }
487
556
  }.to_not change { MockUser.count }
488
557
 
489
- expect(response.status).to eql(404)
558
+ expect(response.status ).to eql(404)
559
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
560
+
490
561
  result = JSON.parse(response.body)
562
+
491
563
  expect(result['status']).to eql('404')
492
564
  end
493
565
  end # "context '#replace' do"
@@ -519,7 +591,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
519
591
  patch "/Users/#{@u2.primary_key}", params: payload.merge(format: :scim)
520
592
  }.to_not change { MockUser.count }
521
593
 
522
- expect(response.status).to eql(200)
594
+ expect(response.status ).to eql(200)
595
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
596
+
523
597
  result = JSON.parse(response.body)
524
598
 
525
599
  expect(result['id']).to eql(@u2.primary_key.to_s)
@@ -556,7 +630,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
556
630
  patch "/Users/#{@u2.primary_key}", params: payload.merge(format: :scim)
557
631
  }.to_not change { MockUser.count }
558
632
 
559
- expect(response.status).to eql(200)
633
+ expect(response.status ).to eql(200)
634
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
635
+
560
636
  result = JSON.parse(response.body)
561
637
 
562
638
  expect(result['id']).to eql(@u2.primary_key.to_s)
@@ -588,7 +664,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
588
664
  patch "/Users/#{@u2.primary_key}", params: payload.merge(format: :scim)
589
665
  }.to_not change { MockUser.count }
590
666
 
591
- expect(response.status).to eql(200)
667
+ expect(response.status ).to eql(200)
668
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
669
+
592
670
  result = JSON.parse(response.body)
593
671
 
594
672
  expect(result['id']).to eql(@u2.primary_key.to_s)
@@ -620,7 +698,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
620
698
  patch "/Users/#{@u2.primary_key}", params: payload.merge(format: :scim)
621
699
  }.to_not change { MockUser.count }
622
700
 
623
- expect(response.status).to eql(200)
701
+ expect(response.status ).to eql(200)
702
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
703
+
624
704
  result = JSON.parse(response.body)
625
705
 
626
706
  expect(result['id']).to eql(@u2.primary_key.to_s)
@@ -659,7 +739,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
659
739
  }
660
740
  }.to_not change { MockUser.count }
661
741
 
662
- expect(response.status).to eql(400)
742
+ expect(response.status ).to eql(400)
743
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
744
+
663
745
  result = JSON.parse(response.body)
664
746
 
665
747
  expect(result['scimType']).to eql('invalidValue')
@@ -687,8 +769,11 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
687
769
  }
688
770
  }.to_not change { MockUser.count }
689
771
 
690
- expect(response.status).to eql(404)
772
+ expect(response.status ).to eql(404)
773
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
774
+
691
775
  result = JSON.parse(response.body)
776
+
692
777
  expect(result['status']).to eql('404')
693
778
  end
694
779
 
@@ -725,7 +810,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
725
810
 
726
811
  get "/Groups/#{@g1.id}", params: { format: :scim }
727
812
 
728
- expect(response.status).to eql(200)
813
+ expect(response.status ).to eql(200)
814
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
815
+
729
816
  result = JSON.parse(response.body)
730
817
 
731
818
  expect(result['members']).to be_empty
@@ -752,7 +839,9 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
752
839
 
753
840
  get "/Groups/#{@g1.id}", params: { format: :scim }
754
841
 
755
- expect(response.status).to eql(200)
842
+ expect(response.status ).to eql(200)
843
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
844
+
756
845
  result = JSON.parse(response.body)
757
846
 
758
847
  expect(result['members'].map { |m| m['value'] }.sort()).to eql(expected_remaining_user_ids)
@@ -863,8 +952,11 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
863
952
  delete '/Users/xyz', params: { format: :scim }
864
953
  }.to_not change { MockUser.count }
865
954
 
866
- expect(response.status).to eql(404)
955
+ expect(response.status ).to eql(404)
956
+ expect(response.headers['Content-Type']).to eql('application/scim+json; charset=utf-8')
957
+
867
958
  result = JSON.parse(response.body)
959
+
868
960
  expect(result['status']).to eql('404')
869
961
  end
870
962
  end # "context '#destroy' do"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scimitar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - RIPA Global
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-09-25 00:00:00.000000000 Z
12
+ date: 2023-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -130,6 +130,8 @@ executables: []
130
130
  extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
+ - LICENSE.txt
134
+ - README.md
133
135
  - Rakefile
134
136
  - app/controllers/scimitar/active_record_backed_resources_controller.rb
135
137
  - app/controllers/scimitar/application_controller.rb
@@ -196,6 +198,7 @@ files:
196
198
  - lib/scimitar/version.rb
197
199
  - spec/apps/dummy/app/controllers/custom_destroy_mock_users_controller.rb
198
200
  - spec/apps/dummy/app/controllers/custom_request_verifiers_controller.rb
201
+ - spec/apps/dummy/app/controllers/custom_save_mock_users_controller.rb
199
202
  - spec/apps/dummy/app/controllers/mock_groups_controller.rb
200
203
  - spec/apps/dummy/app/controllers/mock_users_controller.rb
201
204
  - spec/apps/dummy/app/models/mock_group.rb
@@ -260,13 +263,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
263
  - !ruby/object:Gem::Version
261
264
  version: '0'
262
265
  requirements: []
263
- rubygems_version: 3.4.4
266
+ rubygems_version: 3.4.10
264
267
  signing_key:
265
268
  specification_version: 4
266
269
  summary: SCIM v2 for Rails
267
270
  test_files:
268
271
  - spec/apps/dummy/app/controllers/custom_destroy_mock_users_controller.rb
269
272
  - spec/apps/dummy/app/controllers/custom_request_verifiers_controller.rb
273
+ - spec/apps/dummy/app/controllers/custom_save_mock_users_controller.rb
270
274
  - spec/apps/dummy/app/controllers/mock_groups_controller.rb
271
275
  - spec/apps/dummy/app/controllers/mock_users_controller.rb
272
276
  - spec/apps/dummy/app/models/mock_group.rb