rhoconnect 3.2.0.beta1 → 3.2.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +14 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +33 -7
- data/README.md +4 -0
- data/Rakefile +13 -11
- data/commands/commands/rhoconnect/create_user.rb +1 -1
- data/commands/commands/rhoconnect/delete_device.rb +1 -1
- data/commands/commands/rhoconnect/delete_user.rb +1 -1
- data/commands/commands/rhoconnect/get_token.rb +1 -1
- data/commands/commands/rhoconnect/reset.rb +1 -1
- data/commands/execute.rb +0 -1
- data/doc/bulk-sync.txt +35 -1
- data/doc/install.txt +7 -3
- data/examples/simple/config.ru +1 -1
- data/generators/templates/application/Gemfile +1 -1
- data/install.sh +4 -4
- data/installer/unix-like/create_texts.rb +31 -31
- data/installer/unix-like/pre_uninstall.sh +2 -3
- data/installer/unix-like/rho_connect_install_constants.rb +3 -3
- data/installer/unix-like/rho_connect_install_debian.rb +0 -5
- data/installer/unix-like/rho_connect_install_yum.rb +1 -3
- data/installer/utils/constants.rb +4 -4
- data/installer/utils/nix_install_test.rb +20 -20
- data/installer/utils/package_upload/repos.rake +2 -2
- data/installer/utils/package_upload/s3_single_file.rb +57 -0
- data/lib/rhoconnect/client_sync.rb +1 -1
- data/lib/rhoconnect/jobs/bulk_data_job.rb +30 -32
- data/lib/rhoconnect/jobs/ping_job.rb +15 -2
- data/lib/rhoconnect/server.rb +3 -0
- data/lib/rhoconnect/tasks.rb +5 -7
- data/lib/rhoconnect/user.rb +1 -0
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect/web-console/models/adapter.js +2 -0
- data/lib/rhoconnect/web-console/models/client.js +0 -22
- data/lib/rhoconnect/web-console/models/source.js +1 -1
- data/lib/rhoconnect/web-console/templates/index.erb +2 -1
- data/lib/rhoconnect/web-console/views/home.js +22 -1
- data/lib/rhoconnect/web-console/views/set_adapter.js +5 -6
- data/rhoconnect.gemspec +2 -1
- data/spec/api/source/fast_insert_spec.rb +1 -1
- data/spec/api/user/create_user_spec.rb +11 -1
- data/spec/client_sync_spec.rb +32 -25
- data/spec/javascripts/admins_routes_spec.js +108 -103
- data/spec/javascripts/doc_view_spec.js +2 -3
- data/spec/javascripts/edit_user_view_spec.js +1 -1
- data/spec/javascripts/home_view_spec.js +6 -6
- data/spec/javascripts/server_doc_view_spec.js +4 -0
- data/spec/javascripts/session_spec.js +15 -0
- data/spec/javascripts/set_adapter_view_spec.js +2 -6
- data/spec/javascripts/show_device_view_spec.js +4 -1
- data/spec/javascripts/show_user_view_spec.js +4 -0
- data/spec/javascripts/source_docs_view_spec.js +2 -2
- data/spec/jobs/bulk_data_job_spec.rb +8 -12
- data/spec/jobs/ping_job_spec.rb +21 -0
- data/spec/perf/bulk_data_perf_spec.rb +1 -2
- data/spec/server/server_spec.rb +2 -4
- data/spec/spec_helper.rb +13 -3
- data/tasks/jasmine.rake +7 -0
- metadata +24 -7
- data/lib/rhoconnect/console/rhoconnect_api.rb +0 -245
- data/spec/api/application/rhoconnect_api_spec.rb +0 -592
@@ -1,592 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__),'..','..','..','lib','rhoconnect','console','rhoconnect_api.rb')
|
2
|
-
require File.join(File.dirname(__FILE__),'..','api_helper')
|
3
|
-
|
4
|
-
describe "RhoconnectApi" do
|
5
|
-
it_should_behave_like "ApiHelper" do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@s = Source.load(@s_fields[:name],@s_params)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should return api token using direct api call" do
|
12
|
-
RhoconnectApi::get_token('','rhoadmin','').should == @api_token
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should get adapter using direct api call" do
|
16
|
-
RhoconnectApi::get_adapter('',@api_token)
|
17
|
-
Rhoconnect.appserver.should == "http://test.com"
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should get adapter using rest call" do
|
21
|
-
res = mock('HttpResponse')
|
22
|
-
res.stub!(:body).and_return(["http://test.com"].to_json)
|
23
|
-
RestClient.stub(:post).and_return(res)
|
24
|
-
RestClient.should_receive(:post).once
|
25
|
-
RhoconnectApi::get_adapter('some_url',@api_token).should == ["http://test.com"]
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should save adapter using rest call" do
|
29
|
-
RestClient.stub(:post).and_return("adpater url saved")
|
30
|
-
RestClient.should_receive(:post).once
|
31
|
-
RhoconnectApi::save_adapter('some_url',@api_token,'http://test.com').should == "adpater url saved"
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should return api token using rest call" do
|
35
|
-
res = mock('HttpResponse')
|
36
|
-
res.stub!(:body).and_return(@api_token)
|
37
|
-
RestClient.stub(:post).and_return(res)
|
38
|
-
RestClient.should_receive(:post).once
|
39
|
-
RhoconnectApi::get_token('some_url','rhoadmin','').should == @api_token
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should list users using direct api call" do
|
43
|
-
RhoconnectApi::list_users('',@api_token).should == ['testuser']
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should list users using rect call" do
|
47
|
-
res = mock('HttpResponse')
|
48
|
-
res.stub!(:body).and_return(['testuser'].to_json)
|
49
|
-
RestClient.stub(:post).and_return(res)
|
50
|
-
RestClient.should_receive(:post).once
|
51
|
-
RhoconnectApi::list_users('some_url',@api_token).should == ['testuser']
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should create user using direct api call" do
|
55
|
-
RhoconnectApi::create_user('',@api_token,'testuser1','testpass1')
|
56
|
-
User.load('testuser1').login.should == 'testuser1'
|
57
|
-
User.authenticate('testuser1','testpass1').login.should == 'testuser1'
|
58
|
-
@a.users.members.sort.should == [@u.login, 'testuser1']
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should create user using rect call" do
|
62
|
-
RestClient.stub(:post).and_return("User created")
|
63
|
-
RestClient.should_receive(:post).once
|
64
|
-
RhoconnectApi::create_user('some_url',@api_token,'testuser1','testpass1').should == "User created"
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should update user using direct api call" do
|
68
|
-
RhoconnectApi::update_user('',@api_token, {:new_password => '123'})
|
69
|
-
User.authenticate('rhoadmin','123').login.should == 'rhoadmin'
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should delete user using rect call" do
|
73
|
-
RestClient.stub(:post).and_return("User deleted")
|
74
|
-
RestClient.should_receive(:post).once
|
75
|
-
RhoconnectApi::delete_user('some_url',@api_token,'testuser1').should == "User deleted"
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should list clients using direct api call" do
|
79
|
-
res = RhoconnectApi::list_clients('',@api_token,@u_fields[:login])
|
80
|
-
res.is_a?(Array).should == true
|
81
|
-
res.size.should == 1
|
82
|
-
res[0].is_a?(String) == true
|
83
|
-
res[0].length.should == 32
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should handle empty client's list" do
|
87
|
-
@u.clients.delete(@c.id)
|
88
|
-
RhoconnectApi::list_clients('',@api_token,@u_fields[:login]).should == []
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should create user using rect call" do
|
92
|
-
res = mock('HttpResponse')
|
93
|
-
res.stub!(:body).and_return(["21325fd9911044c6ad974785bf23c173"].to_json)
|
94
|
-
RestClient.stub(:post).and_return(res)
|
95
|
-
RestClient.should_receive(:post).once
|
96
|
-
RhoconnectApi::list_clients('some_url',@api_token,'testuser1').should == ["21325fd9911044c6ad974785bf23c173"]
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should create client for a user using direct api call" do
|
100
|
-
RhoconnectApi::create_client('',@api_token,@u_fields[:login])
|
101
|
-
clients = User.load(@u_fields[:login]).clients.members
|
102
|
-
clients.size.should == 2
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should create client using rect call" do
|
106
|
-
res = mock('HttpResponse')
|
107
|
-
res.stub!(:body).and_return("")
|
108
|
-
RestClient.stub(:post).and_return(res)
|
109
|
-
RestClient.should_receive(:post).once
|
110
|
-
RhoconnectApi::create_client('some_url',@api_token,'testuser1')
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should delete client using direct api call" do
|
114
|
-
RhoconnectApi::delete_client('',@api_token,@u_fields[:login],@c.id).should == "Client deleted"
|
115
|
-
Client.is_exist?(@c.id).should == false
|
116
|
-
User.load(@u_fields[:login]).clients.members.should == []
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should delete client using rect call" do
|
120
|
-
RestClient.stub(:post).and_return("Client deleted")
|
121
|
-
RestClient.should_receive(:post).once
|
122
|
-
RhoconnectApi::delete_client('some_url',@api_token,@u_fields[:login],@c.id).should == "Client deleted"
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should list client attributes using direct api call" do
|
126
|
-
res = RhoconnectApi::get_client_params('',@api_token,@c.id)
|
127
|
-
res.delete_if { |attrib| attrib['name'] == 'rho__id' || attrib['name'] == 'last_sync'}
|
128
|
-
res.sort{|x,y| x['name']<=>y['name']}.should == [
|
129
|
-
{"name"=>"device_type", "value"=>"Apple", "type"=>"string"},
|
130
|
-
{"name"=>"device_pin", "value"=>"abcd", "type"=>"string"},
|
131
|
-
{"name"=>"device_port", "value"=>"3333", "type"=>"string"},
|
132
|
-
{"name"=>"user_id", "value"=>"testuser", "type"=>"string"},
|
133
|
-
{"name"=>"phone_id", "value"=>nil, "type"=>"string"},
|
134
|
-
{"name"=>"app_id", "value"=>"application", "type"=>"string"}].sort{|x,y| x['name']<=>y['name']}
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should list client attributes using rest call" do
|
138
|
-
res = mock('HttpResponse')
|
139
|
-
res.stub!(:body).and_return(["blah"].to_json)
|
140
|
-
RestClient.stub(:post).and_return(res)
|
141
|
-
RestClient.should_receive(:post).once
|
142
|
-
RhoconnectApi::get_client_params('some_url',@api_token,'client_id')
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should list all application sources using direct api call" do
|
146
|
-
RhoconnectApi::list_sources('',@api_token).sort.should ==
|
147
|
-
["SimpleAdapter", "SampleAdapter", "FixedSchemaAdapter", "OtherAdapter"].sort
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should list all application sources using rest call" do
|
151
|
-
res = mock('HttpResponse')
|
152
|
-
res.stub!(:body).and_return(["SimpleAdapter", "SampleAdapter", "FixedSchemaAdapter", "OtherAdapter"].to_json)
|
153
|
-
RestClient.stub(:post).and_return(res)
|
154
|
-
RestClient.should_receive(:post).once
|
155
|
-
RhoconnectApi::list_sources('some_url',@api_token)
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should list source attributes using direct api call" do
|
159
|
-
result = RhoconnectApi::get_source_params(
|
160
|
-
'',@api_token,"SampleAdapter").sort {|x,y| x["name"] <=> y["name"] }
|
161
|
-
result.should == [
|
162
|
-
{"name"=>"rho__id", "value"=>"SampleAdapter", "type"=>"string"},
|
163
|
-
{"name"=>"source_id", "value"=>nil, "type"=>"integer"},
|
164
|
-
{"name"=>"name", "value"=>"SampleAdapter", "type"=>"string"},
|
165
|
-
{"name"=>"url", "value"=>"http://example.com", "type"=>"string"},
|
166
|
-
{"name"=>"login", "value"=>"testuser", "type"=>"string"},
|
167
|
-
{"name"=>"password", "value"=>"testpass", "type"=>"string"},
|
168
|
-
{"name"=>"priority", "value"=>3, "type"=>"integer"},
|
169
|
-
{"name"=>"callback_url", "value"=>nil, "type"=>"string"},
|
170
|
-
{"name"=>"poll_interval", "value"=>300, "type"=>"integer"},
|
171
|
-
{"name"=>"retry_limit", "value"=>0, "type"=>"integer"},
|
172
|
-
{"name"=>"simulate_time", "value"=>0, "type"=>"integer"},
|
173
|
-
{"name"=>"partition_type", "value"=>"user", "type"=>"string"},
|
174
|
-
{"name"=>"sync_type", "value"=>"incremental", "type"=>"string"},
|
175
|
-
{"name"=>"belongs_to", "type"=>"string", "value"=>nil},
|
176
|
-
{"name"=>"has_many", "type"=>"string", "value"=>"FixedSchemaAdapter,brand"},
|
177
|
-
{"name"=>"id", "value"=>"SampleAdapter", "type"=>"string"},
|
178
|
-
{"name"=>"queue", "value"=>nil, "type"=>"string"},
|
179
|
-
{"name"=>"query_queue", "value"=>nil, "type"=>"string"},
|
180
|
-
{"name"=>"cud_queue", "value"=>nil, "type"=>"string"},
|
181
|
-
{"name"=>"pass_through", "value"=>nil, "type"=>"string"}].sort {|x,y| x["name"] <=> y["name"] }
|
182
|
-
end
|
183
|
-
|
184
|
-
it "should list source attributes using rest call" do
|
185
|
-
res = mock('HttpResponse')
|
186
|
-
res.stub!(:body).and_return(["SimpleAdapter"].to_json)
|
187
|
-
RestClient.stub(:post).and_return(res)
|
188
|
-
RestClient.should_receive(:post).once
|
189
|
-
RhoconnectApi::get_source_params('some_url',@api_token,"SimpleAdapter")
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should list of shared source documents using direct api call" do
|
193
|
-
RhoconnectApi::list_source_docs('',@api_token,"SimpleAdapter","*").sort.should == {
|
194
|
-
"md"=>"source:application:__shared__:SimpleAdapter:md",
|
195
|
-
"errors"=>"source:application:__shared__:SimpleAdapter:errors",
|
196
|
-
"md_size"=>"source:application:__shared__:SimpleAdapter:md_size",
|
197
|
-
"md_copy"=>"source:application:__shared__:SimpleAdapter:md_copy"}.sort
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should list of shared source documents using rest call" do
|
201
|
-
res = mock('HttpResponse')
|
202
|
-
res.stub!(:body).and_return(["SimpleAdapter"].to_json)
|
203
|
-
RestClient.stub(:post).and_return(res)
|
204
|
-
RestClient.should_receive(:post).once
|
205
|
-
RhoconnectApi::list_source_docs('some_url',@api_token,"SimpleAdapter",'*')
|
206
|
-
end
|
207
|
-
|
208
|
-
it "should list client documents using direct api call" do
|
209
|
-
RhoconnectApi::list_client_docs('',@api_token,"SimpleAdapter",@c.id).should == {
|
210
|
-
"cd"=>"client:application:testuser:#{@c.id}:SimpleAdapter:cd",
|
211
|
-
"cd_size"=>"client:application:testuser:#{@c.id}:SimpleAdapter:cd_size",
|
212
|
-
"create"=>"client:application:testuser:#{@c.id}:SimpleAdapter:create",
|
213
|
-
"update"=>"client:application:testuser:#{@c.id}:SimpleAdapter:update",
|
214
|
-
"delete"=>"client:application:testuser:#{@c.id}:SimpleAdapter:delete",
|
215
|
-
|
216
|
-
"page"=>"client:application:testuser:#{@c.id}:SimpleAdapter:page",
|
217
|
-
"page_token"=>"client:application:testuser:#{@c.id}:SimpleAdapter:page_token",
|
218
|
-
"delete_page"=>"client:application:testuser:#{@c.id}:SimpleAdapter:delete_page",
|
219
|
-
"create_links"=>"client:application:testuser:#{@c.id}:SimpleAdapter:create_links",
|
220
|
-
"create_links_page"=>"client:application:testuser:#{@c.id}:SimpleAdapter:create_links_page",
|
221
|
-
|
222
|
-
"delete_errors"=>"client:application:testuser:#{@c.id}:SimpleAdapter:delete_errors",
|
223
|
-
"login_error"=>"client:application:testuser:#{@c.id}:SimpleAdapter:login_error",
|
224
|
-
"create_errors"=>"client:application:testuser:#{@c.id}:SimpleAdapter:create_errors",
|
225
|
-
"update_errors"=>"client:application:testuser:#{@c.id}:SimpleAdapter:update_errors",
|
226
|
-
"logoff_error"=>"client:application:testuser:#{@c.id}:SimpleAdapter:logoff_error",
|
227
|
-
|
228
|
-
"search"=>"client:application:testuser:#{@c.id}:SimpleAdapter:search",
|
229
|
-
"search_token"=>"client:application:testuser:#{@c.id}:SimpleAdapter:search_token",
|
230
|
-
"search_errors"=>"client:application:testuser:#{@c.id}:SimpleAdapter:search_errors"}
|
231
|
-
end
|
232
|
-
|
233
|
-
it "should list users using direct api call" do
|
234
|
-
RhoconnectApi::list_users('',@api_token).should == ['testuser']
|
235
|
-
end
|
236
|
-
|
237
|
-
it "should list users using rect call" do
|
238
|
-
res = mock('HttpResponse')
|
239
|
-
res.stub!(:body).and_return(['testuser'].to_json)
|
240
|
-
RestClient.stub(:post).and_return(res)
|
241
|
-
RestClient.should_receive(:post).once
|
242
|
-
RhoconnectApi::list_users('some_url',@api_token).should == ['testuser']
|
243
|
-
end
|
244
|
-
|
245
|
-
it "should create user using direct api call" do
|
246
|
-
RhoconnectApi::create_user('',@api_token,'testuser1','testpass1')
|
247
|
-
User.load('testuser1').login.should == 'testuser1'
|
248
|
-
User.authenticate('testuser1','testpass1').login.should == 'testuser1'
|
249
|
-
@a.users.members.sort.should == [@u.login, 'testuser1']
|
250
|
-
end
|
251
|
-
|
252
|
-
it "should create user using rect call" do
|
253
|
-
RestClient.stub(:post).and_return("User created")
|
254
|
-
RestClient.should_receive(:post).once
|
255
|
-
RhoconnectApi::create_user('some_url',@api_token,'testuser1','testpass1').should == "User created"
|
256
|
-
end
|
257
|
-
|
258
|
-
it "should update user using direct api call" do
|
259
|
-
RhoconnectApi::update_user('',@api_token, {:new_password => '123'})
|
260
|
-
User.authenticate('rhoadmin','123').login.should == 'rhoadmin'
|
261
|
-
end
|
262
|
-
|
263
|
-
it "should update user using rest call" do
|
264
|
-
RestClient.stub(:post)
|
265
|
-
RestClient.should_receive(:post).once
|
266
|
-
RhoconnectApi::update_user('some_url',@api_token, {:new_password => '123'})
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should delete user direct api call" do
|
270
|
-
RhoconnectApi::create_user('',@api_token,'testuser1','testpass1').should == "User created"
|
271
|
-
User.is_exist?('testuser1').should == true
|
272
|
-
RhoconnectApi::delete_user('',@api_token,'testuser1').should == "User deleted"
|
273
|
-
User.is_exist?('testuser1').should == false
|
274
|
-
App.load(test_app_name).users.members.should == ["testuser"]
|
275
|
-
end
|
276
|
-
|
277
|
-
it "should delete user using rect call" do
|
278
|
-
RestClient.stub(:post).and_return("User deleted")
|
279
|
-
RestClient.should_receive(:post).once
|
280
|
-
RhoconnectApi::delete_user('some_url',@api_token,'testuser1').should == "User deleted"
|
281
|
-
end
|
282
|
-
|
283
|
-
it "should list clients using direct api call" do
|
284
|
-
res = RhoconnectApi::list_clients('',@api_token,@u_fields[:login])
|
285
|
-
res.is_a?(Array).should == true
|
286
|
-
res.size.should == 1
|
287
|
-
res[0].is_a?(String) == true
|
288
|
-
res[0].length.should == 32
|
289
|
-
end
|
290
|
-
|
291
|
-
it "should handle empty client's list" do
|
292
|
-
@u.clients.delete(@c.id)
|
293
|
-
RhoconnectApi::list_clients('',@api_token,@u_fields[:login]).should == []
|
294
|
-
end
|
295
|
-
|
296
|
-
it "should create user using rect call" do
|
297
|
-
res = mock('HttpResponse')
|
298
|
-
res.stub!(:body).and_return(["21325fd9911044c6ad974785bf23c173"].to_json)
|
299
|
-
RestClient.stub(:post).and_return(res)
|
300
|
-
RestClient.should_receive(:post).once
|
301
|
-
RhoconnectApi::list_clients('some_url',@api_token,'testuser1').should == ["21325fd9911044c6ad974785bf23c173"]
|
302
|
-
end
|
303
|
-
|
304
|
-
it "should create client for a user using direct api call" do
|
305
|
-
RhoconnectApi::create_client('',@api_token,@u_fields[:login])
|
306
|
-
clients = User.load(@u_fields[:login]).clients.members
|
307
|
-
clients.size.should == 2
|
308
|
-
end
|
309
|
-
|
310
|
-
it "should create client using rect call" do
|
311
|
-
res = mock('HttpResponse')
|
312
|
-
res.stub!(:body).and_return("")
|
313
|
-
RestClient.stub(:post).and_return(res)
|
314
|
-
RestClient.should_receive(:post).once
|
315
|
-
RhoconnectApi::create_client('some_url',@api_token,'testuser1')
|
316
|
-
end
|
317
|
-
|
318
|
-
it "should delete client using direct api call" do
|
319
|
-
RhoconnectApi::delete_client('',@api_token,@u_fields[:login],@c.id).should == "Client deleted"
|
320
|
-
Client.is_exist?(@c.id).should == false
|
321
|
-
User.load(@u_fields[:login]).clients.members.should == []
|
322
|
-
end
|
323
|
-
|
324
|
-
it "should delete client using rect call" do
|
325
|
-
RestClient.stub(:post).and_return("Client deleted")
|
326
|
-
RestClient.should_receive(:post).once
|
327
|
-
RhoconnectApi::delete_client('some_url',@api_token,@u_fields[:login],@c.id).should == "Client deleted"
|
328
|
-
end
|
329
|
-
|
330
|
-
it "should list client attributes using direct api call" do
|
331
|
-
res = RhoconnectApi::get_client_params('',@api_token,@c.id)
|
332
|
-
res.delete_if { |attrib| attrib['name'] == 'rho__id' || attrib['name'] == 'last_sync'}
|
333
|
-
res.sort{|x,y| x['name']<=>y['name']}.should == [
|
334
|
-
{"name"=>"device_type", "value"=>"Apple", "type"=>"string"},
|
335
|
-
{"name"=>"device_pin", "value"=>"abcd", "type"=>"string"},
|
336
|
-
{"name"=>"device_port", "value"=>"3333", "type"=>"string"},
|
337
|
-
{"name"=>"user_id", "value"=>"testuser", "type"=>"string"},
|
338
|
-
{"name"=>"phone_id", "value"=>nil, "type"=>"string"},
|
339
|
-
{"name"=>"app_id", "value"=>"application", "type"=>"string"}].sort{|x,y| x['name']<=>y['name']}
|
340
|
-
end
|
341
|
-
|
342
|
-
it "should list client attributes using rest call" do
|
343
|
-
res = mock('HttpResponse')
|
344
|
-
res.stub!(:body).and_return(["blah"].to_json)
|
345
|
-
RestClient.stub(:post).and_return(res)
|
346
|
-
RestClient.should_receive(:post).once
|
347
|
-
RhoconnectApi::get_client_params('some_url',@api_token,'client_id')
|
348
|
-
end
|
349
|
-
|
350
|
-
it "should list all application sources using direct api call" do
|
351
|
-
RhoconnectApi::list_sources('',@api_token).sort.should ==
|
352
|
-
["SimpleAdapter", "SampleAdapter", "FixedSchemaAdapter", "OtherAdapter"].sort
|
353
|
-
end
|
354
|
-
|
355
|
-
it "should list all application sources using rest call" do
|
356
|
-
res = mock('HttpResponse')
|
357
|
-
res.stub!(:body).and_return(["SimpleAdapter", "SampleAdapter", "FixedSchemaAdapter", "OtherAdapter"].to_json)
|
358
|
-
RestClient.stub(:post).and_return(res)
|
359
|
-
RestClient.should_receive(:post).once
|
360
|
-
RhoconnectApi::list_sources('some_url',@api_token)
|
361
|
-
end
|
362
|
-
|
363
|
-
it "should list source attributes using direct api call" do
|
364
|
-
result = RhoconnectApi::get_source_params(
|
365
|
-
'',@api_token,"SampleAdapter").sort{|x,y| x['name']<=>y['name']}
|
366
|
-
result.should == [
|
367
|
-
{"name"=>"rho__id", "value"=>"SampleAdapter", "type"=>"string"},
|
368
|
-
{"name"=>"source_id", "value"=>nil, "type"=>"integer"},
|
369
|
-
{"name"=>"name", "value"=>"SampleAdapter", "type"=>"string"},
|
370
|
-
{"name"=>"url", "value"=>"http://example.com", "type"=>"string"},
|
371
|
-
{"name"=>"login", "value"=>"testuser", "type"=>"string"},
|
372
|
-
{"name"=>"password", "value"=>"testpass", "type"=>"string"},
|
373
|
-
{"name"=>"priority", "value"=>3, "type"=>"integer"},
|
374
|
-
{"name"=>"callback_url", "value"=>nil, "type"=>"string"},
|
375
|
-
{"name"=>"poll_interval", "value"=>300, "type"=>"integer"},
|
376
|
-
{"name"=>"retry_limit", "type"=>"integer", "value"=>0},
|
377
|
-
{"name"=>"simulate_time", "value"=>0, "type"=>"integer"},
|
378
|
-
{"name"=>"partition_type", "value"=>"user", "type"=>"string"},
|
379
|
-
{"name"=>"sync_type", "value"=>"incremental", "type"=>"string"},
|
380
|
-
{"name"=>"belongs_to", "type"=>"string", "value"=>nil},
|
381
|
-
{"name"=>"has_many", "type"=>"string", "value"=>"FixedSchemaAdapter,brand"},
|
382
|
-
{"name"=>"id", "value"=>"SampleAdapter", "type"=>"string"},
|
383
|
-
{"name"=>"queue", "value"=>nil, "type"=>"string"},
|
384
|
-
{"name"=>"query_queue", "value"=>nil, "type"=>"string"},
|
385
|
-
{"name"=>"cud_queue", "value"=>nil, "type"=>"string"},
|
386
|
-
{"name"=>"pass_through", "value"=>nil, "type"=>"string"}].sort {|x,y| x["name"] <=> y["name"] }
|
387
|
-
end
|
388
|
-
|
389
|
-
it "should list source attributes with default env poll_interval using direct api call" do
|
390
|
-
result = RhoconnectApi::get_source_params(
|
391
|
-
'',@api_token,"OtherAdapter").sort{|x,y| x['name']<=>y['name']}
|
392
|
-
result.should == [
|
393
|
-
{"name"=>"rho__id", "value"=>"OtherAdapter", "type"=>"string"},
|
394
|
-
{"name"=>"source_id", "value"=>nil, "type"=>"integer"},
|
395
|
-
{"name"=>"name", "value"=>"OtherAdapter", "type"=>"string"},
|
396
|
-
{"name"=>"url", "value"=>"", "type"=>"string"},
|
397
|
-
{"name"=>"login", "value"=>"", "type"=>"string"},
|
398
|
-
{"name"=>"password", "value"=>"", "type"=>"string"},
|
399
|
-
{"name"=>"priority", "value"=>3, "type"=>"integer"},
|
400
|
-
{"name"=>"callback_url", "value"=>nil, "type"=>"string"},
|
401
|
-
{"name"=>"poll_interval", "value"=>201, "type"=>"integer"},
|
402
|
-
{"name"=>"retry_limit", "value"=>0, "type"=>"integer"},
|
403
|
-
{"name"=>"simulate_time", "value"=>0, "type"=>"integer"},
|
404
|
-
{"name"=>"partition_type", "value"=>"app", "type"=>"string"},
|
405
|
-
{"name"=>"sync_type", "value"=>"incremental", "type"=>"string"},
|
406
|
-
{"name"=>"belongs_to", "type"=>"string", "value"=>nil},
|
407
|
-
{"name"=>"has_many", "type"=>"string", "value"=>nil},
|
408
|
-
{"name"=>"id", "value"=>"OtherAdapter", "type"=>"string"},
|
409
|
-
{"name"=>"queue", "value"=>nil, "type"=>"string"},
|
410
|
-
{"name"=>"query_queue", "value"=>nil, "type"=>"string"},
|
411
|
-
{"name"=>"cud_queue", "value"=>nil, "type"=>"string"},
|
412
|
-
{"name"=>"pass_through", "value"=>nil, "type"=>"string"}].sort {|x,y| x["name"] <=> y["name"] }
|
413
|
-
end
|
414
|
-
|
415
|
-
it "should list source attributes using rest call" do
|
416
|
-
res = mock('HttpResponse')
|
417
|
-
res.stub!(:body).and_return(["SimpleAdapter"].to_json)
|
418
|
-
RestClient.stub(:post).and_return(res)
|
419
|
-
RestClient.should_receive(:post).once
|
420
|
-
RhoconnectApi::get_source_params('some_url',@api_token,"SimpleAdapter")
|
421
|
-
end
|
422
|
-
|
423
|
-
it "should list of shared source documents using direct api call" do
|
424
|
-
RhoconnectApi::list_source_docs('',@api_token,"SimpleAdapter","*").sort.should == {
|
425
|
-
"md"=>"source:application:__shared__:SimpleAdapter:md",
|
426
|
-
"errors"=>"source:application:__shared__:SimpleAdapter:errors",
|
427
|
-
"md_size"=>"source:application:__shared__:SimpleAdapter:md_size",
|
428
|
-
"md_copy"=>"source:application:__shared__:SimpleAdapter:md_copy"}.sort
|
429
|
-
end
|
430
|
-
|
431
|
-
it "should list of shared source documents using rest call" do
|
432
|
-
res = mock('HttpResponse')
|
433
|
-
res.stub!(:body).and_return(["SimpleAdapter"].to_json)
|
434
|
-
RestClient.stub(:post).and_return(res)
|
435
|
-
RestClient.should_receive(:post).once
|
436
|
-
RhoconnectApi::list_source_docs('some_url',@api_token,"SimpleAdapter",'*')
|
437
|
-
end
|
438
|
-
|
439
|
-
it "should list client documents using direct api call" do
|
440
|
-
RhoconnectApi::list_client_docs('',@api_token,"SimpleAdapter",@c.id).should == {
|
441
|
-
"cd"=>"client:application:testuser:#{@c.id}:SimpleAdapter:cd",
|
442
|
-
"cd_size"=>"client:application:testuser:#{@c.id}:SimpleAdapter:cd_size",
|
443
|
-
"create"=>"client:application:testuser:#{@c.id}:SimpleAdapter:create",
|
444
|
-
"update"=>"client:application:testuser:#{@c.id}:SimpleAdapter:update",
|
445
|
-
"delete"=>"client:application:testuser:#{@c.id}:SimpleAdapter:delete",
|
446
|
-
|
447
|
-
"page"=>"client:application:testuser:#{@c.id}:SimpleAdapter:page",
|
448
|
-
"page_token"=>"client:application:testuser:#{@c.id}:SimpleAdapter:page_token",
|
449
|
-
"delete_page"=>"client:application:testuser:#{@c.id}:SimpleAdapter:delete_page",
|
450
|
-
"create_links"=>"client:application:testuser:#{@c.id}:SimpleAdapter:create_links",
|
451
|
-
"create_links_page"=>"client:application:testuser:#{@c.id}:SimpleAdapter:create_links_page",
|
452
|
-
|
453
|
-
"delete_errors"=>"client:application:testuser:#{@c.id}:SimpleAdapter:delete_errors",
|
454
|
-
"login_error"=>"client:application:testuser:#{@c.id}:SimpleAdapter:login_error",
|
455
|
-
"create_errors"=>"client:application:testuser:#{@c.id}:SimpleAdapter:create_errors",
|
456
|
-
"update_errors"=>"client:application:testuser:#{@c.id}:SimpleAdapter:update_errors",
|
457
|
-
"logoff_error"=>"client:application:testuser:#{@c.id}:SimpleAdapter:logoff_error",
|
458
|
-
|
459
|
-
"search"=>"client:application:testuser:#{@c.id}:SimpleAdapter:search",
|
460
|
-
"search_token"=>"client:application:testuser:#{@c.id}:SimpleAdapter:search_token",
|
461
|
-
"search_errors"=>"client:application:testuser:#{@c.id}:SimpleAdapter:search_errors"}
|
462
|
-
end
|
463
|
-
|
464
|
-
it "should list client documents using rest call" do
|
465
|
-
res = mock('HttpResponse')
|
466
|
-
res.stub!(:body).and_return(["SimpleAdapter"].to_json)
|
467
|
-
RestClient.stub(:post).and_return(res)
|
468
|
-
RestClient.should_receive(:post).once
|
469
|
-
RhoconnectApi::list_client_docs('some_url',@api_token,"SimpleAdapter",'*')
|
470
|
-
end
|
471
|
-
|
472
|
-
it "should return db document by name using direct api call" do
|
473
|
-
data = {'1' => {'foo' => 'bar'}}
|
474
|
-
set_state('abc:abc' => data)
|
475
|
-
RhoconnectApi::get_db_doc('',@api_token,'abc:abc').should == data
|
476
|
-
end
|
477
|
-
|
478
|
-
it "should return db document by name and data_type using direct api call" do
|
479
|
-
data = 'some string'
|
480
|
-
set_state('abc:abc' => data)
|
481
|
-
RhoconnectApi::get_db_doc('',@api_token,'abc:abc','string').should == data
|
482
|
-
end
|
483
|
-
|
484
|
-
it "should return db document using rest call" do
|
485
|
-
data = 'some string'
|
486
|
-
res = mock('HttpResponse')
|
487
|
-
res.stub!(:body).and_return(data)
|
488
|
-
RestClient.stub(:post).and_return(res)
|
489
|
-
RestClient.should_receive(:post).once
|
490
|
-
RhoconnectApi::get_db_doc('some_url',@api_token,'abc:abc','string').should == data
|
491
|
-
end
|
492
|
-
|
493
|
-
it "should set db document by doc name and data using direct api call" do
|
494
|
-
data = {'1' => {'foo' => 'bar'}}
|
495
|
-
RhoconnectApi::set_db_doc('',@api_token,'abc:abc',data)
|
496
|
-
verify_result('abc:abc' => data)
|
497
|
-
end
|
498
|
-
|
499
|
-
it "should set db document by doc name, data type, and data using direct api call" do
|
500
|
-
data = 'some string'
|
501
|
-
RhoconnectApi::set_db_doc('',@api_token,'abc:abc:str',data,'string')
|
502
|
-
verify_result('abc:abc:str' => data)
|
503
|
-
end
|
504
|
-
|
505
|
-
it "should set db document using rest call" do
|
506
|
-
data = 'some string'
|
507
|
-
RestClient.stub(:post)
|
508
|
-
RestClient.should_receive(:post).once
|
509
|
-
RhoconnectApi::set_db_doc('some_url',@api_token,'abc:abc:str',data,'string')
|
510
|
-
end
|
511
|
-
|
512
|
-
it "should reset and re-create rhoadmin user with bootstrap using direct api call" do
|
513
|
-
# Store.put_data('somedoc',{'foo'=>'bar'})
|
514
|
-
Store.put_data('somedoc',{'1' => {'foo'=>'bar'}})
|
515
|
-
RhoconnectApi::reset('',@api_token).should == "DB reset"
|
516
|
-
App.is_exist?(test_app_name).should == true
|
517
|
-
Store.get_data('somedoc').should == {}
|
518
|
-
User.authenticate('rhoadmin','').should_not be_nil
|
519
|
-
end
|
520
|
-
|
521
|
-
it "should reset db using rest call" do
|
522
|
-
RestClient.stub(:post).and_return("DB reset")
|
523
|
-
RestClient.should_receive(:post).once
|
524
|
-
RhoconnectApi::reset('some_url',@api_token).should == "DB reset"
|
525
|
-
end
|
526
|
-
|
527
|
-
it "should do ping asynchronously using direct api call" do
|
528
|
-
params = {"user_id" => @u.id, "api_token" => @api_token,
|
529
|
-
"async" => "true","sources" => [@s.name], "message" => 'hello world',
|
530
|
-
"vibrate" => '5', "badge" => '5', "sound" => 'hello.mp3'}
|
531
|
-
PingJob.should_receive(:enqueue).once.with(params)
|
532
|
-
RhoconnectApi::ping('',@api_token,@u.id,params)
|
533
|
-
end
|
534
|
-
|
535
|
-
it "should do ping using rest call" do
|
536
|
-
RestClient.stub(:post)
|
537
|
-
RestClient.should_receive(:post).once
|
538
|
-
RhoconnectApi::ping('some_url',@api_token,@u.id,{})
|
539
|
-
end
|
540
|
-
|
541
|
-
it "should do ping multiple users using rest call" do
|
542
|
-
@u1_fields = {:login => 'testuser1'}
|
543
|
-
@u1 = User.create(@u1_fields)
|
544
|
-
@u1.password = 'testpass'
|
545
|
-
@c1_fields = {
|
546
|
-
:device_type => 'Apple',
|
547
|
-
:device_pin => 'abcde',
|
548
|
-
:device_port => '3334',
|
549
|
-
:user_id => @u1.id,
|
550
|
-
:app_id => @a.id
|
551
|
-
}
|
552
|
-
@c1 = Client.create(@c1_fields,{:source_name => @s_fields[:name]})
|
553
|
-
@a.users << @u1.id
|
554
|
-
|
555
|
-
RestClient.stub(:post)
|
556
|
-
RestClient.should_receive(:post).once
|
557
|
-
RhoconnectApi::ping('some_url',@api_token,[@u.id, @u1.id],{})
|
558
|
-
end
|
559
|
-
|
560
|
-
it "should get license info using direct api call" do
|
561
|
-
RhoconnectApi::get_license_info('',@api_token).should == {
|
562
|
-
"available" => 9,
|
563
|
-
"issued" => "Fri Apr 23 17:20:13 -0700 2010",
|
564
|
-
"seats" => 10,
|
565
|
-
"rhoconnect_version" => "Version 1",
|
566
|
-
"licensee" => "Rhomobile" }
|
567
|
-
end
|
568
|
-
|
569
|
-
it "should get license info using rest call" do
|
570
|
-
res = mock('HttpResponse')
|
571
|
-
res.stub!(:body).and_return(['data'].to_json)
|
572
|
-
RestClient.stub(:post).and_return(res)
|
573
|
-
RestClient.should_receive(:post).once
|
574
|
-
RhoconnectApi::get_license_info('some_url',@api_token)
|
575
|
-
end
|
576
|
-
|
577
|
-
it "should get stats using direct api call" do
|
578
|
-
Rhoconnect.stats = true
|
579
|
-
Store.set_value('stat:foo','bar')
|
580
|
-
RhoconnectApi::stats('',@api_token,:metric => 'foo').should == 'bar'
|
581
|
-
Rhoconnect.stats = false
|
582
|
-
end
|
583
|
-
|
584
|
-
it "should get stats using rest call" do
|
585
|
-
res = mock('HttpResponse')
|
586
|
-
res.stub!(:body).and_return('bar')
|
587
|
-
RestClient.stub(:post).and_return(res)
|
588
|
-
RestClient.should_receive(:post).once.and_return(res)
|
589
|
-
RhoconnectApi::stats('some_url',@api_token,:metric => 'foo')
|
590
|
-
end
|
591
|
-
end
|
592
|
-
end
|