scimaenaga 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -0
- data/README.md +2 -14
- data/app/controllers/concerns/scim_rails/exception_handler.rb +43 -1
- data/app/controllers/scim_rails/scim_groups_controller.rb +64 -40
- data/app/controllers/scim_rails/scim_users_controller.rb +39 -65
- data/app/libraries/scim_patch.rb +15 -10
- data/app/libraries/scim_patch_operation.rb +127 -24
- data/app/models/scim_rails/scim_query_parser.rb +5 -3
- data/config/routes.rb +2 -0
- data/lib/generators/scim_rails/templates/initializer.rb +0 -6
- data/lib/scim_rails/config.rb +1 -2
- data/lib/scim_rails/version.rb +1 -1
- data/spec/controllers/scim_rails/scim_groups_controller_spec.rb +249 -136
- data/spec/controllers/scim_rails/scim_users_controller_spec.rb +413 -203
- data/spec/dummy/app/models/user.rb +21 -0
- data/spec/dummy/bin/setup +2 -0
- data/spec/dummy/config/initializers/scim_rails_config.rb +6 -4
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20220117095407_add_country_to_users.rb +5 -0
- data/spec/dummy/db/migrate/20220131090107_add_deletable_to_users.rb +5 -0
- data/spec/dummy/db/schema.rb +7 -5
- data/spec/dummy/db/seeds.rb +15 -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 +61 -31
- data/spec/libraries/scim_patch_spec.rb +38 -29
- data/spec/models/scim_query_parser_spec.rb +30 -0
- metadata +83 -67
- data/spec/support/scim_rails_config.rb +0 -59
@@ -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,
|
@@ -15,6 +17,18 @@ class User < ApplicationRecord
|
|
15
17
|
case_insensitive: true
|
16
18
|
}
|
17
19
|
|
20
|
+
def active
|
21
|
+
return active?
|
22
|
+
end
|
23
|
+
|
24
|
+
def active=(active)
|
25
|
+
if active
|
26
|
+
self.archived_at = nil
|
27
|
+
else
|
28
|
+
self.archived_at ||= Time.now
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
18
32
|
def active?
|
19
33
|
archived_at.blank?
|
20
34
|
end
|
@@ -36,4 +50,11 @@ class User < ApplicationRecord
|
|
36
50
|
write_attribute(:archived_at, nil)
|
37
51
|
save!
|
38
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
|
39
60
|
end
|
data/spec/dummy/bin/setup
CHANGED
@@ -22,6 +22,8 @@ chdir APP_ROOT do
|
|
22
22
|
# unless File.exist?('config/database.yml')
|
23
23
|
# cp 'config/database.yml.sample', 'config/database.yml'
|
24
24
|
# end
|
25
|
+
puts "\n== Reset migration =="
|
26
|
+
system! 'bin/rails db:migrate:reset'
|
25
27
|
|
26
28
|
puts "\n== Preparing database =="
|
27
29
|
system! 'bin/rails db:setup'
|
@@ -12,13 +12,14 @@ ScimRails.configure do |config|
|
|
12
12
|
config.signing_algorithm = "HS256"
|
13
13
|
config.signing_secret = "2d6806dd11c2fece2e81b8ca76dcb0062f5b08e28e3264e8ba1c44bbd3578b70"
|
14
14
|
|
15
|
-
config.
|
16
|
-
config.
|
15
|
+
config.user_destroy_method = :destroy!
|
16
|
+
config.group_destroy_method = :destroy!
|
17
17
|
|
18
18
|
config.mutable_user_attributes = [
|
19
19
|
:first_name,
|
20
20
|
:last_name,
|
21
|
-
:email
|
21
|
+
:email,
|
22
|
+
:active
|
22
23
|
]
|
23
24
|
|
24
25
|
config.queryable_user_attributes = {
|
@@ -37,7 +38,8 @@ ScimRails.configure do |config|
|
|
37
38
|
{
|
38
39
|
value: :email
|
39
40
|
}
|
40
|
-
]
|
41
|
+
],
|
42
|
+
active: :active
|
41
43
|
}
|
42
44
|
|
43
45
|
config.user_schema = {
|
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
|
@@ -23,8 +23,8 @@ ActiveRecord::Schema.define(version: 2021_04_23_075950) do
|
|
23
23
|
create_table "group_users", force: :cascade do |t|
|
24
24
|
t.integer "group_id", null: false
|
25
25
|
t.integer "user_id", null: false
|
26
|
-
t.datetime "created_at",
|
27
|
-
t.datetime "updated_at",
|
26
|
+
t.datetime "created_at", null: false
|
27
|
+
t.datetime "updated_at", null: false
|
28
28
|
t.index ["group_id"], name: "index_group_users_on_group_id"
|
29
29
|
t.index ["user_id"], name: "index_group_users_on_user_id"
|
30
30
|
end
|
@@ -32,8 +32,8 @@ ActiveRecord::Schema.define(version: 2021_04_23_075950) do
|
|
32
32
|
create_table "groups", force: :cascade do |t|
|
33
33
|
t.string "name", null: false
|
34
34
|
t.integer "company_id", null: false
|
35
|
-
t.datetime "created_at",
|
36
|
-
t.datetime "updated_at",
|
35
|
+
t.datetime "created_at", null: false
|
36
|
+
t.datetime "updated_at", null: false
|
37
37
|
t.index ["company_id"], name: "index_groups_on_company_id"
|
38
38
|
end
|
39
39
|
|
@@ -45,6 +45,8 @@ ActiveRecord::Schema.define(version: 2021_04_23_075950) do
|
|
45
45
|
t.datetime "archived_at"
|
46
46
|
t.datetime "created_at", null: false
|
47
47
|
t.datetime "updated_at", null: false
|
48
|
+
t.string "country"
|
49
|
+
t.boolean "deletable"
|
48
50
|
end
|
49
51
|
|
50
52
|
add_foreign_key "group_users", "groups"
|
data/spec/dummy/db/seeds.rb
CHANGED
@@ -4,11 +4,25 @@ company = Company.create(
|
|
4
4
|
api_token: 1
|
5
5
|
)
|
6
6
|
|
7
|
+
group = Group.create(
|
8
|
+
company: company,
|
9
|
+
name: 'Test Group'
|
10
|
+
)
|
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
|
+
|
7
20
|
1.upto(1000) do |n|
|
8
21
|
User.create(
|
9
22
|
company: company,
|
10
23
|
first_name: "Test#{n}",
|
11
24
|
last_name: "User#{n}",
|
12
|
-
email: "#{n}@example.com"
|
25
|
+
email: "#{n}@example.com",
|
26
|
+
deletable: true
|
13
27
|
)
|
14
28
|
end
|
Binary file
|
File without changes
|