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