scimaenaga 0.7.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -7
- data/Rakefile +6 -8
- data/app/controllers/concerns/{scim_rails → scimaenaga}/exception_handler.rb +47 -37
- data/app/controllers/concerns/scimaenaga/response.rb +94 -0
- data/app/controllers/scimaenaga/application_controller.rb +72 -0
- data/app/controllers/{scim_rails → scimaenaga}/scim_groups_controller.rb +26 -26
- data/app/controllers/scimaenaga/scim_schemas_controller.rb +42 -0
- data/app/controllers/scimaenaga/scim_users_controller.rb +104 -0
- data/app/helpers/{scim_rails → scimaenaga}/application_helper.rb +1 -1
- data/app/libraries/scim_patch.rb +16 -9
- data/app/libraries/scim_patch_operation.rb +51 -141
- data/app/libraries/scim_patch_operation_converter.rb +90 -0
- data/app/libraries/scim_patch_operation_group.rb +100 -0
- data/app/libraries/scim_patch_operation_user.rb +53 -0
- data/app/models/{scim_rails → scimaenaga}/application_record.rb +1 -1
- data/app/models/scimaenaga/authorize_api_request.rb +39 -0
- data/app/models/{scim_rails → scimaenaga}/scim_count.rb +8 -4
- data/app/models/scimaenaga/scim_query_parser.rb +49 -0
- data/config/routes.rb +15 -13
- data/lib/generators/scimaenaga/USAGE +8 -0
- data/lib/generators/scimaenaga/scimaenaga_generator.rb +7 -0
- data/lib/generators/{scim_rails → scimaenaga}/templates/initializer.rb +128 -22
- data/lib/{scim_rails → scimaenaga}/config.rb +9 -7
- data/lib/scimaenaga/encoder.rb +27 -0
- data/lib/scimaenaga/engine.rb +12 -0
- data/lib/scimaenaga/version.rb +5 -0
- data/lib/scimaenaga.rb +6 -0
- data/lib/tasks/{scim_rails_tasks.rake → scimaenaga_tasks.rake} +1 -1
- data/spec/controllers/{scim_rails → scimaenaga}/scim_groups_controller_spec.rb +8 -8
- data/spec/controllers/{scim_rails → scimaenaga}/scim_groups_request_spec.rb +18 -18
- data/spec/controllers/scimaenaga/scim_schemas_controller_spec.rb +238 -0
- data/spec/controllers/scimaenaga/scim_schemas_request_spec.rb +39 -0
- data/spec/controllers/{scim_rails → scimaenaga}/scim_users_controller_spec.rb +14 -15
- data/spec/controllers/{scim_rails → scimaenaga}/scim_users_request_spec.rb +20 -20
- data/spec/dummy/app/assets/config/manifest.js +1 -1
- data/spec/dummy/config/application.rb +1 -2
- data/spec/dummy/config/initializers/{scim_rails_config.rb → scimaenaga_config.rb} +25 -25
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/factories/company.rb +3 -3
- data/spec/lib/scimaenaga/encoder_spec.rb +64 -0
- data/spec/libraries/scim_patch_operation_group_spec.rb +165 -0
- data/spec/libraries/scim_patch_operation_user_spec.rb +101 -0
- data/spec/libraries/scim_patch_spec.rb +129 -45
- data/spec/models/scim_query_parser_spec.rb +5 -6
- metadata +107 -108
- data/app/controllers/concerns/scim_rails/response.rb +0 -94
- data/app/controllers/scim_rails/application_controller.rb +0 -72
- data/app/controllers/scim_rails/scim_users_controller.rb +0 -107
- data/app/models/scim_rails/authorize_api_request.rb +0 -40
- data/app/models/scim_rails/scim_query_parser.rb +0 -49
- data/lib/generators/scim_rails/USAGE +0 -8
- data/lib/generators/scim_rails/scim_rails_generator.rb +0 -7
- data/lib/scim_rails/encoder.rb +0 -25
- data/lib/scim_rails/engine.rb +0 -12
- data/lib/scim_rails/version.rb +0 -5
- data/lib/scim_rails.rb +0 -6
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +0 -5770
- data/spec/dummy/put_group.http +0 -5
- data/spec/dummy/tmp/restart.txt +0 -0
- data/spec/lib/scim_rails/encoder_spec.rb +0 -62
- data/spec/libraries/scim_patch_operation_spec.rb +0 -116
data/spec/dummy/put_group.http
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
curl 'http://localhost:9999/scim/v2/Groups/1' \
|
2
|
-
-X 'PUT' \
|
3
|
-
-d '{"schemas": ["urn:ietf:params:scim:api:messages:2.0:PutOp"], "Operations": ["op": "Add", "path": "members", "value": {"$ref": null, "value": "1"}]}' \
|
4
|
-
-H 'Content-Type: application/scim+json' \
|
5
|
-
-H 'Authorization:Basic dGVzdF9jb21wYW55OjE=' \
|
data/spec/dummy/tmp/restart.txt
DELETED
File without changes
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe ScimRails::Encoder do
|
4
|
-
let(:company) { Company.new(subdomain: "test") }
|
5
|
-
|
6
|
-
describe "::encode" do
|
7
|
-
context "with signing configuration" do
|
8
|
-
it "generates a signed token with the company attribute" do
|
9
|
-
token = ScimRails::Encoder.encode(company)
|
10
|
-
payload = ScimRails::Encoder.decode(token)
|
11
|
-
|
12
|
-
expect(token).to match /[a-z|A-Z|0-9.]{16,}\.[a-z|A-Z|0-9.]{16,}/
|
13
|
-
expect(payload).to contain_exactly(["iat", Integer], ["subdomain", "test"])
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "without signing configuration" do
|
18
|
-
before do
|
19
|
-
allow(ScimRails.config).to receive(:signing_secret).and_return(nil)
|
20
|
-
allow(ScimRails.config).to receive(:signing_algorithm).and_return(ScimRails::Config::ALGO_NONE)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "generates an unsigned token with the company attribute" do
|
24
|
-
token = ScimRails::Encoder.encode(company)
|
25
|
-
payload = ScimRails::Encoder.decode(token)
|
26
|
-
|
27
|
-
expect(token).to match /[a-z|A-Z|0-9.]{16,}/
|
28
|
-
expect(payload).to contain_exactly(["iat", Integer], ["subdomain", "test"])
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "::decode" do
|
34
|
-
let(:token) { ScimRails::Encoder.encode(company) }
|
35
|
-
|
36
|
-
it "raises InvalidCredentials error for an invalid token" do
|
37
|
-
token = "f487bf84bfub4f74fj4894fnh483f4h4u8f"
|
38
|
-
expect { ScimRails::Encoder.decode(token) }.to raise_error ScimRails::ExceptionHandler::InvalidCredentials
|
39
|
-
end
|
40
|
-
|
41
|
-
context "with signing configuration" do
|
42
|
-
it "decodes a signed token, returning the company attributes" do
|
43
|
-
payload = ScimRails::Encoder.decode(token)
|
44
|
-
|
45
|
-
expect(payload).to contain_exactly(["iat", Integer], ["subdomain", "test"])
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "without signing configuration" do
|
50
|
-
before do
|
51
|
-
allow(ScimRails.config).to receive(:signing_secret).and_return(nil)
|
52
|
-
allow(ScimRails.config).to receive(:signing_algorithm).and_return(ScimRails::Config::ALGO_NONE)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "decodes an unsigned token, returning the company attributes" do
|
56
|
-
payload = ScimRails::Encoder.decode(token)
|
57
|
-
|
58
|
-
expect(payload).to contain_exactly(["iat", Integer], ["subdomain", "test"])
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe ScimPatchOperation do
|
6
|
-
let(:op) { 'Replace' }
|
7
|
-
let(:path) { 'userName' }
|
8
|
-
let(:value) { 'taro.suzuki' }
|
9
|
-
let(:mutable_attributes_schema) do
|
10
|
-
{
|
11
|
-
userName: :name,
|
12
|
-
displayName: :display_name,
|
13
|
-
emails: [
|
14
|
-
{
|
15
|
-
value: :email,
|
16
|
-
}
|
17
|
-
],
|
18
|
-
name: {
|
19
|
-
familyName: :family_name,
|
20
|
-
givenName: :given_name,
|
21
|
-
},
|
22
|
-
active: :active,
|
23
|
-
}
|
24
|
-
end
|
25
|
-
let(:operation) do
|
26
|
-
described_class.new(
|
27
|
-
op,
|
28
|
-
path,
|
29
|
-
value,
|
30
|
-
mutable_attributes_schema
|
31
|
-
)
|
32
|
-
end
|
33
|
-
describe '#initialize' do
|
34
|
-
context 'replace single attribute' do
|
35
|
-
it {
|
36
|
-
expect(operation.operations[0].op).to eq :replace
|
37
|
-
expect(operation.operations[0].path_scim).to eq path
|
38
|
-
expect(operation.operations[0].path_sp).to eq :name
|
39
|
-
expect(operation.operations[0].value).to eq value
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'add single attribute' do
|
44
|
-
let(:op) { 'Add' }
|
45
|
-
it {
|
46
|
-
expect(operation.operations[0].op).to eq :add
|
47
|
-
expect(operation.operations[0].path_scim).to eq path
|
48
|
-
expect(operation.operations[0].path_sp).to eq :name
|
49
|
-
expect(operation.operations[0].value).to eq value
|
50
|
-
}
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'remove single attribute' do
|
54
|
-
let(:op) { 'Remove' }
|
55
|
-
it {
|
56
|
-
expect(operation.operations[0].op).to eq :remove
|
57
|
-
expect(operation.operations[0].path_scim).to eq path
|
58
|
-
expect(operation.operations[0].path_sp).to eq :name
|
59
|
-
expect(operation.operations[0].value).to eq value
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'replace email address' do
|
64
|
-
let(:path) { 'emails[type eq "work"].value' }
|
65
|
-
let(:value) { 'taro.suzuki@example.com' }
|
66
|
-
it {
|
67
|
-
expect(operation.operations[0].op).to eq :replace
|
68
|
-
expect(operation.operations[0].path_scim).to eq path
|
69
|
-
expect(operation.operations[0].path_sp).to eq :email
|
70
|
-
expect(operation.operations[0].value).to eq value
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'replace name.familyName' do
|
75
|
-
let(:path) { 'name.familyName' }
|
76
|
-
let(:value) { 'Suzuki' }
|
77
|
-
it {
|
78
|
-
expect(operation.operations[0].op).to eq :replace
|
79
|
-
expect(operation.operations[0].path_scim).to eq path
|
80
|
-
expect(operation.operations[0].path_sp).to eq :family_name
|
81
|
-
expect(operation.operations[0].value).to eq value
|
82
|
-
}
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'replace active' do
|
86
|
-
let(:path) { 'active' }
|
87
|
-
let(:value) { 'False' }
|
88
|
-
|
89
|
-
it 'convert string to bool' do
|
90
|
-
expect(operation.operations[0].value).to eq false
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context 'replace multiple attribute' do
|
95
|
-
let(:path) { nil }
|
96
|
-
let(:value) do
|
97
|
-
{
|
98
|
-
'userName' => 'taro.suzuki',
|
99
|
-
'displayName' => 'Taro Suzuki',
|
100
|
-
}
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'parse multiple value' do
|
104
|
-
expect(operation.operations[0].op).to eq :replace
|
105
|
-
expect(operation.operations[0].path_scim).to eq 'userName'
|
106
|
-
expect(operation.operations[0].path_sp).to eq :name
|
107
|
-
expect(operation.operations[0].value).to eq 'taro.suzuki'
|
108
|
-
|
109
|
-
expect(operation.operations[1].op).to eq :replace
|
110
|
-
expect(operation.operations[1].path_scim).to eq 'displayName'
|
111
|
-
expect(operation.operations[1].path_sp).to eq :display_name
|
112
|
-
expect(operation.operations[1].value).to eq 'Taro Suzuki'
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|