stormpath-sdk 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +8 -0
- data/lib/stormpath-sdk.rb +2 -0
- data/lib/stormpath-sdk/client.rb +1 -0
- data/lib/stormpath-sdk/resource/account.rb +3 -0
- data/lib/stormpath-sdk/resource/account_link.rb +22 -0
- data/lib/stormpath-sdk/resource/linked_account.rb +20 -0
- data/lib/stormpath-sdk/version.rb +2 -2
- data/spec/client_spec.rb +69 -0
- data/spec/resource/account_link_spec.rb +83 -0
- data/spec/resource/account_spec.rb +44 -0
- data/spec/resource/linked_account_spec.rb +56 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9ba021abe721aacd48f6507ca61e7d23bbe85f1
|
4
|
+
data.tar.gz: 4a0a74ae0bd2d179888becafc4ba94c8598b6c8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70784a596911dde78a22749952d552bf8c35042fad1387720796284f3a66ec4cd52c8757eb1117925a6c4d8d47546d0cb46ee6c7430a236becb5c32f046bcdc7
|
7
|
+
data.tar.gz: 6eb7a9b888f7a5e3c4ab1b5078aa38f82f5eac37fc86ccf2befe3ff34d78e4e6d88a2dcaa026683eb2687e463f5cc1aa2e206b7722b53728926e340eeb1797c2
|
data/CHANGES.md
CHANGED
data/lib/stormpath-sdk.rb
CHANGED
@@ -36,6 +36,8 @@ module Stormpath
|
|
36
36
|
autoload :CustomDataStorage, 'stormpath-sdk/resource/custom_data_storage'
|
37
37
|
autoload :CustomDataHashMethods, 'stormpath-sdk/resource/custom_data_hash_methods'
|
38
38
|
autoload :Tenant, 'stormpath-sdk/resource/tenant'
|
39
|
+
autoload :LinkedAccount, 'stormpath-sdk/resource/linked_account'
|
40
|
+
autoload :AccountLink, 'stormpath-sdk/resource/account_link'
|
39
41
|
autoload :Application, 'stormpath-sdk/resource/application'
|
40
42
|
autoload :Directory, 'stormpath-sdk/resource/directory'
|
41
43
|
autoload :Account, 'stormpath-sdk/resource/account'
|
data/lib/stormpath-sdk/client.rb
CHANGED
@@ -60,6 +60,7 @@ module Stormpath
|
|
60
60
|
has_many :organization_account_store_mappings, href: '/organizationAccountStoreMappings', can: [:get, :create]
|
61
61
|
has_many :access_tokens, href: '/accessTokens', can: [:get]
|
62
62
|
has_many :refresh_tokens, href: '/refreshTokens', can: [:get]
|
63
|
+
has_many :account_links, href: '/accountLinks', can: :create
|
63
64
|
|
64
65
|
private
|
65
66
|
|
@@ -30,6 +30,9 @@ class Stormpath::Resource::Account < Stormpath::Resource::Instance
|
|
30
30
|
has_many :group_memberships
|
31
31
|
has_many :applications
|
32
32
|
|
33
|
+
has_many :linked_accounts, class_name: :Account
|
34
|
+
has_many :account_links
|
35
|
+
|
33
36
|
has_one :custom_data
|
34
37
|
|
35
38
|
has_many :access_tokens
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2012 Stormpath, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
class Stormpath::Resource::AccountLink < Stormpath::Resource::Instance
|
17
|
+
prop_accessor :right_account, :left_account
|
18
|
+
prop_reader :created_at, :modified_at
|
19
|
+
|
20
|
+
belongs_to :right_account, class_name: :Account, href: '/rightAccount'
|
21
|
+
belongs_to :left_account, class_name: :Account, href: '/leftAccount'
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2012 Stormpath, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
class Stormpath::Resource::LinkedAccount < Stormpath::Resource::Instance
|
17
|
+
include Stormpath::Resource::CustomDataStorage
|
18
|
+
|
19
|
+
belongs_to :account
|
20
|
+
end
|
data/spec/client_spec.rb
CHANGED
@@ -786,4 +786,73 @@ properties
|
|
786
786
|
end
|
787
787
|
end
|
788
788
|
end
|
789
|
+
|
790
|
+
describe '#account_links' do
|
791
|
+
let(:application) do
|
792
|
+
test_api_client.applications.create(name: 'ruby sdk app', description: 'ruby sdk desc')
|
793
|
+
end
|
794
|
+
let(:directory1) do
|
795
|
+
test_api_client.directories.create(name: 'ruby sdk dir 1')
|
796
|
+
end
|
797
|
+
let(:directory2) do
|
798
|
+
test_api_client.directories.create(name: 'ruby sdk dir 2')
|
799
|
+
end
|
800
|
+
|
801
|
+
before do
|
802
|
+
test_api_client.account_store_mappings.create(
|
803
|
+
application: application,
|
804
|
+
account_store: directory1,
|
805
|
+
list_index: 1,
|
806
|
+
is_default_account_store: true,
|
807
|
+
is_default_group_store: false
|
808
|
+
)
|
809
|
+
|
810
|
+
test_api_client.account_store_mappings.create(
|
811
|
+
application: application,
|
812
|
+
account_store: directory2,
|
813
|
+
list_index: 2,
|
814
|
+
is_default_account_store: false,
|
815
|
+
is_default_group_store: false
|
816
|
+
)
|
817
|
+
end
|
818
|
+
|
819
|
+
let!(:account1) do
|
820
|
+
directory1.accounts.create(build_account(email: 'jekyll@example.com', username: 'account1'))
|
821
|
+
end
|
822
|
+
let!(:account2) do
|
823
|
+
directory2.accounts.create(build_account(email: 'hyde@example.com', username: 'account2'))
|
824
|
+
end
|
825
|
+
|
826
|
+
let(:link_accounts) do
|
827
|
+
test_api_client.account_links.create(
|
828
|
+
left_account: {
|
829
|
+
href: account1.href
|
830
|
+
},
|
831
|
+
right_account: {
|
832
|
+
href: account2.href
|
833
|
+
}
|
834
|
+
)
|
835
|
+
end
|
836
|
+
|
837
|
+
after do
|
838
|
+
application.delete
|
839
|
+
directory1.delete
|
840
|
+
directory2.delete
|
841
|
+
end
|
842
|
+
|
843
|
+
context 'account_links.create' do
|
844
|
+
it 'should build link between the 2 accounts' do
|
845
|
+
expect { link_accounts }.to change { account2.linked_accounts.count }.from(0).to(1)
|
846
|
+
end
|
847
|
+
end
|
848
|
+
|
849
|
+
context 'account_links.delete' do
|
850
|
+
before { link_accounts }
|
851
|
+
let(:destroy_link) { link_accounts.delete }
|
852
|
+
|
853
|
+
it 'should delete the link between the 2 accounts' do
|
854
|
+
expect { destroy_link }.to change { account2.linked_accounts.count }.from(1).to(0)
|
855
|
+
end
|
856
|
+
end
|
857
|
+
end
|
789
858
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Stormpath::Resource::AccountLink, :vcr do
|
4
|
+
let(:application) do
|
5
|
+
test_api_client.applications.create(name: 'ruby sdk app', description: 'ruby sdk desc')
|
6
|
+
end
|
7
|
+
let(:directory1) do
|
8
|
+
test_api_client.directories.create(name: 'ruby sdk dir 1')
|
9
|
+
end
|
10
|
+
let(:directory2) do
|
11
|
+
test_api_client.directories.create(name: 'ruby sdk dir 2')
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
test_api_client.account_store_mappings.create(
|
16
|
+
application: application,
|
17
|
+
account_store: directory1,
|
18
|
+
list_index: 1,
|
19
|
+
is_default_account_store: true,
|
20
|
+
is_default_group_store: false
|
21
|
+
)
|
22
|
+
|
23
|
+
test_api_client.account_store_mappings.create(
|
24
|
+
application: application,
|
25
|
+
account_store: directory2,
|
26
|
+
list_index: 2,
|
27
|
+
is_default_account_store: false,
|
28
|
+
is_default_group_store: false
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
let!(:account1) do
|
33
|
+
directory1.accounts.create(build_account(email: 'jekyll@example.com', username: 'account1'))
|
34
|
+
end
|
35
|
+
let!(:account2) do
|
36
|
+
directory2.accounts.create(build_account(email: 'hyde@example.com', username: 'account2'))
|
37
|
+
end
|
38
|
+
|
39
|
+
let!(:account_link) do
|
40
|
+
test_api_client.account_links.create(
|
41
|
+
left_account: {
|
42
|
+
href: account1.href
|
43
|
+
},
|
44
|
+
right_account: {
|
45
|
+
href: account2.href
|
46
|
+
}
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
after do
|
51
|
+
application.delete
|
52
|
+
directory1.delete
|
53
|
+
directory2.delete
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'instances should respond to attribute property methods' do
|
57
|
+
it do
|
58
|
+
[:left_account, :right_account].each do |property_accessor|
|
59
|
+
expect(account_link).to respond_to(property_accessor)
|
60
|
+
expect(account_link).to respond_to("#{property_accessor}=")
|
61
|
+
expect(account_link.send(property_accessor)).to be_a Stormpath::Resource::Account
|
62
|
+
end
|
63
|
+
|
64
|
+
[:created_at, :modified_at].each do |property_getter|
|
65
|
+
expect(account_link).to respond_to(property_getter)
|
66
|
+
expect(account_link.send(property_getter)).to be_a String
|
67
|
+
end
|
68
|
+
|
69
|
+
expect(account_link.left_account).to be_a Stormpath::Resource::Account
|
70
|
+
expect(account_link.right_account).to be_a Stormpath::Resource::Account
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'account link associations' do
|
75
|
+
it 'should belong_to right account' do
|
76
|
+
expect(account_link.right_account).to eq(account2)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should belong_to left account' do
|
80
|
+
expect(account_link.left_account).to eq(account1)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -79,6 +79,50 @@ describe Stormpath::Resource::Account, :vcr do
|
|
79
79
|
expect(account.tenant).to eq(account.directory.tenant)
|
80
80
|
end
|
81
81
|
|
82
|
+
describe 'linked accounts' do
|
83
|
+
let(:directory2) { test_api_client.directories.create name: 'ruby sdk dir 2' }
|
84
|
+
before do
|
85
|
+
test_api_client.account_store_mappings.create(
|
86
|
+
application: app,
|
87
|
+
account_store: directory2,
|
88
|
+
list_index: 2,
|
89
|
+
is_default_account_store: false,
|
90
|
+
is_default_group_store: false
|
91
|
+
)
|
92
|
+
account
|
93
|
+
end
|
94
|
+
|
95
|
+
after do
|
96
|
+
directory2.delete
|
97
|
+
end
|
98
|
+
|
99
|
+
let!(:account2) do
|
100
|
+
directory2.accounts.create(
|
101
|
+
email: 'test2@example.com',
|
102
|
+
givenName: 'Ruby SDK',
|
103
|
+
password: 'P@$$w0rd',
|
104
|
+
surname: 'SDK',
|
105
|
+
username: 'rubysdk2'
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
109
|
+
let!(:link_accounts) do
|
110
|
+
test_api_client.account_links.create(
|
111
|
+
left_account: {
|
112
|
+
href: account.href
|
113
|
+
},
|
114
|
+
right_account: {
|
115
|
+
href: account2.href
|
116
|
+
}
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should contain 1 linked account' do
|
121
|
+
expect(account.linked_accounts.count).to eq 1
|
122
|
+
expect(account.linked_accounts.first).to eq account2
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
82
126
|
after do
|
83
127
|
application.delete if application
|
84
128
|
account.delete if account
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Stormpath::Resource::LinkedAccount, :vcr do
|
4
|
+
let(:application) do
|
5
|
+
test_api_client.applications.create(name: 'ruby sdk app', description: 'ruby sdk desc')
|
6
|
+
end
|
7
|
+
let(:directory1) { test_api_client.directories.create(name: 'ruby sdk dir 1') }
|
8
|
+
let(:directory2) { test_api_client.directories.create(name: 'ruby sdk dir 2') }
|
9
|
+
let(:account1) do
|
10
|
+
directory1.accounts.create(build_account(email: 'jekyll@example.com', username: 'account1'))
|
11
|
+
end
|
12
|
+
let(:account2) do
|
13
|
+
directory2.accounts.create(build_account(email: 'hyde@example.com', username: 'account2'))
|
14
|
+
end
|
15
|
+
|
16
|
+
before do
|
17
|
+
test_api_client.account_store_mappings.create(
|
18
|
+
application: application,
|
19
|
+
account_store: directory1,
|
20
|
+
list_index: 1,
|
21
|
+
is_default_account_store: true,
|
22
|
+
is_default_group_store: false
|
23
|
+
)
|
24
|
+
|
25
|
+
test_api_client.account_store_mappings.create(
|
26
|
+
application: application,
|
27
|
+
account_store: directory2,
|
28
|
+
list_index: 2,
|
29
|
+
is_default_account_store: false,
|
30
|
+
is_default_group_store: false
|
31
|
+
)
|
32
|
+
|
33
|
+
test_api_client.account_links.create(
|
34
|
+
left_account: {
|
35
|
+
href: account1.href
|
36
|
+
},
|
37
|
+
right_account: {
|
38
|
+
href: account2.href
|
39
|
+
}
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
let(:linked_account) { account1.linked_accounts.first }
|
44
|
+
|
45
|
+
after do
|
46
|
+
application.delete
|
47
|
+
directory1.delete
|
48
|
+
directory2.delete
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'account link associations' do
|
52
|
+
it 'should belong_to account' do
|
53
|
+
expect(linked_account).to eq account2
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stormpath-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stormpath, Inc
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-11-
|
12
|
+
date: 2016-11-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -371,6 +371,7 @@ files:
|
|
371
371
|
- lib/stormpath-sdk/resource/access_token.rb
|
372
372
|
- lib/stormpath-sdk/resource/account.rb
|
373
373
|
- lib/stormpath-sdk/resource/account_creation_policy.rb
|
374
|
+
- lib/stormpath-sdk/resource/account_link.rb
|
374
375
|
- lib/stormpath-sdk/resource/account_membership.rb
|
375
376
|
- lib/stormpath-sdk/resource/account_overrides.rb
|
376
377
|
- lib/stormpath-sdk/resource/account_store.rb
|
@@ -391,6 +392,7 @@ files:
|
|
391
392
|
- lib/stormpath-sdk/resource/group.rb
|
392
393
|
- lib/stormpath-sdk/resource/group_membership.rb
|
393
394
|
- lib/stormpath-sdk/resource/instance.rb
|
395
|
+
- lib/stormpath-sdk/resource/linked_account.rb
|
394
396
|
- lib/stormpath-sdk/resource/oauth_policy.rb
|
395
397
|
- lib/stormpath-sdk/resource/organization.rb
|
396
398
|
- lib/stormpath-sdk/resource/organization_account_store_mapping.rb
|
@@ -422,6 +424,7 @@ files:
|
|
422
424
|
- spec/provider/account_resolver_spec.rb
|
423
425
|
- spec/provider/provider_spec.rb
|
424
426
|
- spec/resource/account_creation_policy_spec.rb
|
427
|
+
- spec/resource/account_link_spec.rb
|
425
428
|
- spec/resource/account_spec.rb
|
426
429
|
- spec/resource/account_store_mapping_spec.rb
|
427
430
|
- spec/resource/account_store_spec.rb
|
@@ -435,6 +438,7 @@ files:
|
|
435
438
|
- spec/resource/expansion_spec.rb
|
436
439
|
- spec/resource/group_membership_spec.rb
|
437
440
|
- spec/resource/group_spec.rb
|
441
|
+
- spec/resource/linked_account_spec.rb
|
438
442
|
- spec/resource/organization_spec.rb
|
439
443
|
- spec/resource/password_policy_spec.rb
|
440
444
|
- spec/resource/password_strength_spec.rb
|