scimitar 1.8.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/scimitar/active_record_backed_resources_controller.rb +20 -94
  3. data/app/controllers/scimitar/application_controller.rb +13 -41
  4. data/app/controllers/scimitar/schemas_controller.rb +0 -5
  5. data/app/models/scimitar/complex_types/address.rb +6 -0
  6. data/app/models/scimitar/engine_configuration.rb +5 -13
  7. data/app/models/scimitar/error_response.rb +0 -12
  8. data/app/models/scimitar/lists/query_parser.rb +10 -25
  9. data/app/models/scimitar/resource_invalid_error.rb +1 -1
  10. data/app/models/scimitar/resources/base.rb +4 -14
  11. data/app/models/scimitar/resources/mixin.rb +13 -140
  12. data/app/models/scimitar/schema/address.rb +0 -1
  13. data/app/models/scimitar/schema/attribute.rb +5 -14
  14. data/app/models/scimitar/schema/base.rb +1 -1
  15. data/app/models/scimitar/schema/vdtp.rb +1 -1
  16. data/app/models/scimitar/service_provider_configuration.rb +3 -14
  17. data/config/initializers/scimitar.rb +3 -28
  18. data/lib/scimitar/version.rb +2 -2
  19. data/lib/scimitar.rb +2 -7
  20. data/spec/apps/dummy/app/controllers/mock_groups_controller.rb +1 -1
  21. data/spec/apps/dummy/app/models/mock_group.rb +1 -1
  22. data/spec/apps/dummy/app/models/mock_user.rb +8 -36
  23. data/spec/apps/dummy/config/application.rb +1 -0
  24. data/spec/apps/dummy/config/environments/test.rb +28 -5
  25. data/spec/apps/dummy/config/initializers/scimitar.rb +10 -61
  26. data/spec/apps/dummy/config/routes.rb +7 -28
  27. data/spec/apps/dummy/db/migrate/20210304014602_create_mock_users.rb +1 -10
  28. data/spec/apps/dummy/db/migrate/20210308044214_create_join_table_mock_groups_mock_users.rb +3 -8
  29. data/spec/apps/dummy/db/schema.rb +4 -11
  30. data/spec/controllers/scimitar/application_controller_spec.rb +3 -126
  31. data/spec/controllers/scimitar/resource_types_controller_spec.rb +2 -2
  32. data/spec/controllers/scimitar/schemas_controller_spec.rb +2 -10
  33. data/spec/models/scimitar/complex_types/address_spec.rb +4 -3
  34. data/spec/models/scimitar/complex_types/email_spec.rb +2 -0
  35. data/spec/models/scimitar/lists/query_parser_spec.rb +9 -76
  36. data/spec/models/scimitar/resources/base_spec.rb +70 -208
  37. data/spec/models/scimitar/resources/base_validation_spec.rb +2 -27
  38. data/spec/models/scimitar/resources/mixin_spec.rb +43 -790
  39. data/spec/models/scimitar/schema/attribute_spec.rb +3 -22
  40. data/spec/models/scimitar/schema/base_spec.rb +1 -1
  41. data/spec/models/scimitar/schema/user_spec.rb +0 -10
  42. data/spec/requests/active_record_backed_resources_controller_spec.rb +66 -709
  43. data/spec/requests/application_controller_spec.rb +3 -16
  44. data/spec/spec_helper.rb +0 -8
  45. metadata +14 -25
  46. data/LICENSE.txt +0 -21
  47. data/README.md +0 -710
  48. data/lib/scimitar/support/utilities.rb +0 -51
  49. data/spec/apps/dummy/app/controllers/custom_create_mock_users_controller.rb +0 -25
  50. data/spec/apps/dummy/app/controllers/custom_replace_mock_users_controller.rb +0 -25
  51. data/spec/apps/dummy/app/controllers/custom_save_mock_users_controller.rb +0 -24
  52. data/spec/apps/dummy/app/controllers/custom_update_mock_users_controller.rb +0 -25
@@ -1,51 +0,0 @@
1
- module Scimitar
2
-
3
- # Namespace containing various chunks of Scimitar support code that don't
4
- # logically fit into other areas.
5
- #
6
- module Support
7
-
8
- # A namespace that contains various stand-alone utility methods which act
9
- # as helpers for other parts of the code base, without risking namespace
10
- # pollution by e.g. being part of a module loaded into a client class.
11
- #
12
- module Utilities
13
-
14
- # Takes an array of components that usually come from a dotted path such
15
- # as <tt>foo.bar.baz</tt>, along with a value that is found at the end of
16
- # that path, then converts it into a nested Hash with each level of the
17
- # Hash corresponding to a step along the path.
18
- #
19
- # This was written to help with edge case SCIM uses where (most often, at
20
- # least) inbound calls use a dotted notation where nested values are more
21
- # commonly accepted; converting to nesting makes it easier for subsequent
22
- # processing code, which needs only handle nested Hash data.
23
- #
24
- # As an example, passing:
25
- #
26
- # ['foo', 'bar', 'baz'], 'value'
27
- #
28
- # ...yields:
29
- #
30
- # {'foo' => {'bar' => {'baz' => 'value'}}}
31
- #
32
- # Parameters:
33
- #
34
- # +array+:: Array containing path components, usually acquired from a
35
- # string with dot separators and a call to String#split.
36
- #
37
- # +value+:: The value found at the path indicated by +array+.
38
- #
39
- # If +array+ is empty, +value+ is returned directly, with no nesting
40
- # Hash wrapping it.
41
- #
42
- def self.dot_path(array, value)
43
- return value if array.empty?
44
-
45
- {}.tap do | hash |
46
- hash[array.shift()] = self.dot_path(array, value)
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,25 +0,0 @@
1
- # For tests only - uses custom 'create' implementation which passes a block to
2
- # Scimitar::ActiveRecordBackedResourcesController#create.
3
- #
4
- class CustomCreateMockUsersController < Scimitar::ActiveRecordBackedResourcesController
5
-
6
- OVERRIDDEN_NAME = SecureRandom.uuid
7
-
8
- def create
9
- super do | resource |
10
- resource.first_name = OVERRIDDEN_NAME
11
- resource.save!
12
- end
13
- end
14
-
15
- protected
16
-
17
- def storage_class
18
- MockUser
19
- end
20
-
21
- def storage_scope
22
- MockUser.all
23
- end
24
-
25
- end
@@ -1,25 +0,0 @@
1
- # For tests only - uses custom 'replace' implementation which passes a block to
2
- # Scimitar::ActiveRecordBackedResourcesController#create.
3
- #
4
- class CustomReplaceMockUsersController < Scimitar::ActiveRecordBackedResourcesController
5
-
6
- OVERRIDDEN_NAME = SecureRandom.uuid
7
-
8
- def replace
9
- super do | resource |
10
- resource.first_name = OVERRIDDEN_NAME
11
- resource.save!
12
- end
13
- end
14
-
15
- protected
16
-
17
- def storage_class
18
- MockUser
19
- end
20
-
21
- def storage_scope
22
- MockUser.all
23
- end
24
-
25
- end
@@ -1,24 +0,0 @@
1
- # For tests only - uses custom 'save!' implementation which passes a block to
2
- # Scimitar::ActiveRecordBackedResourcesController#save!.
3
- #
4
- class CustomSaveMockUsersController < Scimitar::ActiveRecordBackedResourcesController
5
-
6
- CUSTOM_SAVE_BLOCK_USERNAME_INDICATOR = 'Custom save-block invoked'
7
-
8
- protected
9
-
10
- def save!(_record)
11
- super do | record |
12
- record.update!(username: CUSTOM_SAVE_BLOCK_USERNAME_INDICATOR)
13
- end
14
- end
15
-
16
- def storage_class
17
- MockUser
18
- end
19
-
20
- def storage_scope
21
- MockUser.all
22
- end
23
-
24
- end
@@ -1,25 +0,0 @@
1
- # For tests only - uses custom 'update' implementation which passes a block to
2
- # Scimitar::ActiveRecordBackedResourcesController#create.
3
- #
4
- class CustomUpdateMockUsersController < Scimitar::ActiveRecordBackedResourcesController
5
-
6
- OVERRIDDEN_NAME = SecureRandom.uuid
7
-
8
- def update
9
- super do | resource |
10
- resource.first_name = OVERRIDDEN_NAME
11
- resource.save!
12
- end
13
- end
14
-
15
- protected
16
-
17
- def storage_class
18
- MockUser
19
- end
20
-
21
- def storage_scope
22
- MockUser.all
23
- end
24
-
25
- end