stormpath-sdk 0.4.0 → 1.0.0.beta
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.
- data/.gitignore +6 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +27 -0
- data/CHANGES.md +21 -1
- data/Gemfile +1 -2
- data/README.md +457 -11
- data/Rakefile +15 -1
- data/lib/stormpath-sdk.rb +52 -33
- data/lib/stormpath-sdk/{resource/group_list.rb → api_key.rb} +5 -9
- data/lib/stormpath-sdk/auth/authentication_result.rb +3 -13
- data/lib/stormpath-sdk/auth/basic_authenticator.rb +5 -11
- data/lib/stormpath-sdk/auth/basic_login_attempt.rb +6 -8
- data/lib/stormpath-sdk/auth/username_password_request.rb +2 -5
- data/lib/stormpath-sdk/cache/cache.rb +54 -0
- data/lib/stormpath-sdk/cache/cache_entry.rb +33 -0
- data/lib/stormpath-sdk/cache/cache_manager.rb +22 -0
- data/lib/stormpath-sdk/cache/cache_stats.rb +35 -0
- data/lib/stormpath-sdk/cache/memory_store.rb +29 -0
- data/lib/stormpath-sdk/cache/redis_store.rb +32 -0
- data/lib/stormpath-sdk/client.rb +111 -0
- data/lib/stormpath-sdk/data_store.rb +241 -0
- data/lib/stormpath-sdk/{client/api_key.rb → error.rb} +16 -10
- data/lib/stormpath-sdk/{util → ext}/hash.rb +1 -2
- data/lib/stormpath-sdk/http/authc/sauthc1_signer.rb +8 -4
- data/lib/stormpath-sdk/http/http_client_request_executor.rb +8 -7
- data/lib/stormpath-sdk/http/request.rb +4 -8
- data/lib/stormpath-sdk/{util/request_utils.rb → http/utils.rb} +17 -38
- data/lib/stormpath-sdk/resource/account.rb +12 -108
- data/lib/stormpath-sdk/resource/application.rb +35 -171
- data/lib/stormpath-sdk/resource/associations.rb +97 -0
- data/lib/stormpath-sdk/resource/base.rb +256 -0
- data/lib/stormpath-sdk/resource/collection.rb +94 -0
- data/lib/stormpath-sdk/resource/directory.rb +11 -68
- data/lib/stormpath-sdk/resource/email_verification_token.rb +3 -9
- data/lib/stormpath-sdk/resource/error.rb +4 -38
- data/lib/stormpath-sdk/resource/expansion.rb +28 -0
- data/lib/stormpath-sdk/resource/group.rb +8 -66
- data/lib/stormpath-sdk/resource/group_membership.rb +4 -55
- data/lib/stormpath-sdk/resource/{application_list.rb → instance.rb} +7 -13
- data/lib/stormpath-sdk/resource/password_reset_token.rb +5 -23
- data/lib/stormpath-sdk/resource/status.rb +22 -28
- data/lib/stormpath-sdk/resource/tenant.rb +5 -52
- data/lib/stormpath-sdk/resource/utils.rb +43 -13
- data/lib/stormpath-sdk/util/assert.rb +5 -15
- data/lib/stormpath-sdk/version.rb +3 -3
- data/spec/api_key_spec.rb +19 -0
- data/spec/auth/basic_authenticator_spec.rb +25 -0
- data/spec/auth/sauthc1_signer_spec.rb +42 -0
- data/spec/cache/cache_entry_spec.rb +157 -0
- data/spec/cache/cache_spec.rb +89 -0
- data/spec/cache/cache_stats_spec.rb +106 -0
- data/spec/client_spec.rb +538 -0
- data/spec/data_store_spec.rb +130 -0
- data/spec/resource/account_spec.rb +74 -0
- data/spec/resource/application_spec.rb +148 -0
- data/spec/resource/base_spec.rb +114 -0
- data/spec/resource/collection_spec.rb +169 -0
- data/spec/resource/directory_spec.rb +30 -0
- data/spec/resource/expansion_spec.rb +100 -0
- data/spec/resource/group_spec.rb +49 -0
- data/spec/spec_helper.rb +135 -0
- data/spec/support/resource_factory.rb +48 -0
- data/spec/support/resource_matchers.rb +27 -0
- data/spec/support/test_cache_stores.rb +9 -0
- data/spec/support/test_request_executor.rb +11 -0
- data/stormpath-sdk.gemspec +14 -4
- data/support/api.rb +55 -0
- metadata +214 -44
- data/lib/stormpath-sdk/client/client.rb +0 -38
- data/lib/stormpath-sdk/client/client_application.rb +0 -38
- data/lib/stormpath-sdk/client/client_application_builder.rb +0 -351
- data/lib/stormpath-sdk/client/client_builder.rb +0 -305
- data/lib/stormpath-sdk/ds/data_store.rb +0 -210
- data/lib/stormpath-sdk/ds/resource_factory.rb +0 -37
- data/lib/stormpath-sdk/resource/account_list.rb +0 -32
- data/lib/stormpath-sdk/resource/collection_resource.rb +0 -91
- data/lib/stormpath-sdk/resource/directory_list.rb +0 -30
- data/lib/stormpath-sdk/resource/group_membership_list.rb +0 -32
- data/lib/stormpath-sdk/resource/instance_resource.rb +0 -28
- data/lib/stormpath-sdk/resource/resource.rb +0 -327
- data/lib/stormpath-sdk/resource/resource_error.rb +0 -47
- data/test/client/client.yml +0 -16
- data/test/client/client_application_builder_spec.rb +0 -114
- data/test/client/client_builder_spec.rb +0 -176
- data/test/client/read_spec.rb +0 -254
- data/test/client/write_spec.rb +0 -420
- data/test/resource/resource_spec.rb +0 -41
- data/test/resource/test_resource.rb +0 -28
@@ -1,176 +0,0 @@
|
|
1
|
-
require "stormpath-sdk"
|
2
|
-
|
3
|
-
include Stormpath::Client
|
4
|
-
|
5
|
-
describe "Client Builder Tests" do
|
6
|
-
|
7
|
-
before(:all) do
|
8
|
-
@client_file = 'test/client/client.yml'
|
9
|
-
@client_remote_file = 'http://localhost:8081/client.yml'
|
10
|
-
@test_remote_file = false
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
it 'Builder should read default properties from YAML file location' do
|
15
|
-
|
16
|
-
result = ClientBuilder.new.
|
17
|
-
set_api_key_file_location(@client_file).
|
18
|
-
build
|
19
|
-
|
20
|
-
result.should be_kind_of Client
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'Builder should read default properties from YAML FILE object' do
|
25
|
-
|
26
|
-
result = ClientBuilder.new.
|
27
|
-
set_api_key_file(File.open(@client_file)).
|
28
|
-
build
|
29
|
-
|
30
|
-
result.should be_kind_of Client
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'Builder should read custom simple properties from YAML file location' do
|
35
|
-
|
36
|
-
result = ClientBuilder.new.
|
37
|
-
set_api_key_file_location(@client_file).
|
38
|
-
set_api_key_id_property_name('different.apiKey.id').
|
39
|
-
set_api_key_secret_property_name('different.apiKey.secret').
|
40
|
-
build
|
41
|
-
|
42
|
-
result.should be_kind_of Client
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'Builder should read default properties from YAML valid object' do
|
47
|
-
|
48
|
-
# getting the properties from file...just to avoid writing them directly
|
49
|
-
# in the 'properties' Hash
|
50
|
-
yml_obj = YAML::load(File.open @client_file)
|
51
|
-
api_key_id_keyword = 'apiKey.id'
|
52
|
-
api_key_secret_keyword = 'apiKey.secret'
|
53
|
-
|
54
|
-
# we create the client from this Hash instead of from a file
|
55
|
-
properties = {api_key_id_keyword => yml_obj[api_key_id_keyword],
|
56
|
-
api_key_secret_keyword => yml_obj[api_key_secret_keyword]}
|
57
|
-
|
58
|
-
result = ClientBuilder.new.
|
59
|
-
set_api_key_properties(properties.to_yaml).
|
60
|
-
build
|
61
|
-
|
62
|
-
result.should be_kind_of Client
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'Builder should read custom simple properties from YAML valid object' do
|
67
|
-
|
68
|
-
# getting the properties from file...just to avoid writing them directly
|
69
|
-
# in the 'properties' Hash
|
70
|
-
yml_obj = YAML::load(File.open @client_file)
|
71
|
-
api_key_id_keyword = 'different.apiKey.id'
|
72
|
-
api_key_secret_keyword = 'different.apiKey.secret'
|
73
|
-
|
74
|
-
# we create the client from this Hash instead of from a file
|
75
|
-
properties = {api_key_id_keyword => yml_obj[api_key_id_keyword],
|
76
|
-
api_key_secret_keyword => yml_obj[api_key_secret_keyword]}
|
77
|
-
|
78
|
-
result = ClientBuilder.new.
|
79
|
-
set_api_key_properties(properties.to_yaml).
|
80
|
-
set_api_key_id_property_name(api_key_id_keyword).
|
81
|
-
set_api_key_secret_property_name(api_key_secret_keyword).
|
82
|
-
build
|
83
|
-
|
84
|
-
result.should be_kind_of Client
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'Builder should read custom complex properties from YAML file location' do
|
89
|
-
|
90
|
-
result = ClientBuilder.new.
|
91
|
-
set_api_key_file_location(@client_file).
|
92
|
-
set_api_key_id_property_name('stormpath', 'apiKey', 'id').
|
93
|
-
set_api_key_secret_property_name('stormpath', 'apiKey', 'secret').
|
94
|
-
build
|
95
|
-
|
96
|
-
result.should be_kind_of Client
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'Builder should read custom complex properties from YAML valid object' do
|
101
|
-
|
102
|
-
# getting the properties from file...just to avoid writing them directly
|
103
|
-
# in the 'properties' Hash
|
104
|
-
yml_obj = YAML::load(File.open @client_file)
|
105
|
-
stormpath = 'different.stormpath'
|
106
|
-
api_key = 'different.apiKey'
|
107
|
-
id = 'different.id'
|
108
|
-
secret = 'different.secret'
|
109
|
-
|
110
|
-
# we create the client from this Hash instead of from a file
|
111
|
-
data = {id => yml_obj[stormpath][api_key][id],
|
112
|
-
secret => yml_obj[stormpath][api_key][secret]}
|
113
|
-
api_key_data = {api_key => data}
|
114
|
-
stormpath_data = {stormpath => api_key_data}
|
115
|
-
|
116
|
-
result = ClientBuilder.new.
|
117
|
-
set_api_key_properties(stormpath_data.to_yaml).
|
118
|
-
set_api_key_id_property_name(stormpath, api_key, id).
|
119
|
-
set_api_key_secret_property_name(stormpath, api_key, secret).
|
120
|
-
build
|
121
|
-
|
122
|
-
result.should be_kind_of Client
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'Builder should read custom complex properties from YAML file location
|
127
|
-
and retrieve a Tenant from the Stormpath REST API' do
|
128
|
-
|
129
|
-
client = ClientBuilder.new.
|
130
|
-
set_api_key_file_location(@client_file).
|
131
|
-
set_api_key_id_property_name('stormpath', 'apiKey', 'id').
|
132
|
-
set_api_key_secret_property_name('stormpath', 'apiKey', 'secret').
|
133
|
-
#set_base_url('http://localhost:8080/v1').
|
134
|
-
build
|
135
|
-
|
136
|
-
result = client.current_tenant
|
137
|
-
|
138
|
-
result.should be_kind_of Tenant
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'Builder should read default properties from YAML URL location
|
143
|
-
and retrieve a Tenant from the Stormpath REST API' do
|
144
|
-
|
145
|
-
if @test_remote_file
|
146
|
-
|
147
|
-
client = ClientBuilder.new.
|
148
|
-
set_api_key_file_location(@client_remote_file).
|
149
|
-
#set_base_url('http://localhost:8080/v1').
|
150
|
-
build
|
151
|
-
|
152
|
-
result = client.current_tenant
|
153
|
-
|
154
|
-
result.should be_kind_of Tenant
|
155
|
-
end
|
156
|
-
|
157
|
-
|
158
|
-
end
|
159
|
-
|
160
|
-
it 'Builder should read custom complex properties from YAML file URL location
|
161
|
-
and retrieve a Tenant from the Stormpath REST API' do
|
162
|
-
|
163
|
-
client = ClientBuilder.new.
|
164
|
-
set_api_key_file_location(@client_remote_file).
|
165
|
-
set_api_key_id_property_name('stormpath', 'apiKey', 'id').
|
166
|
-
set_api_key_secret_property_name('stormpath', 'apiKey', 'secret').
|
167
|
-
#set_base_url('http://localhost:8080/v1').
|
168
|
-
build
|
169
|
-
|
170
|
-
result = client.current_tenant
|
171
|
-
|
172
|
-
result.should be_kind_of Tenant
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
end
|
data/test/client/read_spec.rb
DELETED
@@ -1,254 +0,0 @@
|
|
1
|
-
require "stormpath-sdk"
|
2
|
-
|
3
|
-
include Stormpath::Client
|
4
|
-
include Stormpath::Resource
|
5
|
-
|
6
|
-
describe "READ Operations" do
|
7
|
-
|
8
|
-
before(:all) do
|
9
|
-
@client = ClientBuilder.new.set_base_url('http://localhost:8080/v1').set_api_key_file_location(Dir.home + '/.stormpath/apiKey.yml').build
|
10
|
-
@tenant = @client.current_tenant
|
11
|
-
@data_store = @client.data_store
|
12
|
-
end
|
13
|
-
|
14
|
-
it "client should be created from api_key" do
|
15
|
-
@client.should be_instance_of Client
|
16
|
-
end
|
17
|
-
|
18
|
-
it "tenant's properties must come complete'" do
|
19
|
-
|
20
|
-
@tenant.should be_kind_of Tenant
|
21
|
-
|
22
|
-
key = @tenant.get_key
|
23
|
-
name = @tenant.get_name
|
24
|
-
|
25
|
-
key.should be_kind_of String
|
26
|
-
name.should be_kind_of String
|
27
|
-
|
28
|
-
applications = @tenant.get_applications
|
29
|
-
|
30
|
-
applications.should be_kind_of ApplicationList
|
31
|
-
|
32
|
-
# checking the tenant's' applications
|
33
|
-
applications.each { |app|
|
34
|
-
|
35
|
-
app.should be_kind_of Application
|
36
|
-
|
37
|
-
appName = app.get_name
|
38
|
-
|
39
|
-
# just checking that at least one
|
40
|
-
# application property can be read from here
|
41
|
-
appName.should be_kind_of String
|
42
|
-
}
|
43
|
-
|
44
|
-
directories = @tenant.get_directories
|
45
|
-
|
46
|
-
directories.should be_kind_of DirectoryList
|
47
|
-
|
48
|
-
# checking the tenant's' directories
|
49
|
-
directories.each { |dir|
|
50
|
-
|
51
|
-
dir.should be_kind_of Directory
|
52
|
-
|
53
|
-
dirName = dir.get_name
|
54
|
-
|
55
|
-
# just checking that at least one
|
56
|
-
# directory property can be read from here
|
57
|
-
dirName.should be_kind_of String
|
58
|
-
}
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
it "application's properties must come complete'" do
|
63
|
-
|
64
|
-
href = 'applications/uGBNDZ7TRhm_tahanqvn9A'
|
65
|
-
application = @data_store.get_resource href, Application
|
66
|
-
|
67
|
-
application.should be_kind_of Application
|
68
|
-
|
69
|
-
name = application.get_name
|
70
|
-
status = application.get_status
|
71
|
-
description = application.get_description
|
72
|
-
tenant = application.get_tenant
|
73
|
-
accounts = application.get_accounts
|
74
|
-
|
75
|
-
name.should be_kind_of String
|
76
|
-
status.should be_kind_of String
|
77
|
-
description.should be_kind_of String
|
78
|
-
tenant.should be_kind_of Tenant
|
79
|
-
accounts.should be_kind_of AccountList
|
80
|
-
|
81
|
-
accounts.each { |acc|
|
82
|
-
|
83
|
-
acc.should be_kind_of Account
|
84
|
-
|
85
|
-
acc_name = acc.get_username
|
86
|
-
|
87
|
-
# just checking that at least one
|
88
|
-
# account property can be read from here
|
89
|
-
acc_name.should be_kind_of String
|
90
|
-
}
|
91
|
-
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
it "directory's properties must come complete'" do
|
96
|
-
|
97
|
-
href = 'directories/jDd1xnMYTdqP-L-m6UD1Vg'
|
98
|
-
directory = @data_store.get_resource href, Directory
|
99
|
-
|
100
|
-
directory.should be_kind_of Directory
|
101
|
-
|
102
|
-
name = directory.get_name
|
103
|
-
status = directory.get_status
|
104
|
-
description = directory.get_description
|
105
|
-
tenant = directory.get_tenant
|
106
|
-
accounts = directory.get_accounts
|
107
|
-
groups = directory.get_groups
|
108
|
-
|
109
|
-
name.should be_kind_of String
|
110
|
-
status.should be_kind_of String
|
111
|
-
description.should be_kind_of String
|
112
|
-
tenant.should be_kind_of Tenant
|
113
|
-
accounts.should be_kind_of AccountList
|
114
|
-
groups.should be_kind_of GroupList
|
115
|
-
|
116
|
-
accounts.each { |acc|
|
117
|
-
|
118
|
-
acc.should be_kind_of Account
|
119
|
-
|
120
|
-
acc_name = acc.get_username
|
121
|
-
|
122
|
-
# just checking that at least one
|
123
|
-
# account property can be read from here
|
124
|
-
acc_name.should be_kind_of String
|
125
|
-
}
|
126
|
-
|
127
|
-
groups.each { |group|
|
128
|
-
|
129
|
-
group.should be_kind_of Group
|
130
|
-
|
131
|
-
group_name = group.get_name
|
132
|
-
|
133
|
-
# just checking that at least one
|
134
|
-
# group property can be read from here
|
135
|
-
group_name.should be_kind_of String
|
136
|
-
}
|
137
|
-
|
138
|
-
|
139
|
-
end
|
140
|
-
|
141
|
-
it "group's properties must come complete'" do
|
142
|
-
|
143
|
-
href = 'groups/E_D6HFfxSFmP0wIRvvvMUA'
|
144
|
-
group = @data_store.get_resource href, Group
|
145
|
-
|
146
|
-
group.should be_kind_of Group
|
147
|
-
|
148
|
-
name = group.get_name
|
149
|
-
status = group.get_status
|
150
|
-
description = group.get_description
|
151
|
-
tenant = group.get_tenant
|
152
|
-
accounts = group.get_accounts
|
153
|
-
directory = group.get_directory
|
154
|
-
|
155
|
-
name.should be_kind_of String
|
156
|
-
status.should be_kind_of String
|
157
|
-
description.should be_kind_of String
|
158
|
-
tenant.should be_kind_of Tenant
|
159
|
-
accounts.should be_kind_of AccountList
|
160
|
-
directory.should be_kind_of Directory
|
161
|
-
|
162
|
-
accounts.each { |acc|
|
163
|
-
|
164
|
-
acc.should be_kind_of Account
|
165
|
-
|
166
|
-
acc_name = acc.get_username
|
167
|
-
|
168
|
-
# just checking that at least one
|
169
|
-
# account property can be read from here
|
170
|
-
acc_name.should be_kind_of String
|
171
|
-
}
|
172
|
-
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
it "account's properties must come complete'" do
|
177
|
-
|
178
|
-
href = 'accounts/AnUd9aE_RKq-v8QJfrjq0A'
|
179
|
-
account = @data_store.get_resource href, Account
|
180
|
-
|
181
|
-
account.should be_kind_of Account
|
182
|
-
|
183
|
-
username = account.get_username
|
184
|
-
status = account.get_status
|
185
|
-
email = account.get_email
|
186
|
-
given_name = account.get_given_name
|
187
|
-
middle_name = account.get_middle_name
|
188
|
-
surname = account.get_surname
|
189
|
-
groups = account.get_groups
|
190
|
-
directory = account.get_directory
|
191
|
-
email_verification_token = account.get_email_verification_token
|
192
|
-
group_memberships = account.get_group_memberships
|
193
|
-
|
194
|
-
username.should be_kind_of String
|
195
|
-
status.should be_kind_of String
|
196
|
-
email.should be_kind_of String
|
197
|
-
given_name.should be_kind_of String
|
198
|
-
# middle_name is optional
|
199
|
-
#middle_name.should be_kind_of String
|
200
|
-
surname.should be_kind_of String
|
201
|
-
groups.should be_kind_of GroupList
|
202
|
-
directory.should be_kind_of Directory
|
203
|
-
# email_verification_token may not be present
|
204
|
-
#email_verification_token.should be_kind_of EmailVerificationToken
|
205
|
-
group_memberships.should be_kind_of GroupMembershipList
|
206
|
-
|
207
|
-
groups.each { |group|
|
208
|
-
|
209
|
-
group.should be_kind_of Group
|
210
|
-
|
211
|
-
group_name = group.get_name
|
212
|
-
|
213
|
-
# just checking that at least one
|
214
|
-
# group property can be read from here
|
215
|
-
group_name.should be_kind_of String
|
216
|
-
}
|
217
|
-
|
218
|
-
group_memberships.each { |groupMembership|
|
219
|
-
|
220
|
-
groupMembership.should be_kind_of GroupMembership
|
221
|
-
|
222
|
-
group = groupMembership.get_group
|
223
|
-
|
224
|
-
if (!group.nil?)
|
225
|
-
|
226
|
-
group_name = group.get_name
|
227
|
-
|
228
|
-
# just checking that at least one
|
229
|
-
# group property can be read from here
|
230
|
-
group_name.should be_kind_of String
|
231
|
-
|
232
|
-
end
|
233
|
-
}
|
234
|
-
|
235
|
-
|
236
|
-
end
|
237
|
-
|
238
|
-
it "dirty properties must be retained after materialization" do
|
239
|
-
|
240
|
-
account = @data_store.instantiate Account, {'href' => 'accounts/AnUd9aE_RKq-v8QJfrjq0A'}
|
241
|
-
|
242
|
-
name = 'Name Before Materialization'
|
243
|
-
|
244
|
-
account.set_given_name name
|
245
|
-
|
246
|
-
account.get_surname.should be_kind_of String
|
247
|
-
|
248
|
-
account.get_given_name.should == name
|
249
|
-
end
|
250
|
-
|
251
|
-
end
|
252
|
-
|
253
|
-
|
254
|
-
|
data/test/client/write_spec.rb
DELETED
@@ -1,420 +0,0 @@
|
|
1
|
-
require "stormpath-sdk"
|
2
|
-
|
3
|
-
include Stormpath::Client
|
4
|
-
include Stormpath::Resource
|
5
|
-
include Stormpath::Authentication
|
6
|
-
|
7
|
-
describe "WRITE Operations" do
|
8
|
-
|
9
|
-
before(:all) do
|
10
|
-
@client = ClientBuilder.new.set_base_url('http://localhost:8080/v1').set_api_key_file_location(Dir.home + '/.stormpath/apiKey.yml').build
|
11
|
-
@data_store = @client.data_store
|
12
|
-
@create_account = false
|
13
|
-
@update_account = false
|
14
|
-
@remove_account_property = false
|
15
|
-
@update_application = false
|
16
|
-
@update_directory = false
|
17
|
-
@update_group = false
|
18
|
-
@create_application = false
|
19
|
-
@change_password = false
|
20
|
-
@verify_email = false
|
21
|
-
@send_password_reset_email = false
|
22
|
-
@verify_password_reset_token = false
|
23
|
-
@create_account_with_group_membership = false
|
24
|
-
@create_group_membership_from_account = false
|
25
|
-
@create_group_membership_from_group = false
|
26
|
-
@update_group_membership_with_deletion = false
|
27
|
-
end
|
28
|
-
|
29
|
-
it "application should be able to authenticate" do
|
30
|
-
|
31
|
-
href = 'applications/uGBNDZ7TRhm_tahanqvn9A'
|
32
|
-
application = @data_store.get_resource href, Application
|
33
|
-
|
34
|
-
result = application.authenticate_account UsernamePasswordRequest.new 'kentucky', 'super_P4ss'
|
35
|
-
|
36
|
-
result.should be_kind_of AuthenticationResult
|
37
|
-
|
38
|
-
result.get_account.should be_kind_of Account
|
39
|
-
end
|
40
|
-
|
41
|
-
it "application should NOT be able to authenticate and catch the error" do
|
42
|
-
|
43
|
-
begin
|
44
|
-
|
45
|
-
href = 'applications/uGBNDZ7TRhm_tahanqvn9A'
|
46
|
-
application = @data_store.get_resource href, Application
|
47
|
-
result = application.authenticate_account UsernamePasswordRequest.new 'kentucky', 'WRONG_PASS'
|
48
|
-
|
49
|
-
rescue ResourceError => re
|
50
|
-
p '** Authentication Error **'
|
51
|
-
p 'Message: ' + re.message
|
52
|
-
p 'HTTP Status: ' + re.get_status.to_s
|
53
|
-
p 'Developer Message: ' + re.get_developer_message
|
54
|
-
p 'More Information: ' + re.get_more_info
|
55
|
-
p 'Error Code: ' + re.get_code.to_s
|
56
|
-
end
|
57
|
-
|
58
|
-
result.should_not be_kind_of AuthenticationResult
|
59
|
-
end
|
60
|
-
|
61
|
-
it "directory should be able to create account" do
|
62
|
-
|
63
|
-
if (@create_account)
|
64
|
-
|
65
|
-
href = 'directories/jDd1xnMYTdqP-L-m6UD1Vg'
|
66
|
-
directory = @data_store.get_resource href, Directory
|
67
|
-
|
68
|
-
account = @data_store.instantiate Account
|
69
|
-
account.set_email 'rubysdk@email.com'
|
70
|
-
account.set_given_name 'Ruby'
|
71
|
-
account.set_password 'super_P4ss'
|
72
|
-
account.set_surname 'Sdk'
|
73
|
-
account.set_username 'rubysdk'
|
74
|
-
|
75
|
-
result = directory.create_account account, false
|
76
|
-
|
77
|
-
result.should be_kind_of Account
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
it "account should be updated" do
|
84
|
-
|
85
|
-
if (@update_account)
|
86
|
-
|
87
|
-
href = 'accounts/RpB0hBFVSTmoLZTqHlwBRg'
|
88
|
-
account = @data_store.get_resource href, Account
|
89
|
-
|
90
|
-
mod_value = 'Modified at: ' + Time.now.to_s
|
91
|
-
account.set_middle_name mod_value
|
92
|
-
account.set_status Status::ENABLED
|
93
|
-
|
94
|
-
account.save
|
95
|
-
|
96
|
-
account.get_middle_name.should == mod_value
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
it "account property should be updated/removed" do
|
103
|
-
|
104
|
-
if (@remove_account_property)
|
105
|
-
|
106
|
-
href = 'accounts/gJH4bh6QQKK0awRmwD72Cg'
|
107
|
-
account = @data_store.get_resource href, Account
|
108
|
-
|
109
|
-
mod_value = 'Modified at: ' + Time.now.to_s
|
110
|
-
account.set_middle_name mod_value
|
111
|
-
|
112
|
-
account.save
|
113
|
-
|
114
|
-
account.get_middle_name.should == mod_value
|
115
|
-
|
116
|
-
account.set_middle_name nil
|
117
|
-
|
118
|
-
account.save
|
119
|
-
|
120
|
-
account.get_middle_name.should == nil
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
it "application should be updated" do
|
127
|
-
|
128
|
-
if (@update_application)
|
129
|
-
|
130
|
-
href = 'applications/fzyWJ5V_SDORGPk4fT2jhA'
|
131
|
-
application = @data_store.get_resource href, Application
|
132
|
-
|
133
|
-
application.set_name application.get_name + ' Modified'
|
134
|
-
application.set_status Status::ENABLED
|
135
|
-
|
136
|
-
application.save
|
137
|
-
|
138
|
-
application.get_name.should be_kind_of String
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
it "directory should be updated" do
|
145
|
-
|
146
|
-
if (@update_directory)
|
147
|
-
|
148
|
-
href = 'directories/wDTY5jppTLS2uZEAcqaL5A'
|
149
|
-
directory = @data_store.get_resource href, Directory
|
150
|
-
|
151
|
-
directory.set_name directory.get_name + ' Modified'
|
152
|
-
directory.set_status Status::ENABLED
|
153
|
-
|
154
|
-
directory.save
|
155
|
-
|
156
|
-
directory.get_name.should be_kind_of String
|
157
|
-
|
158
|
-
end
|
159
|
-
|
160
|
-
end
|
161
|
-
|
162
|
-
it "group should be updated" do
|
163
|
-
|
164
|
-
if (@update_group)
|
165
|
-
|
166
|
-
href = 'groups/mCidbrAcSF-VpkNfOVvJkQ'
|
167
|
-
group = @data_store.get_resource href, Group
|
168
|
-
|
169
|
-
group.set_name group.get_description + ' Modified'
|
170
|
-
group.set_status Status::ENABLED
|
171
|
-
|
172
|
-
group.save
|
173
|
-
|
174
|
-
group.get_name.should be_kind_of String
|
175
|
-
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
it "application should be created" do
|
181
|
-
|
182
|
-
if (@create_application)
|
183
|
-
|
184
|
-
tenant = @client.current_tenant
|
185
|
-
|
186
|
-
application = @data_store.instantiate Application
|
187
|
-
application.set_name 'Test Application Creation'
|
188
|
-
application.set_description 'Test Application Description'
|
189
|
-
|
190
|
-
result = tenant.create_application application
|
191
|
-
|
192
|
-
result.should be_kind_of Application
|
193
|
-
|
194
|
-
end
|
195
|
-
|
196
|
-
end
|
197
|
-
|
198
|
-
it "email should get verified" do
|
199
|
-
|
200
|
-
if (@verify_email)
|
201
|
-
|
202
|
-
verification_token = 'ujhNWAIVT2Wtfk-no3ajtw'
|
203
|
-
|
204
|
-
tenant = @client.current_tenant
|
205
|
-
|
206
|
-
result = tenant.verify_account_email verification_token
|
207
|
-
|
208
|
-
result.should be_kind_of Account
|
209
|
-
|
210
|
-
end
|
211
|
-
|
212
|
-
end
|
213
|
-
|
214
|
-
it "password reset email should be sent" do
|
215
|
-
|
216
|
-
if (@send_password_reset_email)
|
217
|
-
|
218
|
-
href = 'applications/uGBNDZ7TRhm_tahanqvn9A'
|
219
|
-
application = @data_store.get_resource href, Application
|
220
|
-
|
221
|
-
result = application.send_password_reset_email 'rubysdk@email.com'
|
222
|
-
|
223
|
-
result.should be_kind_of Account
|
224
|
-
|
225
|
-
end
|
226
|
-
|
227
|
-
end
|
228
|
-
|
229
|
-
it "password reset token should be verified" do
|
230
|
-
|
231
|
-
if (@verify_password_reset_token)
|
232
|
-
|
233
|
-
href = 'applications/fzyWJ5V_SDORGPk4fT2jhA'
|
234
|
-
application = @data_store.get_resource href, Application
|
235
|
-
|
236
|
-
result = application.verify_password_reset_token 'N0Zt1W9jTW2hP37XAE1jTQ'
|
237
|
-
|
238
|
-
result.should be_kind_of Account
|
239
|
-
|
240
|
-
end
|
241
|
-
|
242
|
-
end
|
243
|
-
|
244
|
-
it "password should be changed" do
|
245
|
-
|
246
|
-
if (@change_password)
|
247
|
-
|
248
|
-
href = 'applications/fzyWJ5V_SDORGPk4fT2jhA'
|
249
|
-
application = @data_store.get_resource href, Application
|
250
|
-
|
251
|
-
account = application.verify_password_reset_token 'TFMWt3lbQdWc7MNF48pJbw'
|
252
|
-
|
253
|
-
account.should be_kind_of Account
|
254
|
-
|
255
|
-
new_password = 'changed_P4ss'
|
256
|
-
account.set_password new_password
|
257
|
-
account.save
|
258
|
-
|
259
|
-
begin
|
260
|
-
|
261
|
-
application.authenticate_account UsernamePasswordRequest.new account.get_username, new_password
|
262
|
-
|
263
|
-
rescue ResourceError => re
|
264
|
-
|
265
|
-
false.should be true
|
266
|
-
|
267
|
-
end
|
268
|
-
|
269
|
-
end
|
270
|
-
|
271
|
-
end
|
272
|
-
|
273
|
-
it "account should be created linked to a group" do
|
274
|
-
|
275
|
-
if (@create_account_with_group_membership)
|
276
|
-
|
277
|
-
directory_href = 'directories/wDTY5jppTLS2uZEAcqaL5A'
|
278
|
-
directory = @data_store.get_resource directory_href, Directory
|
279
|
-
|
280
|
-
group_href = 'groups/mCidbrAcSF-VpkNfOVvJkQ'
|
281
|
-
group = @data_store.get_resource group_href, Group
|
282
|
-
|
283
|
-
account = @data_store.instantiate Account
|
284
|
-
account.set_email 'rubysdkwithgroup@email.com'
|
285
|
-
account.set_given_name 'Ruby'
|
286
|
-
account.set_password 'super_P4ss'
|
287
|
-
account.set_surname 'Sdk With Group'
|
288
|
-
account.set_username 'rubysdkwithgroup'
|
289
|
-
|
290
|
-
begin
|
291
|
-
|
292
|
-
directory.create_account account
|
293
|
-
account.add_group group
|
294
|
-
|
295
|
-
rescue ResourceError => re
|
296
|
-
|
297
|
-
false.should be true
|
298
|
-
|
299
|
-
end
|
300
|
-
|
301
|
-
group_added = false
|
302
|
-
account.get_groups.each { |tmpGroup|
|
303
|
-
|
304
|
-
if tmpGroup.get_href.include? group_href
|
305
|
-
|
306
|
-
group_added = true
|
307
|
-
break
|
308
|
-
end
|
309
|
-
}
|
310
|
-
|
311
|
-
group_added.should be true
|
312
|
-
|
313
|
-
end
|
314
|
-
|
315
|
-
end
|
316
|
-
|
317
|
-
|
318
|
-
it "account should be linked to specified group" do
|
319
|
-
|
320
|
-
if (@create_group_membership_from_account)
|
321
|
-
|
322
|
-
group_href = 'groups/0I5wmUILTvqHraXLERE9fw'
|
323
|
-
group = @data_store.get_resource group_href, Group
|
324
|
-
|
325
|
-
account_href = 'accounts/RpB0hBFVSTmoLZTqHlwBRg'
|
326
|
-
account = @data_store.get_resource account_href, Account
|
327
|
-
|
328
|
-
account.add_group group
|
329
|
-
|
330
|
-
group_linked = false
|
331
|
-
account.get_group_memberships.each { |group_membership|
|
332
|
-
|
333
|
-
group = group_membership.get_group
|
334
|
-
|
335
|
-
if (!group.nil? and group.get_href.include? group_href)
|
336
|
-
group_linked = true
|
337
|
-
break
|
338
|
-
end
|
339
|
-
}
|
340
|
-
|
341
|
-
group_linked.should == true
|
342
|
-
|
343
|
-
end
|
344
|
-
|
345
|
-
end
|
346
|
-
|
347
|
-
|
348
|
-
it "group should be linked to specified account" do
|
349
|
-
|
350
|
-
if (@create_group_membership_from_group)
|
351
|
-
|
352
|
-
group_href = 'groups/E_D6HFfxSFmP0wIRvvvMUA'
|
353
|
-
group = @data_store.get_resource group_href, Group
|
354
|
-
|
355
|
-
account_href = 'accounts/RpB0hBFVSTmoLZTqHlwBRg'
|
356
|
-
account = @data_store.get_resource account_href, Account
|
357
|
-
|
358
|
-
group.add_account account
|
359
|
-
|
360
|
-
accountLinked = false
|
361
|
-
group.get_accounts.each { |tmpAccount|
|
362
|
-
|
363
|
-
if (tmpAccount.get_href.include? account_href)
|
364
|
-
accountLinked = true
|
365
|
-
break
|
366
|
-
end
|
367
|
-
}
|
368
|
-
|
369
|
-
accountLinked.should == true
|
370
|
-
|
371
|
-
end
|
372
|
-
|
373
|
-
end
|
374
|
-
|
375
|
-
it "group membership should be updated with deletion/creation" do
|
376
|
-
|
377
|
-
if (@update_group_membership_with_deletion)
|
378
|
-
|
379
|
-
group_href = 'groups/0I5wmUILTvqHraXLERE9fw'
|
380
|
-
group = @data_store.get_resource group_href, Group
|
381
|
-
|
382
|
-
account_href = 'accounts/RpB0hBFVSTmoLZTqHlwBRg'
|
383
|
-
account = @data_store.get_resource account_href, Account
|
384
|
-
|
385
|
-
group_membership = nil
|
386
|
-
account.get_group_memberships.each { |tmp_group_membership|
|
387
|
-
|
388
|
-
group_membership = tmp_group_membership
|
389
|
-
tmp_group = group_membership.get_group
|
390
|
-
|
391
|
-
if (!tmp_group.nil? and tmp_group.get_href.include? group_href)
|
392
|
-
break
|
393
|
-
end
|
394
|
-
}
|
395
|
-
|
396
|
-
if (group_membership.nil?)
|
397
|
-
group_membership = account.add_group group
|
398
|
-
end
|
399
|
-
|
400
|
-
group_membership.delete
|
401
|
-
group.add_account account
|
402
|
-
|
403
|
-
|
404
|
-
account.get_group_memberships.each { |tmp_group_membership|
|
405
|
-
|
406
|
-
tmp_group = tmp_group_membership.get_group
|
407
|
-
|
408
|
-
if (!tmp_group.nil? and tmp_group.get_href.include? group_href)
|
409
|
-
group_membership = tmp_group_membership
|
410
|
-
break
|
411
|
-
end
|
412
|
-
}
|
413
|
-
|
414
|
-
group_membership.get_group.get_href.should include group_href
|
415
|
-
|
416
|
-
end
|
417
|
-
|
418
|
-
end
|
419
|
-
|
420
|
-
end
|