scimaenaga 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/scim_rails/exception_handler.rb +43 -1
- data/app/controllers/scim_rails/scim_groups_controller.rb +13 -2
- data/app/controllers/scim_rails/scim_users_controller.rb +21 -0
- data/app/libraries/scim_patch.rb +1 -2
- data/app/libraries/scim_patch_operation.rb +105 -36
- data/config/routes.rb +1 -0
- data/lib/scim_rails/config.rb +1 -0
- data/lib/scim_rails/version.rb +1 -1
- data/spec/controllers/scim_rails/scim_groups_controller_spec.rb +25 -7
- data/spec/controllers/scim_rails/scim_users_controller_spec.rb +361 -220
- data/spec/dummy/app/models/user.rb +9 -0
- data/spec/dummy/config/initializers/scim_rails_config.rb +3 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20220131090107_add_deletable_to_users.rb +5 -0
- data/spec/dummy/db/schema.rb +2 -1
- data/spec/dummy/db/seeds.rb +10 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +5770 -0
- data/spec/dummy/put_group.http +5 -0
- data/spec/dummy/tmp/restart.txt +0 -0
- data/spec/factories/user.rb +2 -0
- data/spec/libraries/scim_patch_operation_spec.rb +51 -31
- data/spec/libraries/scim_patch_spec.rb +31 -33
- metadata +81 -67
@@ -3,6 +3,8 @@ class User < ApplicationRecord
|
|
3
3
|
has_many :group_users
|
4
4
|
has_many :groups, through: :group_users
|
5
5
|
|
6
|
+
before_destroy :check_deletable
|
7
|
+
|
6
8
|
validates \
|
7
9
|
:first_name,
|
8
10
|
:last_name,
|
@@ -48,4 +50,11 @@ class User < ApplicationRecord
|
|
48
50
|
write_attribute(:archived_at, nil)
|
49
51
|
save!
|
50
52
|
end
|
53
|
+
|
54
|
+
def check_deletable
|
55
|
+
return if deletable
|
56
|
+
|
57
|
+
errors.add(:base, 'The specified user could not be deleted.')
|
58
|
+
throw :abort
|
59
|
+
end
|
51
60
|
end
|
@@ -12,6 +12,9 @@ ScimRails.configure do |config|
|
|
12
12
|
config.signing_algorithm = "HS256"
|
13
13
|
config.signing_secret = "2d6806dd11c2fece2e81b8ca76dcb0062f5b08e28e3264e8ba1c44bbd3578b70"
|
14
14
|
|
15
|
+
config.user_destroy_method = :destroy!
|
16
|
+
config.group_destroy_method = :destroy!
|
17
|
+
|
15
18
|
config.mutable_user_attributes = [
|
16
19
|
:first_name,
|
17
20
|
:last_name,
|
Binary file
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 2022_01_31_090107) do
|
14
14
|
|
15
15
|
create_table "companies", force: :cascade do |t|
|
16
16
|
t.string "name", null: false
|
@@ -46,6 +46,7 @@ ActiveRecord::Schema.define(version: 2022_01_17_095407) do
|
|
46
46
|
t.datetime "created_at", null: false
|
47
47
|
t.datetime "updated_at", null: false
|
48
48
|
t.string "country"
|
49
|
+
t.boolean "deletable"
|
49
50
|
end
|
50
51
|
|
51
52
|
add_foreign_key "group_users", "groups"
|
data/spec/dummy/db/seeds.rb
CHANGED
@@ -9,11 +9,20 @@ group = Group.create(
|
|
9
9
|
name: 'Test Group'
|
10
10
|
)
|
11
11
|
|
12
|
+
User.create(
|
13
|
+
company: company,
|
14
|
+
first_name: 'scim',
|
15
|
+
last_name: 'owner',
|
16
|
+
email: 'owner@example.com',
|
17
|
+
deletable: false
|
18
|
+
)
|
19
|
+
|
12
20
|
1.upto(1000) do |n|
|
13
21
|
User.create(
|
14
22
|
company: company,
|
15
23
|
first_name: "Test#{n}",
|
16
24
|
last_name: "User#{n}",
|
17
|
-
email: "#{n}@example.com"
|
25
|
+
email: "#{n}@example.com",
|
26
|
+
deletable: true
|
18
27
|
)
|
19
28
|
end
|
Binary file
|
File without changes
|