stormpath-sdk 1.0.0.beta.6 → 1.0.0.beta.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -0
- data/CHANGES.md +10 -0
- data/lib/stormpath-sdk.rb +15 -0
- data/lib/stormpath-sdk/data_store.rb +30 -14
- data/lib/stormpath-sdk/http/request.rb +5 -25
- data/lib/stormpath-sdk/http/response.rb +0 -5
- data/lib/stormpath-sdk/provider/account_access.rb +28 -0
- data/lib/stormpath-sdk/provider/account_request.rb +30 -0
- data/lib/stormpath-sdk/provider/account_resolver.rb +43 -0
- data/lib/stormpath-sdk/provider/account_result.rb +27 -0
- data/lib/stormpath-sdk/provider/facebook/facebook_provider.rb +18 -0
- data/lib/stormpath-sdk/provider/facebook/facebook_provider_data.rb +18 -0
- data/lib/stormpath-sdk/provider/google/google_provider.rb +18 -0
- data/lib/stormpath-sdk/provider/google/google_provider_data.rb +19 -0
- data/lib/stormpath-sdk/provider/provider.rb +18 -0
- data/lib/stormpath-sdk/provider/provider_data.rb +18 -0
- data/lib/stormpath-sdk/provider/stormpath/stormpath_provider.rb +17 -0
- data/lib/stormpath-sdk/provider/stormpath/stormpath_provider_data.rb +17 -0
- data/lib/stormpath-sdk/resource/account.rb +15 -0
- data/lib/stormpath-sdk/resource/application.rb +5 -2
- data/lib/stormpath-sdk/resource/associations.rb +7 -5
- data/lib/stormpath-sdk/resource/directory.rb +15 -0
- data/lib/stormpath-sdk/version.rb +2 -2
- data/spec/auth/basic_authenticator_spec.rb +5 -5
- data/spec/cache/cache_entry_spec.rb +3 -3
- data/spec/client_spec.rb +27 -20
- data/spec/provider/account_resolver_spec.rb +25 -0
- data/spec/provider/provider_spec.rb +152 -0
- data/spec/resource/account_spec.rb +26 -30
- data/spec/resource/account_store_mapping_spec.rb +28 -27
- data/spec/resource/account_store_spec.rb +7 -7
- data/spec/resource/application_spec.rb +34 -26
- data/spec/resource/collection_spec.rb +34 -34
- data/spec/resource/custom_data_spec.rb +2 -2
- data/spec/resource/directory_spec.rb +25 -23
- data/spec/resource/group_membership_spec.rb +3 -3
- data/spec/resource/group_spec.rb +16 -17
- data/spec/resource/status_spec.rb +16 -16
- data/spec/resource/tenant_spec.rb +10 -8
- data/spec/spec_helper.rb +37 -18
- data/spec/support/custom_data_storage_behavior.rb +19 -19
- data/spec/support/mocked_provider_accounts.rb +72 -0
- data/stormpath-sdk.gemspec +5 -9
- metadata +104 -111
- checksums.yaml +0 -7
@@ -1,16 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'pry-debugger'
|
3
2
|
|
4
3
|
describe Stormpath::Resource::Account, :vcr do
|
5
4
|
|
6
|
-
describe "instances" do
|
7
|
-
let(:directory) { test_api_client.directories.create name:
|
8
|
-
|
5
|
+
describe "instances should respond to attribute property methods" do
|
6
|
+
let(:directory) { test_api_client.directories.create name: random_directory_name }
|
9
7
|
let(:given_name) { 'Ruby SDK' }
|
10
8
|
let(:middle_name) { 'Gruby' }
|
11
9
|
let(:surname) { 'SDK' }
|
12
|
-
|
13
|
-
subject(:account) do
|
10
|
+
let(:account) do
|
14
11
|
directory.accounts.create email: 'test@example.com',
|
15
12
|
given_name: given_name,
|
16
13
|
password: 'P@$$w0rd',
|
@@ -19,36 +16,35 @@ describe Stormpath::Resource::Account, :vcr do
|
|
19
16
|
username: 'rubysdk'
|
20
17
|
end
|
21
18
|
|
22
|
-
[:given_name, :username, :middle_name, :surname, :email, :status].each do |property_accessor|
|
23
|
-
it { should respond_to property_accessor }
|
24
|
-
it { should respond_to "#{property_accessor}=" }
|
25
|
-
its(property_accessor) { should be_instance_of String }
|
26
|
-
end
|
27
|
-
|
28
|
-
it {should respond_to :full_name}
|
29
|
-
its(:full_name) { should be_instance_of String}
|
30
|
-
its(:full_name) { should eq("#{given_name} #{middle_name} #{surname}")}
|
31
|
-
|
32
|
-
it {should respond_to "password="}
|
33
|
-
|
34
|
-
its(:tenant) { should be_instance_of Stormpath::Resource::Tenant }
|
35
|
-
its(:directory) { should be_instance_of Stormpath::Resource::Directory }
|
36
|
-
its(:custom_data) { should be_instance_of Stormpath::Resource::CustomData }
|
37
|
-
its(:email_verification_token) { should be_nil }
|
38
|
-
|
39
|
-
its(:groups) { should be_instance_of Stormpath::Resource::Collection }
|
40
|
-
its(:group_memberships) { should be_instance_of Stormpath::Resource::Collection }
|
41
|
-
|
42
19
|
after do
|
43
20
|
account.delete if account
|
44
21
|
directory.delete if directory
|
45
22
|
end
|
46
23
|
|
24
|
+
it do
|
25
|
+
[:given_name, :username, :middle_name, :surname, :email, :status].each do |property_accessor|
|
26
|
+
expect(account).to respond_to(property_accessor)
|
27
|
+
expect(account).to respond_to("#{property_accessor}=")
|
28
|
+
expect(account.send property_accessor).to be_a String
|
29
|
+
end
|
30
|
+
|
31
|
+
expect(account).to respond_to(:full_name)
|
32
|
+
expect(account.full_name).to be_a String
|
33
|
+
expect(account.full_name).to eq("#{given_name} #{middle_name} #{surname}")
|
34
|
+
expect(account).to respond_to("password=")
|
35
|
+
|
36
|
+
expect(account.tenant).to be_a Stormpath::Resource::Tenant
|
37
|
+
expect(account.directory).to be_a Stormpath::Resource::Directory
|
38
|
+
expect(account.custom_data).to be_a Stormpath::Resource::CustomData
|
39
|
+
expect(account.email_verification_token).to be_nil
|
40
|
+
expect(account.groups).to be_a Stormpath::Resource::Collection
|
41
|
+
expect(account.group_memberships).to be_a Stormpath::Resource::Collection
|
42
|
+
end
|
47
43
|
end
|
48
44
|
|
49
45
|
describe 'account_associations' do
|
50
|
-
let(:directory) { test_api_client.directories.create name:
|
51
|
-
|
46
|
+
let(:directory) { test_api_client.directories.create name: random_directory_name }
|
47
|
+
|
52
48
|
let(:account) do
|
53
49
|
directory.accounts.create email: 'test@example.com',
|
54
50
|
givenName: 'Ruby SDK',
|
@@ -74,7 +70,7 @@ describe Stormpath::Resource::Account, :vcr do
|
|
74
70
|
|
75
71
|
describe "#add_or_remove_group" do
|
76
72
|
context "given a group" do
|
77
|
-
let(:directory) { test_api_client.directories.create name:
|
73
|
+
let(:directory) { test_api_client.directories.create name: random_directory_name }
|
78
74
|
|
79
75
|
let(:group) { directory.groups.create name: 'testGroup' }
|
80
76
|
|
@@ -93,7 +89,7 @@ describe Stormpath::Resource::Account, :vcr do
|
|
93
89
|
end
|
94
90
|
|
95
91
|
it 'has one group membership resource' do
|
96
|
-
expect(account.group_memberships).to
|
92
|
+
expect(account.group_memberships.count).to eq(1)
|
97
93
|
end
|
98
94
|
|
99
95
|
it 'adds and removes the group from the account' do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Stormpath::Resource::AccountStoreMapping, :vcr do
|
4
|
-
|
4
|
+
|
5
5
|
def create_account_store_mapping(application, account_store, options={})
|
6
6
|
test_api_client.account_store_mappings.create({
|
7
7
|
application: application,
|
@@ -12,38 +12,41 @@ describe Stormpath::Resource::AccountStoreMapping, :vcr do
|
|
12
12
|
})
|
13
13
|
end
|
14
14
|
|
15
|
-
let(:
|
16
|
-
|
17
|
-
let(:
|
18
|
-
|
15
|
+
let(:directory_name) { random_directory_name }
|
16
|
+
|
17
|
+
let(:directory) { test_api_client.directories.create name: directory_name, description: 'testDirectory for AccountStoreMappings' }
|
18
|
+
|
19
|
+
let(:application) { test_api_client.applications.create name: random_application_name, description: 'testApplication for AccountStoreMappings' }
|
20
|
+
|
19
21
|
after do
|
20
22
|
application.delete if application
|
21
23
|
directory.delete if directory
|
22
24
|
end
|
23
|
-
|
24
|
-
describe "instances" do
|
25
|
-
subject(:account_store_mapping) {create_account_store_mapping(application,directory, is_default_account_store: true)}
|
26
|
-
|
27
|
-
[:list_index, :is_default_account_store, :is_default_group_store, :default_account_store, :default_group_store ].each do |prop_accessor|
|
28
|
-
it { should respond_to prop_accessor }
|
29
|
-
it { should respond_to "#{prop_accessor}=" }
|
30
|
-
end
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
end
|
26
|
+
describe "instances" do
|
27
|
+
let(:account_store_mapping) {create_account_store_mapping(application,directory, is_default_account_store: true)}
|
35
28
|
|
36
|
-
|
29
|
+
it do
|
30
|
+
[:list_index, :is_default_account_store, :is_default_group_store, :default_account_store, :default_group_store ].each do |prop_accessor|
|
31
|
+
expect(account_store_mapping).to respond_to(prop_accessor)
|
32
|
+
expect(account_store_mapping).to respond_to("#{prop_accessor}=")
|
33
|
+
end
|
37
34
|
|
38
|
-
|
39
|
-
|
40
|
-
its(specific_store_method) {should satisfy {|attribute| [TrueClass, FalseClass].include? attribute.class }}
|
35
|
+
[:default_account_store?, :default_group_store?].each do |prop_getter|
|
36
|
+
expect(account_store_mapping).to respond_to(prop_getter)
|
41
37
|
end
|
42
|
-
end
|
43
38
|
|
44
|
-
|
39
|
+
expect(account_store_mapping.list_index).to be_a Fixnum
|
40
|
+
|
41
|
+
[:default_account_store, :default_group_store].each do |default_store_method|
|
42
|
+
[default_store_method, "is_#{default_store_method}", "#{default_store_method}?"].each do |specific_store_method|
|
43
|
+
expect(account_store_mapping.send specific_store_method).to be_boolean
|
44
|
+
end
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
+
expect(account_store_mapping.account_store).to be_a Stormpath::Resource::Directory
|
48
|
+
expect(account_store_mapping.application).to be_a Stormpath::Resource::Application
|
49
|
+
end
|
47
50
|
end
|
48
51
|
|
49
52
|
|
@@ -159,7 +162,6 @@ describe Stormpath::Resource::AccountStoreMapping, :vcr do
|
|
159
162
|
account_store_mapping.save
|
160
163
|
expect(reloaded_mapping.is_default_account_store).to eq(false)
|
161
164
|
end
|
162
|
-
|
163
165
|
end
|
164
166
|
|
165
167
|
describe "given a mapping" do
|
@@ -171,16 +173,15 @@ describe Stormpath::Resource::AccountStoreMapping, :vcr do
|
|
171
173
|
account_store_mapping.delete
|
172
174
|
expect(reloaded_application.account_store_mappings.count).to eq(0)
|
173
175
|
end
|
174
|
-
|
176
|
+
|
175
177
|
it 'should be able to list its attributes' do
|
176
178
|
reloaded_application.account_store_mappings.each do |account_store_mapping|
|
177
|
-
expect(account_store_mapping.account_store.name).to eq(
|
179
|
+
expect(account_store_mapping.account_store.name).to eq(directory_name)
|
178
180
|
expect(account_store_mapping.list_index).to eq(0)
|
179
181
|
expect(account_store_mapping.default_account_store?).to eq(true)
|
180
182
|
expect(account_store_mapping.default_group_store?).to eq(false)
|
181
183
|
end
|
182
184
|
end
|
183
|
-
|
184
185
|
end
|
185
186
|
|
186
187
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Stormpath::Resource::AccountStore, :vcr do
|
4
|
-
|
4
|
+
|
5
5
|
def create_account_store_mapping(application, account_store, is_default_group_store=false)
|
6
6
|
test_api_client.account_store_mappings.create({
|
7
7
|
application: application,
|
@@ -11,13 +11,13 @@ describe Stormpath::Resource::AccountStore, :vcr do
|
|
11
11
|
is_default_group_store: is_default_group_store
|
12
12
|
})
|
13
13
|
end
|
14
|
-
|
15
|
-
let(:application) { test_api_client.applications.create name:
|
16
|
-
|
17
|
-
let(:directory) { test_api_client.directories.create name:
|
18
|
-
|
14
|
+
|
15
|
+
let(:application) { test_api_client.applications.create name: random_application_name, description: 'testApplication for AccountStoreMappings' }
|
16
|
+
|
17
|
+
let(:directory) { test_api_client.directories.create name: random_directory_name, description: 'testDirectory for AccountStoreMappings' }
|
18
|
+
|
19
19
|
let(:group) { directory.groups.create name: 'testGroup', description: 'testGroup for AccountStoreMappings' }
|
20
|
-
|
20
|
+
|
21
21
|
after do
|
22
22
|
application.delete if application
|
23
23
|
group.delete if group
|
@@ -1,30 +1,38 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Stormpath::Resource::Application, :vcr do
|
4
|
-
let(:
|
5
|
-
let(:
|
4
|
+
let(:app) { test_api_client.applications.create name: random_application_name, description: 'Dummy desc.' }
|
5
|
+
let(:application) { test_api_client.applications.get app.href }
|
6
|
+
let(:directory) { test_api_client.directories.create name: random_directory_name }
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
before do
|
9
|
+
test_api_client.account_store_mappings.create({ application: app, account_store: directory,
|
10
|
+
list_index: 1, is_default_account_store: true, is_default_group_store: true })
|
11
|
+
end
|
9
12
|
|
10
|
-
|
13
|
+
after do
|
14
|
+
application.delete if application
|
15
|
+
directory.delete if directory
|
16
|
+
end
|
11
17
|
|
12
|
-
|
13
|
-
it { should respond_to property_accessor }
|
14
|
-
it { should respond_to "#{property_accessor}="}
|
15
|
-
its(property_accessor) { should be_instance_of String }
|
16
|
-
end
|
18
|
+
it "instances should respond to attribute property methods" do
|
17
19
|
|
18
|
-
|
19
|
-
its(:default_account_store_mapping) { should be_instance_of Stormpath::Resource::AccountStoreMapping }
|
20
|
-
its(:default_group_store_mapping) { should be_instance_of Stormpath::Resource::AccountStoreMapping }
|
20
|
+
expect(application).to be_a Stormpath::Resource::Application
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
[:name, :description, :status].each do |property_accessor|
|
23
|
+
expect(application).to respond_to(property_accessor)
|
24
|
+
expect(application).to respond_to("#{property_accessor}=")
|
25
|
+
expect(application.send property_accessor).to be_a String
|
26
|
+
end
|
26
27
|
|
28
|
+
expect(application.tenant).to be_a Stormpath::Resource::Tenant
|
29
|
+
expect(application.default_account_store_mapping).to be_a Stormpath::Resource::AccountStoreMapping
|
30
|
+
expect(application.default_group_store_mapping).to be_a Stormpath::Resource::AccountStoreMapping
|
27
31
|
|
32
|
+
expect(application.groups).to be_a Stormpath::Resource::Collection
|
33
|
+
expect(application.accounts).to be_a Stormpath::Resource::Collection
|
34
|
+
expect(application.password_reset_tokens).to be_a Stormpath::Resource::Collection
|
35
|
+
expect(application.account_store_mappings).to be_a Stormpath::Resource::Collection
|
28
36
|
end
|
29
37
|
|
30
38
|
describe '.load' do
|
@@ -69,7 +77,7 @@ describe Stormpath::Resource::Application, :vcr do
|
|
69
77
|
end
|
70
78
|
|
71
79
|
context '#groups' do
|
72
|
-
let(:group) { application.groups.create name:
|
80
|
+
let(:group) { application.groups.create name: random_group_name }
|
73
81
|
|
74
82
|
after do
|
75
83
|
group.delete if group
|
@@ -86,7 +94,7 @@ describe Stormpath::Resource::Application, :vcr do
|
|
86
94
|
end
|
87
95
|
|
88
96
|
end
|
89
|
-
|
97
|
+
|
90
98
|
describe '#authenticate_account' do
|
91
99
|
let(:account) do
|
92
100
|
directory.accounts.create build_account(password: 'P@$$w0rd')
|
@@ -132,10 +140,10 @@ describe Stormpath::Resource::Application, :vcr do
|
|
132
140
|
after do
|
133
141
|
account.delete if account
|
134
142
|
end
|
135
|
-
|
136
|
-
context 'given a proper directory' do
|
143
|
+
|
144
|
+
context 'given a proper directory' do
|
137
145
|
let(:account) { directory.accounts.create build_account(password: 'P@$$w0rd') }
|
138
|
-
|
146
|
+
|
139
147
|
let(:login_request) do
|
140
148
|
Stormpath::Authentication::UsernamePasswordRequest.new account.username, password, account_store: directory
|
141
149
|
end
|
@@ -149,7 +157,7 @@ describe Stormpath::Resource::Application, :vcr do
|
|
149
157
|
end
|
150
158
|
|
151
159
|
context 'given a wrong directory' do
|
152
|
-
let(:new_directory) { test_api_client.directories.create name: '
|
160
|
+
let(:new_directory) { test_api_client.directories.create name: random_directory_name('new') }
|
153
161
|
|
154
162
|
let(:account) { new_directory.accounts.create build_account(password: 'P@$$w0rd') }
|
155
163
|
|
@@ -167,7 +175,7 @@ describe Stormpath::Resource::Application, :vcr do
|
|
167
175
|
end
|
168
176
|
|
169
177
|
context 'given a group' do
|
170
|
-
let(:group) {directory.groups.create name:
|
178
|
+
let(:group) {directory.groups.create name: random_group_name }
|
171
179
|
|
172
180
|
let(:account) { directory.accounts.create build_account(password: 'P@$$w0rd') }
|
173
181
|
|
@@ -229,11 +237,11 @@ describe Stormpath::Resource::Application, :vcr do
|
|
229
237
|
describe '#verify_password_reset_token' do
|
230
238
|
let(:account) do
|
231
239
|
directory.accounts.create({
|
232
|
-
email:
|
240
|
+
email: random_email,
|
233
241
|
given_name: 'Ruby SDK',
|
234
242
|
password: 'P@$$w0rd',
|
235
243
|
surname: 'SDK',
|
236
|
-
username:
|
244
|
+
username: random_user_name
|
237
245
|
})
|
238
246
|
end
|
239
247
|
|
@@ -169,7 +169,7 @@ describe Stormpath::Resource::Collection, :vcr do
|
|
169
169
|
|
170
170
|
context 'live examples' do
|
171
171
|
context 'testing limits and offsets' do
|
172
|
-
let(:directory) {test_api_client.directories.create name:
|
172
|
+
let(:directory) {test_api_client.directories.create name: random_directory_name }
|
173
173
|
|
174
174
|
let(:groups) do
|
175
175
|
('A'..'Z').map do |letter|
|
@@ -182,21 +182,21 @@ describe Stormpath::Resource::Collection, :vcr do
|
|
182
182
|
end
|
183
183
|
|
184
184
|
it 'should respond as expected with or without limits' do
|
185
|
-
expect(groups).to
|
185
|
+
expect(groups.count).to eq(26)
|
186
186
|
|
187
|
-
expect(directory.groups.limit(3)).to
|
187
|
+
expect(directory.groups.limit(3).count).to eq(26)
|
188
188
|
|
189
|
-
expect(directory.groups.offset(10).limit(3)).to
|
189
|
+
expect(directory.groups.offset(10).limit(3).count).to eq(16)
|
190
190
|
|
191
|
-
expect(directory.groups.limit(3).offset(10)).to
|
191
|
+
expect(directory.groups.limit(3).offset(10).count).to eq(16)
|
192
192
|
|
193
|
-
expect(directory.groups).to
|
193
|
+
expect(directory.groups.count).to eq(26)
|
194
194
|
|
195
|
-
expect(directory.groups.limit(25)).to
|
195
|
+
expect(directory.groups.limit(25).count).to eq(26)
|
196
196
|
|
197
|
-
expect(directory.groups.limit(26)).to
|
197
|
+
expect(directory.groups.limit(26).count).to eq(26)
|
198
198
|
|
199
|
-
expect(directory.groups.limit(100)).to
|
199
|
+
expect(directory.groups.limit(100).count).to eq(26)
|
200
200
|
|
201
201
|
expect(directory.groups.limit(25)).to include(groups.last)
|
202
202
|
|
@@ -204,14 +204,14 @@ describe Stormpath::Resource::Collection, :vcr do
|
|
204
204
|
|
205
205
|
expect(directory.groups.offset(1).limit(25)).not_to include(groups.first)
|
206
206
|
|
207
|
-
expect(directory.groups.offset(25)).to
|
207
|
+
expect(directory.groups.offset(25).count).to eq(1)
|
208
208
|
|
209
|
-
expect(directory.groups.offset(26)).to
|
209
|
+
expect(directory.groups.offset(26).count).to eq(0)
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
213
|
context 'testing limits and offsets with name checking' do
|
214
|
-
let(:directory) {test_api_client.directories.create name:
|
214
|
+
let(:directory) {test_api_client.directories.create name: random_directory_name }
|
215
215
|
|
216
216
|
let!(:groups) do
|
217
217
|
('1'..'100').map do |number|
|
@@ -224,25 +224,25 @@ describe Stormpath::Resource::Collection, :vcr do
|
|
224
224
|
end
|
225
225
|
|
226
226
|
it 'should paginate properly' do
|
227
|
-
expect(directory.groups).to
|
227
|
+
expect(directory.groups.count).to eq(100)
|
228
228
|
|
229
229
|
expect(directory.groups.map {|group| group.name }).to eq(('1'..'100').to_a.sort)
|
230
230
|
|
231
|
-
expect(directory.groups.limit(30)).to
|
231
|
+
expect(directory.groups.limit(30).count).to eq(100)
|
232
232
|
|
233
|
-
expect(directory.groups.limit(30).current_page.items).to
|
233
|
+
expect(directory.groups.limit(30).current_page.items.count).to eq(30)
|
234
234
|
|
235
|
-
expect(directory.groups.limit(30).offset(30)).to
|
235
|
+
expect(directory.groups.limit(30).offset(30).count).to eq(70)
|
236
236
|
|
237
|
-
expect(directory.groups.limit(30).offset(30).current_page.items).to
|
237
|
+
expect(directory.groups.limit(30).offset(30).current_page.items.count).to eq(30)
|
238
238
|
|
239
|
-
expect(directory.groups.limit(30).offset(60)).to
|
239
|
+
expect(directory.groups.limit(30).offset(60).count).to eq(40)
|
240
240
|
|
241
|
-
expect(directory.groups.limit(30).offset(60).current_page.items).to
|
241
|
+
expect(directory.groups.limit(30).offset(60).current_page.items.count).to eq(30)
|
242
242
|
|
243
|
-
expect(directory.groups.limit(30).offset(90)).to
|
243
|
+
expect(directory.groups.limit(30).offset(90).count).to eq(10)
|
244
244
|
|
245
|
-
expect(directory.groups.limit(30).offset(90).current_page.items).to
|
245
|
+
expect(directory.groups.limit(30).offset(90).current_page.items.count).to eq(10)
|
246
246
|
|
247
247
|
expect(directory.groups.limit(30).map {|group| group.name }).to eq(('1'..'100').to_a.sort)
|
248
248
|
|
@@ -273,7 +273,7 @@ describe Stormpath::Resource::Collection, :vcr do
|
|
273
273
|
end
|
274
274
|
|
275
275
|
context '#wild characters search' do
|
276
|
-
let(:directory) {test_api_client.directories.create name:
|
276
|
+
let(:directory) {test_api_client.directories.create name: random_directory_name }
|
277
277
|
|
278
278
|
# !@#$%^&*()_-+=?><:]}[{'
|
279
279
|
# 'jlpicard/!@$%^*()_-+&=?><:]}[{'
|
@@ -292,24 +292,24 @@ describe Stormpath::Resource::Collection, :vcr do
|
|
292
292
|
end
|
293
293
|
|
294
294
|
it 'should search accounts by username' do
|
295
|
-
expect(directory.accounts.search(username: username)).to
|
295
|
+
expect(directory.accounts.search(username: username).count).to eq(1)
|
296
296
|
end
|
297
297
|
|
298
298
|
it 'should search accounts by any column (aiming at username)' do
|
299
|
-
expect(directory.accounts.search(username)).to
|
299
|
+
expect(directory.accounts.search(username).count).to eq(1)
|
300
300
|
end
|
301
301
|
|
302
302
|
it 'should search accounts by email' do
|
303
|
-
expect(directory.accounts.search(email: "capt@enterprise.com")).to
|
303
|
+
expect(directory.accounts.search(email: "capt@enterprise.com").count).to eq(1)
|
304
304
|
end
|
305
305
|
|
306
306
|
it 'should search accounts by any column (aiming at email)' do
|
307
|
-
expect(directory.accounts.search("capt@enterprise.com")).to
|
307
|
+
expect(directory.accounts.search("capt@enterprise.com").count).to eq(1)
|
308
308
|
end
|
309
309
|
end
|
310
310
|
|
311
311
|
context '#asterisk search on one attribute' do
|
312
|
-
let(:directory) {test_api_client.directories.create name:
|
312
|
+
let(:directory) {test_api_client.directories.create name: random_directory_name }
|
313
313
|
|
314
314
|
let!(:account) do
|
315
315
|
directory.accounts.create username: "jlpicard",
|
@@ -324,20 +324,20 @@ describe Stormpath::Resource::Collection, :vcr do
|
|
324
324
|
end
|
325
325
|
|
326
326
|
it 'should search accounts by username with asterisk at the beginning' do
|
327
|
-
expect(directory.accounts.search(username: "*card")).to
|
327
|
+
expect(directory.accounts.search(username: "*card").count).to eq(1)
|
328
328
|
end
|
329
329
|
|
330
330
|
it 'should search accounts by username with asterisk at the end' do
|
331
|
-
expect(directory.accounts.search(username: "jl*")).to
|
331
|
+
expect(directory.accounts.search(username: "jl*").count).to eq(1)
|
332
332
|
end
|
333
333
|
|
334
334
|
it 'should search accounts by username with asterisk at the beginning and the end' do
|
335
|
-
expect(directory.accounts.search(username: "*pic*")).to
|
335
|
+
expect(directory.accounts.search(username: "*pic*").count).to eq(1)
|
336
336
|
end
|
337
337
|
end
|
338
338
|
|
339
339
|
context '#asterisk search on multiple attribute' do
|
340
|
-
let(:directory) {test_api_client.directories.create name:
|
340
|
+
let(:directory) {test_api_client.directories.create name: random_directory_name }
|
341
341
|
|
342
342
|
let!(:account) do
|
343
343
|
directory.accounts.create username: "jlpicard",
|
@@ -352,15 +352,15 @@ describe Stormpath::Resource::Collection, :vcr do
|
|
352
352
|
end
|
353
353
|
|
354
354
|
it 'should search accounts by username with asterisk at the beginning' do
|
355
|
-
expect(directory.accounts.search(username: "*card", email: "*enterprise.com")).to
|
355
|
+
expect(directory.accounts.search(username: "*card", email: "*enterprise.com").count).to eq(1)
|
356
356
|
end
|
357
357
|
|
358
358
|
it 'should search accounts by username with asterisk at the end' do
|
359
|
-
expect(directory.accounts.search(username: "jl*", email: "capt*")).to
|
359
|
+
expect(directory.accounts.search(username: "jl*", email: "capt*").count).to eq(1)
|
360
360
|
end
|
361
361
|
|
362
362
|
it 'should search accounts by username with asterisk at the beginning and the end' do
|
363
|
-
expect(directory.accounts.search(username: "*pic*", email: "*enterprise*")).to
|
363
|
+
expect(directory.accounts.search(username: "*pic*", email: "*enterprise*").count).to eq(1)
|
364
364
|
end
|
365
365
|
end
|
366
366
|
|