scimitar 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4361be0d5f54ce11106a22215c7ec4167a877961dc775908e902f3c6abc281e
4
- data.tar.gz: b4e721e5f247b4ed1f3fa1a65f0f68b4572bc4d41ad44a68d37578c41d71e718
3
+ metadata.gz: 95a2166cc921a400959f9d8d4398f6bf8ecb772f8d7a0a0a73950892e85d808a
4
+ data.tar.gz: cdf5aab3812f10f69c96304e738a150f4208850267527b66d36eeb99548d7b1f
5
5
  SHA512:
6
- metadata.gz: f373036a611555190e8d15bfd021be1bda8dc3bd358d58dfc8825f656bcdd648a5b7b2c06e091c58455b7eadec6277ccbf58646dd2b26bc4f9864dd6aa2761e7
7
- data.tar.gz: e05d6fd73646929393c7edfea91076bf475fb1f997be0692130a5ba12b2d0f56ee8e106f775b1cdabdf8ed8723d56042b4941c110f66ce800b6868336d6762f7
6
+ metadata.gz: f0925517599b107e44fd93db9be142aebe608892c2c5069c50d22b353c51238290710474b062a002fdb010be3d783c4dea3b314f72f47b4aca3c2385a8fc1377
7
+ data.tar.gz: eef6eebfc64bb2d4adabfca110f26e3a6c9e227f47387da6fb384925899ddf0ae260cf68176f24040a6bb356cf34f6576c920bd44264d4a1fee415aeadc237e6
@@ -1,6 +1,6 @@
1
1
  module Scimitar
2
2
  module Errors
3
- def add_errors_from_hash(errors_hash, prefix: nil)
3
+ def add_errors_from_hash(errors_hash:, prefix: nil)
4
4
  errors_hash.each_pair do |key, value|
5
5
  new_key = prefix.nil? ? key : "#{prefix}.#{key}".to_sym
6
6
  if value.is_a?(Array)
@@ -88,7 +88,7 @@ module Scimitar
88
88
  end
89
89
  value.class.schema.valid?(value)
90
90
  return true if value.errors.empty?
91
- add_errors_from_hash(value.errors.to_hash, prefix: self.name)
91
+ add_errors_from_hash(errors_hash: value.errors.to_hash, prefix: self.name)
92
92
  false
93
93
  end
94
94
 
@@ -26,7 +26,9 @@ module Scimitar
26
26
  #
27
27
  def self.valid?(resource)
28
28
  cloned_scim_attributes.each do |scim_attribute|
29
- resource.add_errors_from_hash(scim_attribute.errors.to_hash) unless scim_attribute.valid?(resource.send(scim_attribute.name))
29
+ unless scim_attribute.valid?(resource.send(scim_attribute.name))
30
+ resource.add_errors_from_hash(errors_hash: scim_attribute.errors.to_hash)
31
+ end
30
32
  end
31
33
  end
32
34
 
@@ -2,81 +2,85 @@
2
2
  #
3
3
  # For supporting information and rationale, please see README.md.
4
4
 
5
- # =============================================================================
6
- # SERVICE PROVIDER CONFIGURATION
7
- # =============================================================================
8
- #
9
- # This is a Ruby abstraction over a SCIM entity that declares the capabilities
10
- # supported by a particular implementation.
11
- #
12
- # Typically this is used to declare parts of the standard unsupported, if you
13
- # don't need them and don't want to provide subclass support.
14
- #
15
- Scimitar.service_provider_configuration = Scimitar::ServiceProviderConfiguration.new({
5
+ Rails.application.config.to_prepare do # (required for >= Rails 7 / Zeitwerk)
16
6
 
17
- # See https://tools.ietf.org/html/rfc7643#section-8.5 for properties.
7
+ # ===========================================================================
8
+ # SERVICE PROVIDER CONFIGURATION
9
+ # ===========================================================================
18
10
  #
19
- # See Gem source file 'app/models/scimitar/service_provider_configuration.rb'
20
- # for defaults. Define Hash keys here that override defaults; e.g. to declare
21
- # that filters are not supported so that calling clients shouldn't use them:
11
+ # This is a Ruby abstraction over a SCIM entity that declares the
12
+ # capabilities supported by a particular implementation.
22
13
  #
23
- # filter: Scimitar::Supported.unsupported
14
+ # Typically this is used to declare parts of the standard unsupported, if you
15
+ # don't need them and don't want to provide subclass support.
16
+ #
17
+ Scimitar.service_provider_configuration = Scimitar::ServiceProviderConfiguration.new({
24
18
 
25
- })
19
+ # See https://tools.ietf.org/html/rfc7643#section-8.5 for properties.
20
+ #
21
+ # See Gem file 'app/models/scimitar/service_provider_configuration.rb'
22
+ # for defaults. Define Hash keys here that override defaults; e.g. to
23
+ # declare that filters are not supported so that calling clients shouldn't
24
+ # use them:
25
+ #
26
+ # filter: Scimitar::Supported.unsupported
26
27
 
27
- # =============================================================================
28
- # ENGINE CONFIGURATION
29
- # =============================================================================
30
- #
31
- # This is where you provide callbacks for things like authorisation or mixins
32
- # that get included into all Scimitar-derived controllers (for things like
33
- # before-actions that apply to all Scimitar controller-based routes).
34
- #
35
- Scimitar.engine_configuration = Scimitar::EngineConfiguration.new({
28
+ })
36
29
 
37
- # If you have filters you want to run for any Scimitar action/route, you can
38
- # define them here. For example, you might use a before-action to set up some
39
- # multi-tenancy related state, or skip Rails CSRF token verification/
40
- #
41
- # For example:
30
+ # ===========================================================================
31
+ # ENGINE CONFIGURATION
32
+ # ===========================================================================
42
33
  #
43
- # application_controller_mixin: Module.new do
44
- # def self.included(base)
45
- # base.class_eval do
34
+ # This is where you provide callbacks for things like authorisation or mixins
35
+ # that get included into all Scimitar-derived controllers (for things like
36
+ # before-actions that apply to all Scimitar controller-based routes).
46
37
  #
47
- # # Anything here is written just as you'd write it at the top of
48
- # # one of your controller classes, but it gets included in all
49
- # # Scimitar classes too.
50
- #
51
- # skip_before_action :verify_authenticity_token
52
- # prepend_before_action :setup_some_kind_of_multi_tenancy_data
53
- # end
54
- # end
55
- # end, # ...other configuration entries might follow...
38
+ Scimitar.engine_configuration = Scimitar::EngineConfiguration.new({
56
39
 
57
- # If you want to support username/password authentication:
58
- #
59
- # basic_authenticator: Proc.new do | username, password |
60
- # # Check username/password and return 'true' if valid, else 'false'.
61
- # end, # ...other configuration entries might follow...
62
- #
63
- # The 'username' and 'password' parameters come from Rails:
64
- #
65
- # https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic.html
66
- # https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic/ControllerMethods.html#method-i-authenticate_with_http_basic
40
+ # If you have filters you want to run for any Scimitar action/route, you
41
+ # can define them here. For example, you might use a before-action to set
42
+ # up some multi-tenancy related state, or skip Rails CSRF token
43
+ # verification. For example:
44
+ #
45
+ # application_controller_mixin: Module.new do
46
+ # def self.included(base)
47
+ # base.class_eval do
48
+ #
49
+ # # Anything here is written just as you'd write it at the top of
50
+ # # one of your controller classes, but it gets included in all
51
+ # # Scimitar classes too.
52
+ #
53
+ # skip_before_action :verify_authenticity_token
54
+ # prepend_before_action :setup_some_kind_of_multi_tenancy_data
55
+ # end
56
+ # end
57
+ # end, # ...other configuration entries might follow...
67
58
 
68
- # If you want to support HTTP bearer token (OAuth-style) authentication:
69
- #
70
- # token_authenticator: Proc.new do | token, options |
71
- # # Check token and return 'true' if valid, else 'false'.
72
- # end, # ...other configuration entries might follow...
73
- #
74
- # The 'token' and 'options' parameters come from Rails:
75
- #
76
- # https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html
77
- # https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token/ControllerMethods.html#method-i-authenticate_with_http_token
78
- #
79
- # Note that both basic and token authentication can be declared, with the
80
- # parameters in the inbound HTTP request determining which is invoked.
59
+ # If you want to support username/password authentication:
60
+ #
61
+ # basic_authenticator: Proc.new do | username, password |
62
+ # # Check username/password and return 'true' if valid, else 'false'.
63
+ # end, # ...other configuration entries might follow...
64
+ #
65
+ # The 'username' and 'password' parameters come from Rails:
66
+ #
67
+ # https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic.html
68
+ # https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic/ControllerMethods.html#method-i-authenticate_with_http_basic
69
+
70
+ # If you want to support HTTP bearer token (OAuth-style) authentication:
71
+ #
72
+ # token_authenticator: Proc.new do | token, options |
73
+ # # Check token and return 'true' if valid, else 'false'.
74
+ # end, # ...other configuration entries might follow...
75
+ #
76
+ # The 'token' and 'options' parameters come from Rails:
77
+ #
78
+ # https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html
79
+ # https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token/ControllerMethods.html#method-i-authenticate_with_http_token
80
+ #
81
+ # Note that both basic and token authentication can be declared, with the
82
+ # parameters in the inbound HTTP request determining which is invoked.
83
+
84
+ })
81
85
 
82
- })
86
+ end
@@ -3,11 +3,11 @@ module Scimitar
3
3
  # Gem version. If this changes, be sure to re-run "bundle install" or
4
4
  # "bundle update".
5
5
  #
6
- VERSION = '1.2.0'
6
+ VERSION = '2.0.0'
7
7
 
8
8
  # Date for VERSION. If this changes, be sure to re-run "bundle install"
9
9
  # or "bundle update".
10
10
  #
11
- DATE = '2021-09-27'
11
+ DATE = '2022-03-04'
12
12
 
13
13
  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,14 +1,16 @@
1
1
  # Test app configuration.
2
2
  #
3
- Scimitar.engine_configuration = Scimitar::EngineConfiguration.new({
3
+ Rails.application.config.to_prepare do
4
+ Scimitar.engine_configuration = Scimitar::EngineConfiguration.new({
4
5
 
5
- application_controller_mixin: Module.new do
6
- def self.included(base)
7
- base.class_eval do
8
- def test_hook; end
9
- before_action :test_hook
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
10
12
  end
11
13
  end
12
- end
13
14
 
14
- })
15
+ })
16
+ end
@@ -42,25 +42,25 @@ RSpec.describe Scimitar::Resources::User do
42
42
  let(:user) { described_class.new }
43
43
 
44
44
  it 'adds the error when the value is a string' do
45
- user.add_errors_from_hash(key: 'some error')
45
+ user.add_errors_from_hash(errors_hash: {key: 'some error'})
46
46
  expect(user.errors.messages.to_h).to eql({key: ['some error']})
47
47
  expect(user.errors.full_messages).to eql(['Key some error'])
48
48
  end
49
49
 
50
50
  it 'adds the error when the value is an array' do
51
- user.add_errors_from_hash(key: ['error1', 'error2'])
51
+ user.add_errors_from_hash(errors_hash: {key: ['error1', 'error2']})
52
52
  expect(user.errors.messages.to_h).to eql({key: ['error1', 'error2']})
53
53
  expect(user.errors.full_messages).to eql(['Key error1', 'Key error2'])
54
54
  end
55
55
 
56
56
  it 'adds the error with prefix when the value is a string' do
57
- user.add_errors_from_hash({key: 'some error'}, prefix: :pre)
57
+ user.add_errors_from_hash(errors_hash: {key: 'some error'}, prefix: :pre)
58
58
  expect(user.errors.messages.to_h).to eql({:'pre.key' => ['some error']})
59
59
  expect(user.errors.full_messages).to eql(['Pre key some error'])
60
60
  end
61
61
 
62
62
  it 'adds the error wity prefix when the value is an array' do
63
- user.add_errors_from_hash({key: ['error1', 'error2']}, prefix: :pre)
63
+ user.add_errors_from_hash(errors_hash: {key: ['error1', 'error2']}, prefix: :pre)
64
64
  expect(user.errors.messages.to_h).to eql({:'pre.key' => ['error1', 'error2']})
65
65
  expect(user.errors.full_messages).to eql(['Pre key error1', 'Pre key error2'])
66
66
  end
@@ -23,7 +23,6 @@ RSpec.describe Scimitar::ApplicationController do
23
23
 
24
24
  expect(response).to have_http_status(:bad_request)
25
25
  expect(JSON.parse(response.body)['detail']).to start_with('Invalid JSON - ')
26
- expect(JSON.parse(response.body)['detail']).to include("'not-json-12345'")
27
26
  end
28
27
 
29
28
  it 'translates Content-Type to Rails request format' do
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scimitar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RIPA Global
8
8
  - Andrew David Hodgkinson
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-09-27 00:00:00.000000000 Z
12
+ date: 2022-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '6.0'
20
+ version: '7.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '6.0'
27
+ version: '7.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '6.3'
76
+ version: '6.4'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '6.3'
83
+ version: '6.4'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rspec-rails
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -245,7 +245,7 @@ metadata:
245
245
  source_code_uri: https://github.com/RIPAGlobal/scimitar/
246
246
  bug_tracker_uri: https://github.com/RIPAGlobal/scimitar/issues/
247
247
  changelog_uri: https://github.com/RIPAGlobal/scimitar/blob/master/CHANGELOG.md
248
- post_install_message:
248
+ post_install_message:
249
249
  rdoc_options: []
250
250
  require_paths:
251
251
  - lib
@@ -260,51 +260,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  - !ruby/object:Gem::Version
261
261
  version: '0'
262
262
  requirements: []
263
- rubygems_version: 3.2.28
264
- signing_key:
263
+ rubygems_version: 3.3.3
264
+ signing_key:
265
265
  specification_version: 4
266
266
  summary: SCIM v2 for Rails
267
267
  test_files:
268
- - spec/spec_helper.rb
269
- - spec/models/scimitar/lists/query_parser_spec.rb
268
+ - spec/apps/dummy/app/controllers/custom_destroy_mock_users_controller.rb
269
+ - spec/apps/dummy/app/controllers/custom_request_verifiers_controller.rb
270
+ - spec/apps/dummy/app/controllers/mock_groups_controller.rb
271
+ - spec/apps/dummy/app/controllers/mock_users_controller.rb
272
+ - spec/apps/dummy/app/models/mock_group.rb
273
+ - spec/apps/dummy/app/models/mock_user.rb
274
+ - spec/apps/dummy/config/application.rb
275
+ - spec/apps/dummy/config/boot.rb
276
+ - spec/apps/dummy/config/environment.rb
277
+ - spec/apps/dummy/config/environments/test.rb
278
+ - spec/apps/dummy/config/initializers/cookies_serializer.rb
279
+ - spec/apps/dummy/config/initializers/scimitar.rb
280
+ - spec/apps/dummy/config/initializers/session_store.rb
281
+ - spec/apps/dummy/config/routes.rb
282
+ - spec/apps/dummy/db/migrate/20210304014602_create_mock_users.rb
283
+ - spec/apps/dummy/db/migrate/20210308020313_create_mock_groups.rb
284
+ - spec/apps/dummy/db/migrate/20210308044214_create_join_table_mock_groups_mock_users.rb
285
+ - spec/apps/dummy/db/schema.rb
286
+ - spec/controllers/scimitar/application_controller_spec.rb
287
+ - spec/controllers/scimitar/resource_types_controller_spec.rb
288
+ - spec/controllers/scimitar/resources_controller_spec.rb
289
+ - spec/controllers/scimitar/schemas_controller_spec.rb
290
+ - spec/controllers/scimitar/service_provider_configurations_controller_spec.rb
291
+ - spec/models/scimitar/complex_types/address_spec.rb
292
+ - spec/models/scimitar/complex_types/email_spec.rb
270
293
  - spec/models/scimitar/lists/count_spec.rb
294
+ - spec/models/scimitar/lists/query_parser_spec.rb
295
+ - spec/models/scimitar/resource_type_spec.rb
296
+ - spec/models/scimitar/resources/base_spec.rb
271
297
  - spec/models/scimitar/resources/base_validation_spec.rb
272
298
  - spec/models/scimitar/resources/mixin_spec.rb
273
299
  - spec/models/scimitar/resources/user_spec.rb
274
- - spec/models/scimitar/resources/base_spec.rb
275
300
  - spec/models/scimitar/schema/attribute_spec.rb
301
+ - spec/models/scimitar/schema/base_spec.rb
276
302
  - spec/models/scimitar/schema/group_spec.rb
277
303
  - spec/models/scimitar/schema/user_spec.rb
278
- - spec/models/scimitar/schema/base_spec.rb
279
- - spec/models/scimitar/resource_type_spec.rb
280
- - spec/models/scimitar/complex_types/email_spec.rb
281
- - spec/models/scimitar/complex_types/address_spec.rb
282
- - spec/requests/controller_configuration_spec.rb
283
- - spec/requests/engine_spec.rb
284
304
  - spec/requests/active_record_backed_resources_controller_spec.rb
285
305
  - spec/requests/application_controller_spec.rb
306
+ - spec/requests/controller_configuration_spec.rb
307
+ - spec/requests/engine_spec.rb
308
+ - spec/spec_helper.rb
286
309
  - spec/spec_helper_spec.rb
287
310
  - spec/support/hash_with_indifferent_case_insensitive_access_spec.rb
288
- - spec/controllers/scimitar/schemas_controller_spec.rb
289
- - spec/controllers/scimitar/resource_types_controller_spec.rb
290
- - spec/controllers/scimitar/resources_controller_spec.rb
291
- - spec/controllers/scimitar/service_provider_configurations_controller_spec.rb
292
- - spec/controllers/scimitar/application_controller_spec.rb
293
- - spec/apps/dummy/app/models/mock_group.rb
294
- - spec/apps/dummy/app/models/mock_user.rb
295
- - spec/apps/dummy/app/controllers/custom_request_verifiers_controller.rb
296
- - spec/apps/dummy/app/controllers/custom_destroy_mock_users_controller.rb
297
- - spec/apps/dummy/app/controllers/mock_groups_controller.rb
298
- - spec/apps/dummy/app/controllers/mock_users_controller.rb
299
- - spec/apps/dummy/config/routes.rb
300
- - spec/apps/dummy/config/environments/test.rb
301
- - spec/apps/dummy/config/environment.rb
302
- - spec/apps/dummy/config/application.rb
303
- - spec/apps/dummy/config/boot.rb
304
- - spec/apps/dummy/config/initializers/session_store.rb
305
- - spec/apps/dummy/config/initializers/cookies_serializer.rb
306
- - spec/apps/dummy/config/initializers/scimitar.rb
307
- - spec/apps/dummy/db/schema.rb
308
- - spec/apps/dummy/db/migrate/20210308020313_create_mock_groups.rb
309
- - spec/apps/dummy/db/migrate/20210308044214_create_join_table_mock_groups_mock_users.rb
310
- - spec/apps/dummy/db/migrate/20210304014602_create_mock_users.rb