stormpath-sdk 1.3.0 → 1.3.1
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/.rspec +1 -0
- data/.travis.yml +0 -3
- data/CHANGES.md +9 -0
- data/README.md +8 -21
- data/Rakefile +1 -15
- data/lib/stormpath-sdk/oauth/error.rb +21 -0
- data/lib/stormpath-sdk/oauth/local_access_token_verification.rb +2 -2
- data/lib/stormpath-sdk/oauth/remote_access_token_verification.rb +2 -2
- data/lib/stormpath-sdk/version.rb +2 -2
- data/spec/auth/http_basic_authentication_spec.rb +6 -21
- data/spec/auth/http_bearer_authentication_spec.rb +11 -24
- data/spec/client_spec.rb +116 -258
- data/spec/oauth/access_token_authentication_result_spec.rb +14 -14
- data/spec/provider/provider_spec.rb +32 -40
- data/spec/resource/account_creation_policy_spec.rb +8 -13
- data/spec/resource/account_link_spec.rb +4 -17
- data/spec/resource/account_spec.rb +37 -81
- data/spec/resource/account_store_mapping_spec.rb +20 -32
- data/spec/resource/account_store_spec.rb +8 -31
- data/spec/resource/api_key_spec.rb +11 -14
- data/spec/resource/application_spec.rb +39 -168
- data/spec/resource/collection_spec.rb +17 -17
- data/spec/resource/custom_data_spec.rb +2 -2
- data/spec/resource/directory_spec.rb +164 -240
- data/spec/resource/email_template_spec.rb +21 -24
- data/spec/resource/group_membership_spec.rb +9 -12
- data/spec/resource/group_spec.rb +17 -31
- data/spec/resource/linked_account_spec.rb +4 -17
- data/spec/resource/organization_spec.rb +38 -110
- data/spec/resource/password_policy_spec.rb +13 -16
- data/spec/resource/password_strength_spec.rb +15 -18
- data/spec/resource/status_spec.rb +32 -35
- data/spec/spec_helper.rb +8 -139
- data/spec/support/api_key_helpers.rb +34 -0
- data/spec/support/custom_data_storage_behavior.rb +139 -156
- data/spec/support/env_names_warning.rb +59 -0
- data/spec/support/resource_helpers.rb +84 -0
- data/spec/support/resource_matchers.rb +6 -0
- data/stormpath-sdk.gemspec +1 -0
- metadata +20 -3
- data/support/api.rb +0 -55
@@ -1,20 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Stormpath::Resource::EmailTemplate, :vcr do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
let(:application) { test_api_client.applications.create(build_application) }
|
5
|
+
|
6
|
+
after { application.delete }
|
7
|
+
|
8
|
+
describe 'instances should respond to attribute property methods' do
|
9
|
+
let(:directory) { test_api_client.directories.create(build_directory) }
|
7
10
|
let(:password_policy) { directory.password_policy }
|
8
11
|
let(:reset_email_template) { password_policy.reset_email_templates.first }
|
9
12
|
|
10
13
|
before do
|
11
|
-
|
12
|
-
application: application,
|
13
|
-
account_store: directory,
|
14
|
-
list_index: 1,
|
15
|
-
is_default_account_store: false,
|
16
|
-
is_default_group_store: false
|
17
|
-
)
|
14
|
+
map_account_store(application, directory, 1, false, false)
|
18
15
|
end
|
19
16
|
|
20
17
|
after { directory.delete }
|
@@ -35,25 +32,25 @@ describe Stormpath::Resource::EmailTemplate, :vcr do
|
|
35
32
|
end
|
36
33
|
|
37
34
|
it 'can change attributes' do
|
38
|
-
reset_email_template.name =
|
39
|
-
reset_email_template.description =
|
40
|
-
reset_email_template.subject =
|
41
|
-
reset_email_template.from_email_address = "email
|
42
|
-
reset_email_template.text_body =
|
43
|
-
reset_email_template.html_body =
|
44
|
-
reset_email_template.mime_type =
|
35
|
+
reset_email_template.name = 'Default Password Reset Template'
|
36
|
+
reset_email_template.description = 'This is the password reset email template'
|
37
|
+
reset_email_template.subject = 'Please reset your password'
|
38
|
+
reset_email_template.from_email_address = "email#{default_domain}"
|
39
|
+
reset_email_template.text_body = 'You forgot your password! ${sptoken}'
|
40
|
+
reset_email_template.html_body = '<p> You forgot your password! </p> ${sptoken}'
|
41
|
+
reset_email_template.mime_type = 'text/plain'
|
45
42
|
|
46
43
|
reset_email_template.save
|
47
44
|
|
48
45
|
reloaded_reset_email_template = password_policy.reset_email_templates.first
|
49
46
|
|
50
|
-
expect(reloaded_reset_email_template.name).to eq(
|
51
|
-
expect(reloaded_reset_email_template.description).to eq(
|
52
|
-
expect(reloaded_reset_email_template.subject).to eq(
|
53
|
-
expect(reloaded_reset_email_template.from_email_address).to eq("email
|
54
|
-
expect(reloaded_reset_email_template.text_body).to eq(
|
55
|
-
expect(reloaded_reset_email_template.html_body).to eq(
|
56
|
-
expect(reloaded_reset_email_template.mime_type).to eq(
|
47
|
+
expect(reloaded_reset_email_template.name).to eq('Default Password Reset Template')
|
48
|
+
expect(reloaded_reset_email_template.description).to eq('This is the password reset email template')
|
49
|
+
expect(reloaded_reset_email_template.subject).to eq('Please reset your password')
|
50
|
+
expect(reloaded_reset_email_template.from_email_address).to eq("email#{default_domain}")
|
51
|
+
expect(reloaded_reset_email_template.text_body).to eq('You forgot your password! ${sptoken}')
|
52
|
+
expect(reloaded_reset_email_template.html_body).to eq('<p> You forgot your password! </p> ${sptoken}')
|
53
|
+
expect(reloaded_reset_email_template.mime_type).to eq('text/plain')
|
57
54
|
end
|
58
55
|
end
|
59
56
|
end
|
@@ -1,28 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Stormpath::Resource::GroupMembership, :vcr do
|
4
|
-
it
|
4
|
+
it 'should be the same as AccountMembership' do
|
5
5
|
expect(Stormpath::Resource::GroupMembership).to eq(Stormpath::Resource::AccountMembership)
|
6
6
|
end
|
7
7
|
|
8
8
|
describe '#add_account' do
|
9
|
-
context
|
10
|
-
|
11
|
-
let(:
|
12
|
-
|
13
|
-
let(:group) { directory.groups.create name: 'someGroup' }
|
14
|
-
|
15
|
-
let(:account) { directory.accounts.create({ email: 'rubysdk@example.com', given_name: 'Ruby SDK', password: 'P@$$w0rd', surname: 'SDK' }) }
|
9
|
+
context 'given an account and a group' do
|
10
|
+
let(:directory) { test_api_client.directories.create(build_directory) }
|
11
|
+
let(:group) { directory.groups.create(build_group) }
|
12
|
+
let(:account) { directory.accounts.create(build_account) }
|
16
13
|
|
17
14
|
before { group.add_account account }
|
18
15
|
|
19
16
|
after do
|
20
|
-
group.delete
|
21
|
-
|
22
|
-
|
17
|
+
group.delete
|
18
|
+
account.delete
|
19
|
+
directory.delete
|
23
20
|
end
|
24
21
|
|
25
|
-
it
|
22
|
+
it 'group membership and account membership should correspond to each other' do
|
26
23
|
expect(group.account_memberships.count).to eq(1)
|
27
24
|
expect(account.group_memberships.count).to eq(1)
|
28
25
|
expect(group.accounts).to include(account)
|
data/spec/resource/group_spec.rb
CHANGED
@@ -1,26 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Stormpath::Resource::Group, :vcr do
|
4
|
+
let(:directory) { test_api_client.directories.create(build_directory) }
|
5
|
+
after { directory.delete }
|
4
6
|
|
5
|
-
describe
|
6
|
-
let(:
|
7
|
+
describe 'instances should respond to attribute property methods' do
|
8
|
+
let(:group) { directory.groups.create name: 'RubyTestGroup', description: 'testDescription' }
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
after do
|
11
|
-
group.delete if group
|
12
|
-
end
|
10
|
+
after { group.delete }
|
13
11
|
|
14
12
|
it do
|
15
13
|
[:name, :description, :status].each do |property_accessor|
|
16
14
|
expect(group).to respond_to(property_accessor)
|
17
15
|
expect(group).to respond_to("#{property_accessor}=")
|
18
|
-
expect(group.send
|
16
|
+
expect(group.send(property_accessor)).to be_a String
|
19
17
|
end
|
20
18
|
|
21
19
|
[:created_at, :modified_at].each do |property_getter|
|
22
20
|
expect(group).to respond_to(property_getter)
|
23
|
-
expect(group.send
|
21
|
+
expect(group.send(property_getter)).to be_a String
|
24
22
|
end
|
25
23
|
|
26
24
|
expect(group.tenant).to be_a Stormpath::Resource::Tenant
|
@@ -32,36 +30,27 @@ describe Stormpath::Resource::Group, :vcr do
|
|
32
30
|
end
|
33
31
|
|
34
32
|
describe '#create_group_with_custom_data' do
|
35
|
-
let(:directory) { test_directory }
|
36
|
-
|
37
33
|
it 'creates a directory with custom data' do
|
38
|
-
directory.custom_data[
|
34
|
+
directory.custom_data['category'] = 'classified'
|
39
35
|
|
40
36
|
directory.save
|
41
|
-
expect(directory.custom_data[
|
37
|
+
expect(directory.custom_data['category']).to eq('classified')
|
42
38
|
end
|
43
39
|
end
|
44
40
|
|
45
41
|
describe '#add_or_remove_account' do
|
46
|
-
context
|
47
|
-
|
48
|
-
let(:
|
49
|
-
|
50
|
-
let(:group) { directory.groups.create name: 'someGroup' }
|
42
|
+
context 'given an account' do
|
43
|
+
let(:group) { directory.groups.create(build_group) }
|
44
|
+
let(:account) { directory.accounts.create(build_account) }
|
51
45
|
|
52
|
-
|
53
|
-
|
54
|
-
before do
|
55
|
-
group.add_account account
|
56
|
-
end
|
46
|
+
before { group.add_account(account) }
|
57
47
|
|
58
48
|
after do
|
59
|
-
group.delete
|
60
|
-
|
61
|
-
account.delete if account
|
49
|
+
group.delete
|
50
|
+
account.delete
|
62
51
|
end
|
63
52
|
|
64
|
-
it
|
53
|
+
it 'adds the account to the group' do
|
65
54
|
expect(group.accounts).to include(account)
|
66
55
|
end
|
67
56
|
|
@@ -71,12 +60,9 @@ describe Stormpath::Resource::Group, :vcr do
|
|
71
60
|
|
72
61
|
it 'adds and removes the group from the account' do
|
73
62
|
expect(group.accounts).to include(account)
|
74
|
-
|
75
|
-
group.remove_account account
|
76
|
-
|
63
|
+
group.remove_account(account)
|
77
64
|
expect(group.accounts).not_to include(account)
|
78
65
|
end
|
79
|
-
|
80
66
|
end
|
81
67
|
end
|
82
68
|
end
|
@@ -7,28 +7,15 @@ describe Stormpath::Resource::LinkedAccount, :vcr do
|
|
7
7
|
let(:directory1) { test_api_client.directories.create(name: 'ruby sdk dir 1') }
|
8
8
|
let(:directory2) { test_api_client.directories.create(name: 'ruby sdk dir 2') }
|
9
9
|
let(:account1) do
|
10
|
-
directory1.accounts.create(build_account(email: 'jekyll
|
10
|
+
directory1.accounts.create(build_account(email: 'jekyll', username: 'jekyll'))
|
11
11
|
end
|
12
12
|
let(:account2) do
|
13
|
-
directory2.accounts.create(build_account(email: 'hyde
|
13
|
+
directory2.accounts.create(build_account(email: 'hyde', username: 'hyde'))
|
14
14
|
end
|
15
15
|
|
16
16
|
before do
|
17
|
-
|
18
|
-
|
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
|
-
)
|
17
|
+
map_account_store(application, directory1, 1, true, false)
|
18
|
+
map_account_store(application, directory2, 2, false, false)
|
32
19
|
|
33
20
|
test_api_client.account_links.create(
|
34
21
|
left_account: {
|
@@ -1,36 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Stormpath::Resource::Organization, :vcr do
|
4
|
-
|
5
4
|
let(:organization) do
|
6
|
-
test_api_client.organizations.create
|
7
|
-
|
5
|
+
test_api_client.organizations.create(build_organization(name: 'test_ruby_organization',
|
6
|
+
name_key: 'testorganization',
|
7
|
+
description: 'test organization'))
|
8
8
|
end
|
9
9
|
|
10
|
-
after
|
11
|
-
organization.delete if organization
|
12
|
-
end
|
10
|
+
after { organization.delete if organization }
|
13
11
|
|
14
|
-
|
15
|
-
test_api_client.organization_account_store_mappings.create(
|
16
|
-
account_store: { href: account_store.href },
|
17
|
-
organization: { href: organization.href },
|
18
|
-
is_default_account_store: options[:default_account_store] || false,
|
19
|
-
is_default_group_store: options[:default_group_store] || false
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "instances should respond to attribute property methods" do
|
12
|
+
describe 'instances should respond to attribute property methods' do
|
24
13
|
it do
|
25
14
|
[:name, :description, :name_key, :status].each do |property_accessor|
|
26
15
|
expect(organization).to respond_to(property_accessor)
|
27
16
|
expect(organization).to respond_to("#{property_accessor}=")
|
28
|
-
expect(organization.send
|
17
|
+
expect(organization.send(property_accessor)).to be_a String
|
29
18
|
end
|
30
19
|
|
31
20
|
[:created_at, :modified_at].each do |property_getter|
|
32
21
|
expect(organization).to respond_to(property_getter)
|
33
|
-
expect(organization.send
|
22
|
+
expect(organization.send(property_getter)).to be_a String
|
34
23
|
end
|
35
24
|
|
36
25
|
expect(organization.tenant).to be_a Stormpath::Resource::Tenant
|
@@ -41,7 +30,7 @@ describe Stormpath::Resource::Organization, :vcr do
|
|
41
30
|
end
|
42
31
|
|
43
32
|
describe 'get resource' do
|
44
|
-
let(:fetched_organization) { test_api_client.organizations.get
|
33
|
+
let(:fetched_organization) { test_api_client.organizations.get(organization.href) }
|
45
34
|
|
46
35
|
it 'returns the organization resource with correct attribute properties' do
|
47
36
|
expect(fetched_organization).to be_kind_of(Stormpath::Resource::Organization)
|
@@ -50,8 +39,10 @@ describe Stormpath::Resource::Organization, :vcr do
|
|
50
39
|
expect(fetched_organization.name_key).to eq(organization.name_key)
|
51
40
|
expect(fetched_organization.status).to eq(organization.status)
|
52
41
|
expect(fetched_organization.account_store_mappings).to eq(organization.account_store_mappings)
|
53
|
-
expect(fetched_organization.default_account_store_mapping)
|
54
|
-
|
42
|
+
expect(fetched_organization.default_account_store_mapping)
|
43
|
+
.to eq(organization.default_account_store_mapping)
|
44
|
+
expect(fetched_organization.default_group_store_mapping)
|
45
|
+
.to eq(organization.default_group_store_mapping)
|
55
46
|
end
|
56
47
|
|
57
48
|
it 'returns custom_data' do
|
@@ -61,30 +52,23 @@ describe Stormpath::Resource::Organization, :vcr do
|
|
61
52
|
|
62
53
|
describe 'create' do
|
63
54
|
context 'invalid data' do
|
55
|
+
before { organization }
|
56
|
+
|
64
57
|
it 'should raise Stormpath::Error' do
|
65
58
|
expect do
|
66
|
-
test_api_client.organizations.create
|
67
|
-
name_key: "test_org"
|
59
|
+
test_api_client.organizations.create(build_organization(name_key: 'testorganization'))
|
68
60
|
end.to raise_error(Stormpath::Error)
|
69
61
|
end
|
70
62
|
end
|
71
63
|
end
|
72
64
|
|
73
65
|
describe 'associations' do
|
74
|
-
|
75
|
-
|
76
|
-
let(:directory) { test_api_client.directories.create name: random_directory_name }
|
77
|
-
|
78
|
-
let(:group) { directory.groups.create name: "test_group" }
|
79
|
-
|
80
|
-
before do
|
81
|
-
create_organization_account_store_mapping(organization, group)
|
82
|
-
end
|
66
|
+
let(:directory) { test_api_client.directories.create(build_directory) }
|
67
|
+
after { directory.delete }
|
83
68
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
69
|
+
context 'groups' do
|
70
|
+
let(:group) { directory.groups.create(name: 'test_group') }
|
71
|
+
before { map_organization_store(group, organization) }
|
88
72
|
|
89
73
|
it 'returns a collection of groups' do
|
90
74
|
expect(organization.groups).to be_kind_of(Stormpath::Resource::Collection)
|
@@ -93,35 +77,10 @@ describe Stormpath::Resource::Organization, :vcr do
|
|
93
77
|
end
|
94
78
|
|
95
79
|
context 'accounts' do
|
96
|
-
let(:
|
97
|
-
|
98
|
-
let(:account) do
|
99
|
-
directory.accounts.create(
|
100
|
-
email: 'rubysdk@example.com',
|
101
|
-
given_name: 'Ruby SDK',
|
102
|
-
password: 'P@$$w0rd',
|
103
|
-
surname: 'SDK'
|
104
|
-
)
|
105
|
-
end
|
106
|
-
let(:org_account) do
|
107
|
-
organization.accounts.create(
|
108
|
-
email: 'rubysdk2@example.com',
|
109
|
-
given_name: 'Ruby SDK',
|
110
|
-
password: 'P@$$w0rd',
|
111
|
-
surname: 'SDK'
|
112
|
-
)
|
113
|
-
end
|
80
|
+
let(:account) { directory.accounts.create(build_account(email: 'rubysdk')) }
|
81
|
+
let(:org_account) { directory.accounts.create(build_account(email: 'rubysdk2')) }
|
114
82
|
|
115
|
-
before
|
116
|
-
create_organization_account_store_mapping(organization,
|
117
|
-
directory,
|
118
|
-
default_account_store: true)
|
119
|
-
end
|
120
|
-
|
121
|
-
after do
|
122
|
-
organization.delete if organization
|
123
|
-
directory.delete if directory
|
124
|
-
end
|
83
|
+
before { map_organization_store(directory, organization, true) }
|
125
84
|
|
126
85
|
it 'returns a collection of accounts' do
|
127
86
|
expect(organization.accounts).to be_kind_of(Stormpath::Resource::Collection)
|
@@ -140,16 +99,7 @@ describe Stormpath::Resource::Organization, :vcr do
|
|
140
99
|
end
|
141
100
|
|
142
101
|
context 'tenant' do
|
143
|
-
|
144
|
-
|
145
|
-
before do
|
146
|
-
create_organization_account_store_mapping(organization, directory)
|
147
|
-
end
|
148
|
-
|
149
|
-
after do
|
150
|
-
organization.delete if organization
|
151
|
-
directory.delete if directory
|
152
|
-
end
|
102
|
+
before { map_organization_store(directory, organization) }
|
153
103
|
|
154
104
|
it 'returns tenant' do
|
155
105
|
expect(organization.tenant).to eq(directory.tenant)
|
@@ -159,45 +109,33 @@ describe Stormpath::Resource::Organization, :vcr do
|
|
159
109
|
|
160
110
|
describe 'delete' do
|
161
111
|
let(:href) { organization.href }
|
162
|
-
|
163
|
-
before do
|
164
|
-
organization.delete
|
165
|
-
end
|
112
|
+
before { organization.delete }
|
166
113
|
|
167
114
|
it 'removes the organization' do
|
168
|
-
expect
|
169
|
-
test_api_client.organizations.get href
|
170
|
-
end.to raise_error(Stormpath::Error)
|
115
|
+
expect { test_api_client.organizations.get(href) }.to raise_error(Stormpath::Error)
|
171
116
|
end
|
172
117
|
end
|
173
118
|
|
174
119
|
describe 'update' do
|
175
120
|
before do
|
176
|
-
organization.name_key =
|
121
|
+
organization.name_key = 'changed-test-organization'
|
177
122
|
organization.save
|
178
123
|
end
|
179
124
|
|
180
125
|
it 'can change the data of the existing organization' do
|
181
|
-
org = test_api_client.organizations.get
|
182
|
-
expect(org.name_key).to eq(
|
126
|
+
org = test_api_client.organizations.get(organization.href)
|
127
|
+
expect(org.name_key).to eq('changed-test-organization')
|
183
128
|
end
|
184
129
|
end
|
185
130
|
|
186
131
|
describe 'organization account store mapping' do
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
let(:organization_account_store_mapping) do
|
191
|
-
create_organization_account_store_mapping(organization, directory)
|
192
|
-
end
|
132
|
+
let(:directory) { test_api_client.directories.create(build_directory) }
|
133
|
+
after { directory.delete }
|
193
134
|
|
135
|
+
context 'given an account_store is a directory' do
|
136
|
+
let(:organization_account_store_mapping) { map_organization_store(directory, organization) }
|
194
137
|
let(:reloaded_mapping) do
|
195
|
-
test_api_client.account_store_mappings.get
|
196
|
-
end
|
197
|
-
|
198
|
-
after do
|
199
|
-
organization.delete if organization
|
200
|
-
directory.delete if directory
|
138
|
+
test_api_client.account_store_mappings.get(organization_account_store_mapping.href)
|
201
139
|
end
|
202
140
|
|
203
141
|
it 'should return a directory' do
|
@@ -207,23 +145,13 @@ describe Stormpath::Resource::Organization, :vcr do
|
|
207
145
|
end
|
208
146
|
|
209
147
|
context 'given an account_store is a group' do
|
210
|
-
let(:
|
211
|
-
|
212
|
-
let(:group) { directory.groups.create name: "test_group" }
|
213
|
-
|
214
|
-
let(:organization_account_store_mapping) do
|
215
|
-
create_organization_account_store_mapping(organization, group)
|
216
|
-
end
|
217
|
-
|
148
|
+
let(:group) { directory.groups.create(name: 'test_group') }
|
149
|
+
let(:organization_account_store_mapping) { map_organization_store(group, organization) }
|
218
150
|
let(:reloaded_mapping) do
|
219
|
-
test_api_client.account_store_mappings.get
|
151
|
+
test_api_client.account_store_mappings.get(organization_account_store_mapping.href)
|
220
152
|
end
|
221
153
|
|
222
|
-
after
|
223
|
-
organization.delete if organization
|
224
|
-
group.delete if group
|
225
|
-
directory.delete if directory
|
226
|
-
end
|
154
|
+
after { group.delete }
|
227
155
|
|
228
156
|
it 'should return group' do
|
229
157
|
expect(reloaded_mapping.account_store.class).to eq(Stormpath::Resource::Group)
|