scimitar 1.11.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/scimitar/active_record_backed_resources_controller.rb +23 -98
  3. data/app/controllers/scimitar/application_controller.rb +17 -44
  4. data/app/controllers/scimitar/resource_types_controller.rb +3 -7
  5. data/app/controllers/scimitar/resources_controller.rb +2 -0
  6. data/app/controllers/scimitar/schemas_controller.rb +3 -366
  7. data/app/controllers/scimitar/service_provider_configurations_controller.rb +1 -0
  8. data/app/models/scimitar/complex_types/address.rb +6 -0
  9. data/app/models/scimitar/engine_configuration.rb +5 -15
  10. data/app/models/scimitar/error_response.rb +0 -12
  11. data/app/models/scimitar/lists/query_parser.rb +13 -113
  12. data/app/models/scimitar/resource_invalid_error.rb +1 -1
  13. data/app/models/scimitar/resources/base.rb +9 -53
  14. data/app/models/scimitar/resources/mixin.rb +59 -646
  15. data/app/models/scimitar/schema/address.rb +0 -1
  16. data/app/models/scimitar/schema/attribute.rb +5 -14
  17. data/app/models/scimitar/schema/base.rb +1 -1
  18. data/app/models/scimitar/schema/name.rb +2 -2
  19. data/app/models/scimitar/schema/user.rb +10 -10
  20. data/app/models/scimitar/schema/vdtp.rb +1 -1
  21. data/app/models/scimitar/service_provider_configuration.rb +3 -14
  22. data/config/initializers/scimitar.rb +3 -69
  23. data/lib/scimitar/engine.rb +12 -57
  24. data/lib/scimitar/support/hash_with_indifferent_case_insensitive_access.rb +10 -140
  25. data/lib/scimitar/version.rb +2 -2
  26. data/lib/scimitar.rb +2 -7
  27. data/spec/apps/dummy/app/controllers/mock_groups_controller.rb +1 -1
  28. data/spec/apps/dummy/app/models/mock_group.rb +1 -1
  29. data/spec/apps/dummy/app/models/mock_user.rb +9 -52
  30. data/spec/apps/dummy/config/application.rb +1 -0
  31. data/spec/apps/dummy/config/environments/test.rb +28 -5
  32. data/spec/apps/dummy/config/initializers/scimitar.rb +10 -90
  33. data/spec/apps/dummy/config/routes.rb +7 -28
  34. data/spec/apps/dummy/db/migrate/20210304014602_create_mock_users.rb +1 -11
  35. data/spec/apps/dummy/db/migrate/20210308044214_create_join_table_mock_groups_mock_users.rb +3 -8
  36. data/spec/apps/dummy/db/schema.rb +4 -12
  37. data/spec/controllers/scimitar/application_controller_spec.rb +3 -126
  38. data/spec/controllers/scimitar/resource_types_controller_spec.rb +4 -8
  39. data/spec/controllers/scimitar/schemas_controller_spec.rb +48 -344
  40. data/spec/models/scimitar/complex_types/address_spec.rb +4 -3
  41. data/spec/models/scimitar/complex_types/email_spec.rb +2 -0
  42. data/spec/models/scimitar/lists/query_parser_spec.rb +9 -146
  43. data/spec/models/scimitar/resources/base_spec.rb +71 -217
  44. data/spec/models/scimitar/resources/base_validation_spec.rb +5 -43
  45. data/spec/models/scimitar/resources/mixin_spec.rb +129 -1508
  46. data/spec/models/scimitar/schema/attribute_spec.rb +3 -22
  47. data/spec/models/scimitar/schema/base_spec.rb +1 -1
  48. data/spec/models/scimitar/schema/user_spec.rb +2 -12
  49. data/spec/requests/active_record_backed_resources_controller_spec.rb +66 -1016
  50. data/spec/requests/application_controller_spec.rb +3 -16
  51. data/spec/requests/engine_spec.rb +0 -75
  52. data/spec/spec_helper.rb +1 -9
  53. data/spec/support/hash_with_indifferent_case_insensitive_access_spec.rb +0 -108
  54. metadata +26 -37
  55. data/LICENSE.txt +0 -21
  56. data/README.md +0 -717
  57. data/lib/scimitar/support/utilities.rb +0 -111
  58. data/spec/apps/dummy/app/controllers/custom_create_mock_users_controller.rb +0 -25
  59. data/spec/apps/dummy/app/controllers/custom_replace_mock_users_controller.rb +0 -25
  60. data/spec/apps/dummy/app/controllers/custom_save_mock_users_controller.rb +0 -24
  61. data/spec/apps/dummy/app/controllers/custom_update_mock_users_controller.rb +0 -25
@@ -1,25 +1,18 @@
1
1
  class MockUser < ActiveRecord::Base
2
2
 
3
- self.primary_key = :primary_key
4
-
5
3
  # ===========================================================================
6
4
  # TEST ATTRIBUTES - see db/migrate/20210304014602_create_mock_users.rb etc.
7
5
  # ===========================================================================
8
6
 
9
7
  READWRITE_ATTRS = %w{
10
- primary_key
8
+ id
11
9
  scim_uid
12
10
  username
13
- password
14
11
  first_name
15
12
  last_name
16
13
  work_email_address
17
14
  home_email_address
18
15
  work_phone_number
19
- organization
20
- department
21
- manager
22
- mock_groups
23
16
  }
24
17
 
25
18
  has_and_belongs_to_many :mock_groups
@@ -45,11 +38,9 @@ class MockUser < ActiveRecord::Base
45
38
 
46
39
  def self.scim_attributes_map
47
40
  return {
48
- id: :primary_key,
41
+ id: :id,
49
42
  externalId: :scim_uid,
50
43
  userName: :username,
51
- password: :password,
52
- active: :is_active,
53
44
  name: {
54
45
  givenName: :first_name,
55
46
  familyName: :last_name
@@ -82,11 +73,8 @@ class MockUser < ActiveRecord::Base
82
73
  }
83
74
  },
84
75
  ],
85
- groups: [
76
+ groups: [ # NB read-only, so no :find_with key
86
77
  {
87
- # Read-only, so no :find_with key. There's no 'class' specified here
88
- # either, to help test the "/Schemas" endpoint's reflection code.
89
- #
90
78
  list: :mock_groups,
91
79
  using: {
92
80
  value: :id,
@@ -94,26 +82,7 @@ class MockUser < ActiveRecord::Base
94
82
  }
95
83
  }
96
84
  ],
97
-
98
- # Custom extension schema - see configuration in
99
- # "spec/apps/dummy/config/initializers/scimitar.rb".
100
- #
101
- organization: :organization,
102
- department: :department,
103
- primaryEmail: :scim_primary_email,
104
-
105
- manager: :manager,
106
-
107
- userGroups: [
108
- {
109
- list: :mock_groups,
110
- find_with: ->(value) { MockGroup.find(value["value"]) },
111
- using: {
112
- value: :id,
113
- display: :display_name
114
- }
115
- }
116
- ]
85
+ active: :is_active
117
86
  }
118
87
  end
119
88
 
@@ -123,25 +92,13 @@ class MockUser < ActiveRecord::Base
123
92
 
124
93
  def self.scim_queryable_attributes
125
94
  return {
126
- 'id' => { column: :primary_key },
127
- 'externalId' => { column: :scim_uid },
128
- 'meta.lastModified' => { column: :updated_at },
129
- 'name.givenName' => { column: :first_name },
130
- 'name.familyName' => { column: :last_name },
131
- 'groups' => { column: MockGroup.arel_table[:id] },
132
- 'groups.value' => { column: MockGroup.arel_table[:id] },
133
- 'emails' => { columns: [ :work_email_address, :home_email_address ] },
134
- 'emails.value' => { columns: [ :work_email_address, :home_email_address ] },
135
- 'emails.type' => { ignore: true }, # We can't filter on that; it'll just search all e-mails
136
- 'primaryEmail' => { column: :scim_primary_email },
95
+ 'name.givenName' => { column: :first_name },
96
+ 'name.familyName' => { column: :last_name },
97
+ 'emails' => { columns: [ :work_email_address, :home_email_address ] },
98
+ 'emails.value' => { columns: [ :work_email_address, :home_email_address ] },
99
+ 'emails.type' => { ignore: true } # We can't filter on that; it'll just search all e-mails
137
100
  }
138
101
  end
139
102
 
140
- # Custom attribute reader
141
- #
142
- def scim_primary_email
143
- work_email_address
144
- end
145
-
146
103
  include Scimitar::Resources::Mixin
147
104
  end
@@ -12,6 +12,7 @@ require 'scimitar'
12
12
 
13
13
  module Dummy
14
14
  class Application < Rails::Application
15
+ config.load_defaults 7.0
15
16
  end
16
17
  end
17
18
 
@@ -1,15 +1,38 @@
1
+ require 'active_support/core_ext/integer/time'
2
+
1
3
  Rails.application.configure do
2
4
  config.cache_classes = true
3
5
  config.eager_load = false
4
- config.serve_static_files = true
5
- config.static_cache_control = 'public, max-age=3600'
6
- config.consider_all_requests_local = true
7
6
 
8
- config.action_dispatch.show_exceptions = false
7
+ # Configure public file server for tests with Cache-Control for performance.
8
+ config.public_file_server.enabled = true
9
+ config.public_file_server.headers = {
10
+ 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
11
+ }
9
12
 
13
+ # Show full error reports and disable caching.
14
+ config.consider_all_requests_local = true
10
15
  config.action_controller.perform_caching = false
16
+ config.cache_store = :null_store
17
+
18
+ # Raise exceptions instead of rendering exception templates.
19
+ config.action_dispatch.show_exceptions = false
20
+
21
+ # Disable request forgery protection in test environment.
11
22
  config.action_controller.allow_forgery_protection = false
12
23
 
13
- config.active_support.test_order = :random
24
+ # Print deprecation notices to the stderr.
14
25
  config.active_support.deprecation = :stderr
26
+
27
+ # Raise exceptions for disallowed deprecations.
28
+ config.active_support.disallowed_deprecation = :raise
29
+
30
+ # Tell Active Support which deprecation messages to disallow.
31
+ config.active_support.disallowed_deprecation_warnings = []
32
+
33
+ # Raises error for missing translations.
34
+ config.i18n.raise_on_missing_translations = true
35
+
36
+ # Annotate rendered view with file names.
37
+ # config.action_view.annotate_rendered_view_with_filenames = true
15
38
  end
@@ -1,96 +1,16 @@
1
1
  # Test app configuration.
2
2
  #
3
- # Note that as a result of https://github.com/RIPAGlobal/scimitar/issues/48,
4
- # tests include a custom extension of the core User schema. A shortcoming of
5
- # some of the code from which Scimitar was originally built is that those
6
- # extensions are done with class-level ivars, so it is largely impossible (or
7
- # at least, impractical in tests) to avoid polluting the core class itself
8
- # with the extension.
9
- #
10
- # All related schema tests are written with this in mind.
11
- #
12
- # Further, https://github.com/RIPAGlobal/scimitar/pull/54 fixed warning
13
- # messages in a way that worked on Rails 6+ but, for V1 Scimitar, it would
14
- # break existing working setups that didn't use the +to_prepare+ wrapper. Their
15
- # application configuration would be written *first* but then *overwritten* by
16
- # the default +to_prepare+ block in Scimitar itself, since that runs later. The
17
- # file below does *not* use +to_prepare+ in order to test the workaround that
18
- # was produced; it should work on all Ruby versions as-is.
19
- #
20
- Scimitar.engine_configuration = Scimitar::EngineConfiguration.new({
21
-
22
- application_controller_mixin: Module.new do
23
- def self.included(base)
24
- base.class_eval do
25
- def test_hook; end
26
- before_action :test_hook
27
- end
28
- end
29
-
30
- def scim_schemas_url(options)
31
- super(test: 1, **options)
32
- end
33
-
34
- def scim_resource_type_url(options)
35
- super(test: 1, **options)
36
- end
37
- end
38
-
39
- })
40
-
41
- module ScimSchemaExtensions
42
- module User
43
-
44
- # This "looks like" part of the standard Enterprise extension.
45
- #
46
- class Enterprise < Scimitar::Schema::Base
47
- def initialize(options = {})
48
- super(
49
- name: 'EnterpriseExtendedUser',
50
- description: 'Enterprise extension for a User',
51
- id: self.class.id,
52
- scim_attributes: self.class.scim_attributes
53
- )
54
- end
55
-
56
- def self.id
57
- 'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User'
58
- end
59
-
60
- def self.scim_attributes
61
- [
62
- Scimitar::Schema::Attribute.new(name: 'organization', type: 'string'),
63
- Scimitar::Schema::Attribute.new(name: 'department', type: 'string'),
64
- Scimitar::Schema::Attribute.new(name: 'primaryEmail', type: 'string'),
65
- ]
3
+ Rails.application.config.to_prepare do
4
+ Scimitar.engine_configuration = Scimitar::EngineConfiguration.new({
5
+
6
+ application_controller_mixin: Module.new do
7
+ def self.included(base)
8
+ base.class_eval do
9
+ def test_hook; end
10
+ before_action :test_hook
11
+ end
66
12
  end
67
13
  end
68
14
 
69
- # In https://github.com/RIPAGlobal/scimitar/issues/122 we learn that with
70
- # more than one extension, things can go wrong - so now we test with two.
71
- #
72
- class Manager < Scimitar::Schema::Base
73
- def initialize(options = {})
74
- super(
75
- name: 'ManagementExtendedUser',
76
- description: 'Management extension for a User',
77
- id: self.class.id,
78
- scim_attributes: self.class.scim_attributes
79
- )
80
- end
81
-
82
- def self.id
83
- 'urn:ietf:params:scim:schemas:extension:manager:1.0:User'
84
- end
85
-
86
- def self.scim_attributes
87
- [
88
- Scimitar::Schema::Attribute.new(name: 'manager', type: 'string')
89
- ]
90
- end
91
- end
92
- end
15
+ })
93
16
  end
94
-
95
- Scimitar::Resources::User.extend_schema ScimSchemaExtensions::User::Enterprise
96
- Scimitar::Resources::User.extend_schema ScimSchemaExtensions::User::Manager
@@ -6,38 +6,17 @@
6
6
  Rails.application.routes.draw do
7
7
  mount Scimitar::Engine, at: '/'
8
8
 
9
- get 'Users', to: 'mock_users#index'
10
- get 'Users/:id', to: 'mock_users#show'
11
- post 'Users', to: 'mock_users#create'
12
- put 'Users/:id', to: 'mock_users#replace'
13
- patch 'Users/:id', to: 'mock_users#update'
14
- delete 'Users/:id', to: 'mock_users#destroy'
9
+ get 'Users', to: 'mock_users#index'
10
+ get 'Users/:id', to: 'mock_users#show'
11
+ post 'Users', to: 'mock_users#create'
12
+ put 'Users/:id', to: 'mock_users#replace'
13
+ patch 'Users/:id', to: 'mock_users#update'
14
+ delete 'Users/:id', to: 'mock_users#destroy'
15
15
 
16
- get 'Groups', to: 'mock_groups#index'
17
- get 'Groups/:id', to: 'mock_groups#show'
18
- patch 'Groups/:id', to: 'mock_groups#update'
19
-
20
- # For testing blocks passed to ActiveRecordBackedResourcesController#create,
21
- # #update, #replace and #destroy.
16
+ # For testing blocks passed to ActiveRecordBackedResourcesController#destroy
22
17
  #
23
- post 'CustomCreateUsers', to: 'custom_create_mock_users#create'
24
- patch 'CustomUpdateUsers/:id', to: 'custom_update_mock_users#update'
25
- put 'CustomReplaceUsers/:id', to: 'custom_replace_mock_users#replace'
26
18
  delete 'CustomDestroyUsers/:id', to: 'custom_destroy_mock_users#destroy'
27
19
 
28
- # Needed because the auto-render of most of the above includes a 'url_for'
29
- # call for a 'show' action, so we must include routes (implemented in the
30
- # base class) for the "show" endpoint.
31
- #
32
- get 'CustomCreateUsers/:id', to: 'custom_create_mock_users#show'
33
- get 'CustomUpdateUsers/:id', to: 'custom_update_mock_users#show'
34
- get 'CustomReplaceUsers/:id', to: 'custom_replace_mock_users#show'
35
-
36
- # For testing blocks passed to ActiveRecordBackedResourcesController#save!
37
- #
38
- post 'CustomSaveUsers', to: 'custom_save_mock_users#create'
39
- get 'CustomSaveUsers/:id', to: 'custom_save_mock_users#show'
40
-
41
20
  # For testing environment inside Scimitar::ApplicationController subclasses.
42
21
  #
43
22
  get 'CustomRequestVerifiers', to: 'custom_request_verifiers#index'
@@ -1,25 +1,15 @@
1
1
  class CreateMockUsers < ActiveRecord::Migration[6.1]
2
2
  def change
3
- create_table :mock_users, id: :uuid, primary_key: :primary_key do |t|
4
- t.timestamps
3
+ create_table :mock_users do |t|
5
4
 
6
- # Support part of the core schema
7
- #
8
5
  t.text :scim_uid
9
6
  t.text :username
10
- t.text :password
11
7
  t.text :first_name
12
8
  t.text :last_name
13
9
  t.text :work_email_address
14
10
  t.text :home_email_address
15
11
  t.text :work_phone_number
16
12
 
17
- # Support the custom extension schema - see configuration in
18
- # "spec/apps/dummy/config/initializers/scimitar.rb".
19
- #
20
- t.text :organization
21
- t.text :department
22
- t.text :manager
23
13
  end
24
14
  end
25
15
  end
@@ -1,13 +1,8 @@
1
1
  class CreateJoinTableMockGroupsMockUsers < ActiveRecord::Migration[6.1]
2
2
  def change
3
- create_table :mock_groups_users, id: false do | t |
4
- t.references :mock_group, foreign_key: true, type: :int8, index: true, null: false
5
- t.references :mock_user, type: :uuid, index: true, null: false, primary_key: :primary_key
6
-
7
- # The 'foreign_key:' option (used above) only works for 'id' column names
8
- # but the test data has a column named 'primary_key' for 'mock_users'.
9
- #
10
- t.foreign_key :mock_users, primary_key: :primary_key
3
+ create_join_table :mock_groups, :mock_users do |t|
4
+ t.index [:mock_group_id, :mock_user_id]
5
+ t.index [:mock_user_id, :mock_group_id]
11
6
  end
12
7
  end
13
8
  end
@@ -24,27 +24,19 @@ ActiveRecord::Schema.define(version: 2021_03_08_044214) do
24
24
 
25
25
  create_table "mock_groups_users", id: false, force: :cascade do |t|
26
26
  t.bigint "mock_group_id", null: false
27
- t.uuid "mock_user_id", null: false
28
- t.index ["mock_group_id"], name: "index_mock_groups_users_on_mock_group_id"
29
- t.index ["mock_user_id"], name: "index_mock_groups_users_on_mock_user_id"
27
+ t.bigint "mock_user_id", null: false
28
+ t.index ["mock_group_id", "mock_user_id"], name: "index_mock_groups_users_on_mock_group_id_and_mock_user_id"
29
+ t.index ["mock_user_id", "mock_group_id"], name: "index_mock_groups_users_on_mock_user_id_and_mock_group_id"
30
30
  end
31
31
 
32
- create_table "mock_users", primary_key: "primary_key", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
33
- t.datetime "created_at", null: false
34
- t.datetime "updated_at", null: false
32
+ create_table "mock_users", force: :cascade do |t|
35
33
  t.text "scim_uid"
36
34
  t.text "username"
37
- t.text "password"
38
35
  t.text "first_name"
39
36
  t.text "last_name"
40
37
  t.text "work_email_address"
41
38
  t.text "home_email_address"
42
39
  t.text "work_phone_number"
43
- t.text "organization"
44
- t.text "department"
45
- t.text "manager"
46
40
  end
47
41
 
48
- add_foreign_key "mock_groups_users", "mock_groups"
49
- add_foreign_key "mock_groups_users", "mock_users", primary_key: "primary_key"
50
42
  end
@@ -24,7 +24,7 @@ RSpec.describe Scimitar::ApplicationController do
24
24
  get :index, params: { format: :scim }
25
25
  expect(response).to be_ok
26
26
  expect(JSON.parse(response.body)).to eql({ 'message' => 'cool, cool!' })
27
- expect(response.headers['WWW-Authenticate']).to eql('Basic')
27
+ expect(response.headers['WWW_AUTHENTICATE']).to eql('Basic')
28
28
  end
29
29
 
30
30
  it 'renders failure with bad password' do
@@ -84,61 +84,7 @@ RSpec.describe Scimitar::ApplicationController do
84
84
  get :index, params: { format: :scim }
85
85
  expect(response).to be_ok
86
86
  expect(JSON.parse(response.body)).to eql({ 'message' => 'cool, cool!' })
87
- expect(response.headers['WWW-Authenticate']).to eql('Bearer')
88
- end
89
-
90
- it 'renders failure with bad token' do
91
- request.env['HTTP_AUTHORIZATION'] = 'Bearer Invalid'
92
-
93
- get :index, params: { format: :scim }
94
- expect(response).not_to be_ok
95
- end
96
-
97
- it 'renders failure with blank token' do
98
- request.env['HTTP_AUTHORIZATION'] = 'Bearer'
99
-
100
- get :index, params: { format: :scim }
101
- expect(response).not_to be_ok
102
- end
103
-
104
- it 'renders failure with missing header' do
105
- get :index, params: { format: :scim }
106
- expect(response).not_to be_ok
107
- end
108
- end
109
-
110
- context 'authenticator evaluated within controller context' do
111
-
112
- # Define a controller with a custom instance method 'valid_token'.
113
- #
114
- controller do
115
- def index
116
- render json: { 'message' => 'cool, cool!' }, format: :scim
117
- end
118
-
119
- def valid_token
120
- 'B'
121
- end
122
- end
123
-
124
- # Call the above controller method from the token authenticator Proc,
125
- # proving that it was executed in the controller's context.
126
- #
127
- before do
128
- Scimitar.engine_configuration = Scimitar::EngineConfiguration.new(
129
- token_authenticator: Proc.new do | token, options |
130
- token == self.valid_token()
131
- end
132
- )
133
- end
134
-
135
- it 'renders success when valid creds are given' do
136
- request.env['HTTP_AUTHORIZATION'] = 'Bearer B'
137
-
138
- get :index, params: { format: :scim }
139
- expect(response).to be_ok
140
- expect(JSON.parse(response.body)).to eql({ 'message' => 'cool, cool!' })
141
- expect(response.headers['WWW-Authenticate']).to eql('Bearer')
87
+ expect(response.headers['WWW_AUTHENTICATE']).to eql('Bearer')
142
88
  end
143
89
 
144
90
  it 'renders failure with bad token' do
@@ -223,74 +169,5 @@ RSpec.describe Scimitar::ApplicationController do
223
169
  expect(parsed_body).to include('status' => '500')
224
170
  expect(parsed_body).to include('detail' => 'Bang')
225
171
  end
226
-
227
- context 'with an exception reporter' do
228
- around :each do | example |
229
- original_configuration = Scimitar.engine_configuration.exception_reporter
230
- Scimitar.engine_configuration.exception_reporter = Proc.new do | exception |
231
- @exception = exception
232
- end
233
- example.run()
234
- ensure
235
- Scimitar.engine_configuration.exception_reporter = original_configuration
236
- end
237
-
238
- context 'and "internal server error"' do
239
- it 'is invoked' do
240
- get :index, params: { format: :scim }
241
-
242
- expect(@exception).to be_a(RuntimeError)
243
- expect(@exception.message).to eql('Bang')
244
- end
245
- end
246
-
247
- context 'and "not found"' do
248
- controller do
249
- def index
250
- handle_resource_not_found(ActiveRecord::RecordNotFound.new(42))
251
- end
252
- end
253
-
254
- it 'is invoked' do
255
- get :index, params: { format: :scim }
256
-
257
- expect(@exception).to be_a(ActiveRecord::RecordNotFound)
258
- expect(@exception.message).to eql('42')
259
- end
260
- end
261
-
262
- context 'and bad JSON' do
263
- controller do
264
- def index
265
- begin
266
- raise 'Hello'
267
- rescue
268
- raise ActionDispatch::Http::Parameters::ParseError
269
- end
270
- end
271
- end
272
-
273
- it 'is invoked' do
274
- get :index, params: { format: :scim }
275
-
276
- expect(@exception).to be_a(ActionDispatch::Http::Parameters::ParseError)
277
- expect(@exception.message).to eql('Hello')
278
- end
279
- end
280
-
281
- context 'and a bad content type' do
282
- controller do
283
- def index; end
284
- end
285
-
286
- it 'is invoked' do
287
- request.headers['Content-Type'] = 'text/plain'
288
- get :index
289
-
290
- expect(@exception).to be_a(Scimitar::ErrorResponse)
291
- expect(@exception.message).to eql('Only application/scim+json type is accepted.')
292
- end
293
- end
294
- end # "context 'exception reporter' do"
295
- end # "context 'error handling' do"
172
+ end
296
173
  end
@@ -9,15 +9,11 @@ RSpec.describe Scimitar::ResourceTypesController do
9
9
  it 'renders the resource type for user' do
10
10
  get :index, format: :scim
11
11
  response_hash = JSON.parse(response.body)
12
- expected_response = {
13
- schemas: ['urn:ietf:params:scim:api:messages:2.0:ListResponse'],
14
- totalResults: 2,
15
- Resources: [
16
- Scimitar::Resources::User.resource_type(scim_resource_type_url(name: 'User', test: 1)),
17
- Scimitar::Resources::Group.resource_type(scim_resource_type_url(name: 'Group', test: 1))
18
- ]
19
- }.to_json
12
+ expected_response = [ Scimitar::Resources::User.resource_type(scim_resource_type_url(name: 'User')),
13
+ Scimitar::Resources::Group.resource_type(scim_resource_type_url(name: 'Group'))
14
+ ].to_json
20
15
 
16
+ response_hash = JSON.parse(response.body)
21
17
  expect(response_hash).to eql(JSON.parse(expected_response))
22
18
  end
23
19