rhoconnect 4.0.4 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/CHANGELOG.md +54 -5
- data/CREDITS +219 -219
- data/Gemfile +2 -2
- data/Gemfile.lock +68 -79
- data/Rakefile +1 -2
- data/bench/benchapp/spec/models/ruby/mock_adapter_spec.rb +17 -17
- data/bench/benchapp/spec/models/ruby/queue_mock_adapter_spec.rb +17 -17
- data/bench/benchapp/spec/spec_helper.rb +3 -3
- data/bench/blobapp/spec/models/ruby/blob_adapter_spec.rb +17 -17
- data/bench/blobapp/spec/spec_helper.rb +3 -3
- data/bench/lib/bench/runner.rb +1 -69
- data/bench/lib/bench.rb +18 -18
- data/bench/spec/mock_adapter_spec.rb +54 -55
- data/bench/spec/mock_client_spec.rb +47 -48
- data/bench/spec/result_spec.rb +41 -44
- data/bench/spec/utils_spec.rb +24 -25
- data/commands/generators/app.rb +7 -5
- data/commands/generators/controller.rb +7 -5
- data/commands/generators/model.rb +7 -5
- data/commands/generators/source.rb +7 -5
- data/commands/parser.rb +1 -1
- data/commands/redis/redis_download.rb +1 -1
- data/doc/async-jobs.txt +9 -9
- data/doc/supported-platforms.txt +0 -2
- data/generators/rhoconnect.rb +92 -212
- data/generators/templates/application/rcgemfile +3 -3
- data/generators/templates/application/spec/application_controller_spec.rb +14 -16
- data/generators/templates/application/spec/js_spec.rb +20 -20
- data/generators/templates/application/spec/spec_helper.rb +1 -1
- data/generators/templates/source/controllers/ruby/controller_spec.rb +18 -19
- data/generators/templates/source/models/ruby/model_spec.rb +17 -17
- data/install.sh +10 -21
- data/installer/unix-like/rho_connect_install_constants.rb +5 -5
- data/installer/unix-like/rho_connect_install_installers.rb +4 -4
- data/installer/utils/constants.rb +6 -6
- data/installer/utils/nix_install_test.rb +29 -29
- data/installer/utils/package_upload/repos.rake +16 -26
- data/js-adapters/node.rb +4 -4
- data/js-adapters/node_channel.rb +4 -8
- data/lib/rhoconnect/db_adapter.rb +13 -13
- data/lib/rhoconnect/handler/changes/engine.rb +1 -1
- data/lib/rhoconnect/jobs/bulk_data_job.rb +29 -29
- data/lib/rhoconnect/license.rb +7 -7
- data/lib/rhoconnect/model/helpers/find_duplicates_on_update.rb +13 -13
- data/lib/rhoconnect/ping/apple.rb +4 -4
- data/lib/rhoconnect/server.rb +2 -2
- data/lib/rhoconnect/source.rb +2 -2
- data/lib/rhoconnect/store.rb +12 -6
- data/lib/rhoconnect/utilities.rb +2 -2
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect.rb +6 -4
- data/rhoconnect.gemspec +5 -6
- data/spec/api/api_helper.rb +1 -1
- data/spec/api/app/fast_delete_spec.rb +22 -22
- data/spec/api/app/fast_insert_spec.rb +23 -23
- data/spec/api/app/fast_update_spec.rb +63 -63
- data/spec/api/app/push_deletes_spec.rb +11 -13
- data/spec/api/app/push_objects_spec.rb +39 -39
- data/spec/api/client/client_get_db_doc_spec.rb +29 -29
- data/spec/api/client/client_set_db_doc_spec.rb +11 -11
- data/spec/api/client/get_client_params_spec.rb +29 -29
- data/spec/api/client/list_client_docs_spec.rb +32 -34
- data/spec/api/client/reset_spec.rb +30 -30
- data/spec/api/readstate/set_refresh_time_spec.rb +43 -43
- data/spec/api/source/get_source_params_spec.rb +32 -34
- data/spec/api/source/list_sources_spec.rb +13 -13
- data/spec/api/source/update_source_params_spec.rb +19 -19
- data/spec/api/store/get_db_doc_spec.rb +27 -27
- data/spec/api/store/set_db_doc_spec.rb +38 -38
- data/spec/api/system/adapter_spec.rb +27 -29
- data/spec/api/system/get_license_info_spec.rb +11 -11
- data/spec/api/system/login_spec.rb +37 -37
- data/spec/api/system/reset_spec.rb +15 -15
- data/spec/api/system/stats_spec.rb +70 -71
- data/spec/api/user/create_user_spec.rb +37 -37
- data/spec/api/user/delete_client_spec.rb +7 -7
- data/spec/api/user/delete_user_spec.rb +62 -62
- data/spec/api/user/list_clients_spec.rb +24 -24
- data/spec/api/user/list_source_docs_spec.rb +29 -29
- data/spec/api/user/list_users_spec.rb +22 -22
- data/spec/api/user/ping_spec.rb +18 -18
- data/spec/api/user/show_user_spec.rb +10 -10
- data/spec/api/user/update_user_spec.rb +43 -43
- data/spec/api/user/user_get_db_doc_spec.rb +12 -12
- data/spec/api/user/user_set_db_doc_spec.rb +37 -37
- data/spec/api_token_spec.rb +8 -8
- data/spec/app_spec.rb +18 -17
- data/spec/apps/jstestapp/settings/settings.yml +2 -0
- data/spec/async_spec.rb +9 -11
- data/spec/bulk_data/bulk_data_spec.rb +120 -120
- data/spec/cli/cli_spec.rb +50 -53
- data/spec/client_spec.rb +105 -105
- data/spec/client_sync_spec.rb +529 -528
- data/spec/controllers/js_base_spec.rb +147 -141
- data/spec/doc/doc_spec.rb +51 -52
- data/spec/document_spec.rb +58 -58
- data/spec/dynamic_adapter_spec.rb +33 -36
- data/spec/generator/generator_spec.rb +76 -42
- data/spec/jobs/bulk_data_job_spec.rb +101 -102
- data/spec/jobs/ping_job_spec.rb +176 -177
- data/spec/jobs/source_job_spec.rb +24 -25
- data/spec/license_spec.rb +54 -55
- data/spec/models/js_base_spec.rb +121 -120
- data/spec/perf/bulk_data_perf_spec.rb +23 -24
- data/spec/perf/perf_spec_helper.rb +7 -7
- data/spec/perf/store_perf_spec.rb +139 -140
- data/spec/ping/apple_spec.rb +65 -65
- data/spec/ping/gcm_spec.rb +83 -84
- data/spec/ping/rhoconnect_push_spec.rb +52 -53
- data/spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb +100 -101
- data/spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb +29 -31
- data/spec/read_state_spec.rb +24 -25
- data/spec/rhoconnect_spec.rb +7 -7
- data/spec/server/server_spec.rb +664 -662
- data/spec/server/stats_spec.rb +12 -12
- data/spec/source_adapter_spec.rb +124 -125
- data/spec/source_spec.rb +148 -149
- data/spec/source_sync_spec.rb +736 -736
- data/spec/spec_helper.rb +4 -5
- data/spec/stats/record_spec.rb +22 -21
- data/spec/store_orm_spec.rb +48 -48
- data/spec/store_spec.rb +428 -426
- data/spec/support/shared_examples.rb +5 -7
- data/spec/sync_states_spec.rb +67 -67
- data/spec/test_methods_spec.rb +121 -123
- data/spec/testdata/10000-data.txt +0 -0
- data/spec/testdata/5000-data.txt +0 -0
- data/spec/user_spec.rb +102 -102
- data/tasks/redis.rake +3 -3
- metadata +154 -195
- data/bench/benchapp/tmp/pids/passenger.9292.pid.lock +0 -0
- data/bench/benchapp/tmp/restart.txt +0 -0
- data/bench/blobapp/settings/license.key.bak +0 -2
- data/bench/blobapp/tmp/restart.txt +0 -0
- data/bench/lib/testdata/1-data.txt +0 -0
- data/bench/lib/testdata/10-data.txt +0 -0
- data/bench/lib/testdata/2-data.txt +0 -0
- data/bench/lib/testdata/250-data.txt +0 -0
- data/bench/lib/testdata/5-blob_data.txt +0 -0
- data/bench/lib/testdata/5-data.txt +0 -0
- data/bench/lib/testdata/50-data.txt +0 -0
- data/bench/lib/testdata/500-data.txt +0 -0
- data/doc/protocol.html +0 -1993
- data/spec/coverage/rcov/assets/0.2.3/jquery-1.3.2.min.js +0 -19
- data/spec/coverage/rcov/assets/0.2.3/jquery.tablesorter.min.js +0 -15
- data/spec/coverage/rcov/assets/0.2.3/print.css +0 -12
- data/spec/coverage/rcov/assets/0.2.3/rcov.js +0 -42
- data/spec/coverage/rcov/assets/0.2.3/screen.css +0 -270
- data/spec/coverage/rcov/index.html +0 -88
- data/spec/generator/generator_spec_helper.rb +0 -9
|
@@ -6,151 +6,157 @@ describe "Rhoconnect::Controller::JsBase" do
|
|
|
6
6
|
include Rack::Test::Methods
|
|
7
7
|
include Rhoconnect
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => true
|
|
10
|
+
|
|
11
|
+
def app
|
|
12
|
+
@app = Rack::URLMap.new Rhoconnect.url_map
|
|
13
|
+
end
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
def remove_application_controller
|
|
16
|
+
Object.send(:remove_const, :ApplicationController) rescue nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
after(:all) do
|
|
20
|
+
Rhoconnect.use_node = false
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def bootstrap_rhoconnect(jsapp = false)
|
|
24
|
+
Rhoconnect::Server.set :environment, :test
|
|
25
|
+
Rhoconnect::Server.set :secret, "secure!"
|
|
26
|
+
Rhoconnect.use_node = true
|
|
27
|
+
if jsapp
|
|
28
|
+
Rhoconnect.bootstrap(get_jstestapp_path)
|
|
29
|
+
else
|
|
30
|
+
Rhoconnect.bootstrap(get_testapp_path)
|
|
31
|
+
end
|
|
32
|
+
# reload ruby controllers
|
|
33
|
+
Dir[File.join(Rhoconnect.app_directory,'controllers','ruby','*.rb')].each do |controller_file|
|
|
34
|
+
load controller_file
|
|
35
|
+
end
|
|
36
|
+
# reload ruby models
|
|
37
|
+
Dir[File.join(Rhoconnect.app_directory,'models','ruby','*.rb')].each do |model_file|
|
|
38
|
+
load model_file
|
|
16
39
|
end
|
|
40
|
+
end
|
|
17
41
|
|
|
42
|
+
describe "ApplicationController" do
|
|
18
43
|
after(:all) do
|
|
19
|
-
Rhoconnect.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Rhoconnect
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
@
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
it "should push_objects to js controller" do
|
|
136
|
-
s = Source.load('JsSample', @s_params)
|
|
137
|
-
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
138
|
-
post "/app/#{Rhoconnect::API_VERSION}/JsSample/push_objects",
|
|
139
|
-
{:user_id => @u.id, :objects => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
140
|
-
last_response.should be_ok
|
|
141
|
-
verify_doc_result(s, {:md => data, :md_size=>'3'})
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
it "should push_deletes to js controller" do
|
|
145
|
-
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
146
|
-
s = Source.load('JsSample',@s_params)
|
|
147
|
-
set_doc_state(s, {:md => data, :md_size => '3'})
|
|
148
|
-
data.delete('2')
|
|
149
|
-
post "/app/#{Rhoconnect::API_VERSION}/JsSample/push_deletes",
|
|
150
|
-
{:user_id => @u.id, :objects => ['2']}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
151
|
-
last_response.should be_ok
|
|
152
|
-
verify_doc_result(s, {:md => data, :md_size=>'2'})
|
|
153
|
-
end
|
|
44
|
+
Rhoconnect.remove_from_url_map(ApplicationController)
|
|
45
|
+
remove_application_controller
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should call Store api in ApplicationController" do
|
|
49
|
+
Rhoconnect.remove_from_url_map(ApplicationController)
|
|
50
|
+
remove_application_controller
|
|
51
|
+
bootstrap_rhoconnect(true)
|
|
52
|
+
do_post "/rc/#{Rhoconnect::API_VERSION}/app/login", "login" => 'storeapitest', "password" => 'testpass'
|
|
53
|
+
Store.get_value('loginkey').should == 'storeapitest'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should use user defined :node_channel_timeout value for test environment" do
|
|
57
|
+
Rhoconnect.remove_from_url_map(ApplicationController)
|
|
58
|
+
remove_application_controller
|
|
59
|
+
bootstrap_rhoconnect(true)
|
|
60
|
+
Rhoconnect::NodeChannel.timeout.should == 60
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "Named Controller" do
|
|
65
|
+
before(:each) do
|
|
66
|
+
bootstrap_rhoconnect
|
|
67
|
+
do_post "/rc/#{Rhoconnect::API_VERSION}/app/login", "login" => @u.login, "password" => 'testpass'
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should get / of js controller with route overridden" do
|
|
71
|
+
get '/app/v1/JsSample', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
|
72
|
+
last_response.should be_ok
|
|
73
|
+
body = JSON.parse(last_response.body)
|
|
74
|
+
body[2]['count'].should == 1
|
|
75
|
+
body.last['insert'].should == {'1' => {'name' => 'iPhone'}}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should get /custom_route of js controller" do
|
|
79
|
+
get '/app/v1/JsSample/custom_route', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
|
80
|
+
last_response.body.should == 'testuser'
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should get /source from custom route" do
|
|
84
|
+
get '/app/v1/JsSample/custom_route2', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
|
85
|
+
last_response.body.should == 'JsSample'
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should get stash_result from js model" do
|
|
89
|
+
pending "stash_result not supported yet"
|
|
90
|
+
get '/app/v1/JsSample/custom_route3',{}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
|
91
|
+
res = JSON.parse(last_response.body)
|
|
92
|
+
res[2]["count"].should == 1
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "should register sync route" do
|
|
96
|
+
get '/app/v1/Sample2', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
|
97
|
+
res = JSON.parse(last_response.body)
|
|
98
|
+
res[2]["count"].should == 1
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should post to js controller" do
|
|
102
|
+
hsh = {'1'=>{'name'=>'testname','price'=>'$199'}}
|
|
103
|
+
post '/app/v1/JsSample',hsh, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
|
104
|
+
last_response.should be_ok
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "should put to js controller" do
|
|
108
|
+
put '/app/v1/JsSample/2', {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
|
109
|
+
last_response.body.should == ''
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "should delete to js controller" do
|
|
113
|
+
@c1 = Client.create({:user_id => @u.id,:app_id => @a.id},{:source_name => 'JsSample'})
|
|
114
|
+
set_doc_state(@c1, :cd => @data)
|
|
115
|
+
delete '/app/v1/JsSample/2', {}, {Rhoconnect::CLIENT_ID_HEADER => @c1.id}
|
|
116
|
+
last_response.should be_ok
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it "should call route that overrides default option" do
|
|
120
|
+
get '/app/v1/JsSample/no_client_route', {}
|
|
121
|
+
last_response.should be_ok
|
|
122
|
+
last_response.body.should == 'no client required!'
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "should upload blob in multipart post" do
|
|
126
|
+
file1,file2 = 'upload1.txt'
|
|
127
|
+
@product1['txtfile-rhoblob'] = file1
|
|
128
|
+
@product1['_id'] = 'tempobj1'
|
|
129
|
+
cud = {'create'=>{'1'=>{'name'=>'hello'}},
|
|
130
|
+
:blob_fields => ['txtfile-rhoblob']}.to_json
|
|
131
|
+
post "/app/#{Rhoconnect::API_VERSION}/JsSample",
|
|
132
|
+
{:cud => cud,'txtfile-rhoblob-1' =>
|
|
133
|
+
Rack::Test::UploadedFile.new(File.join(File.dirname(__FILE__),'..','testdata',file1), "application/octet-stream")},
|
|
134
|
+
{Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
|
135
|
+
last_response.should be_ok
|
|
136
|
+
get "/app/#{Rhoconnect::API_VERSION}/JsSample", {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
|
137
|
+
json = JSON.parse(last_response.body)
|
|
138
|
+
json[5]['links'].should == { "1" => { "l" => "blob_created" } }
|
|
139
|
+
json[5]['delete'].should == { "blob_created" => { "name" => "hello", "txtfile-rhoblob" => "blob_created" } }
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "should push_objects to js controller" do
|
|
143
|
+
s = Source.load('JsSample', @s_params)
|
|
144
|
+
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
145
|
+
post "/app/#{Rhoconnect::API_VERSION}/JsSample/push_objects",
|
|
146
|
+
{:user_id => @u.id, :objects => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
147
|
+
last_response.should be_ok
|
|
148
|
+
verify_doc_result(s, {:md => data, :md_size=>'3'})
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "should push_deletes to js controller" do
|
|
152
|
+
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
153
|
+
s = Source.load('JsSample',@s_params)
|
|
154
|
+
set_doc_state(s, {:md => data, :md_size => '3'})
|
|
155
|
+
data.delete('2')
|
|
156
|
+
post "/app/#{Rhoconnect::API_VERSION}/JsSample/push_deletes",
|
|
157
|
+
{:user_id => @u.id, :objects => ['2']}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
158
|
+
last_response.should be_ok
|
|
159
|
+
verify_doc_result(s, {:md => data, :md_size=>'2'})
|
|
154
160
|
end
|
|
155
161
|
end
|
|
156
162
|
end
|
data/spec/doc/doc_spec.rb
CHANGED
|
@@ -5,11 +5,11 @@ require 'rspec/autorun'
|
|
|
5
5
|
require File.join(File.dirname(__FILE__),'..','spec_helper')
|
|
6
6
|
require File.join(File.dirname(__FILE__),'..','..','lib','rhoconnect','server.rb')
|
|
7
7
|
|
|
8
|
-
describe "Protocol" do
|
|
8
|
+
describe "Protocol" do
|
|
9
9
|
include Rack::Test::Methods
|
|
10
|
-
include Rhoconnect
|
|
10
|
+
include Rhoconnect
|
|
11
11
|
include TestHelpers
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
let(:test_app_name) { 'application' }
|
|
14
14
|
|
|
15
15
|
let(:source) { 'Product' }
|
|
@@ -17,10 +17,10 @@ describe "Protocol" do
|
|
|
17
17
|
let(:client_id) { 1 }
|
|
18
18
|
let(:product1) { {'name' => 'iPhone', 'brand' => 'Apple', 'price' => '199.99'} }
|
|
19
19
|
let(:product2) { {'name' => 'G2', 'brand' => 'Android', 'price' => '99.99'} }
|
|
20
|
-
let(:product3) { {'name' => 'Fuze', 'brand' => 'HTC', 'price' => '299.99'} }
|
|
20
|
+
let(:product3) { {'name' => 'Fuze', 'brand' => 'HTC', 'price' => '299.99'} }
|
|
21
21
|
let(:product4) { {'name' => 'Droid', 'brand' => 'Android', 'price' => '249.99'} }
|
|
22
22
|
let(:products) { {'1' => product1,'2' => product2,'3'=> product3} }
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
before(:all) do
|
|
25
25
|
Rhoconnect.bootstrap(get_testapp_path) do |rhoconnect|
|
|
26
26
|
rhoconnect.vendor_directory = File.join(File.dirname(__FILE__),'..','vendor')
|
|
@@ -31,21 +31,20 @@ describe "Protocol" do
|
|
|
31
31
|
Store.create
|
|
32
32
|
Store.flush_all
|
|
33
33
|
end
|
|
34
|
-
|
|
35
|
-
# it_should_behave_like "DBObjectsHelper"
|
|
34
|
+
|
|
36
35
|
before(:each) do
|
|
37
36
|
@a_fields = { :name => test_app_name }
|
|
38
37
|
# @a = App.create(@a_fields)
|
|
39
38
|
@a = (App.load(test_app_name) || App.create(@a_fields))
|
|
40
39
|
@u_fields = {:login => 'testuser'}
|
|
41
|
-
@u = User.create(@u_fields)
|
|
40
|
+
@u = User.create(@u_fields)
|
|
42
41
|
@u.password = 'testpass'
|
|
43
42
|
@c_fields = {
|
|
44
43
|
:device_type => 'Apple',
|
|
45
44
|
:device_pin => 'abcd',
|
|
46
45
|
:device_port => '3333',
|
|
47
46
|
:user_id => @u.id,
|
|
48
|
-
:app_id => @a.id
|
|
47
|
+
:app_id => @a.id
|
|
49
48
|
}
|
|
50
49
|
@s_fields = {
|
|
51
50
|
:name => 'SampleAdapter',
|
|
@@ -70,9 +69,9 @@ describe "Protocol" do
|
|
|
70
69
|
Source.update_associations(@a.sources)
|
|
71
70
|
@a.users << @u.id
|
|
72
71
|
end
|
|
73
|
-
|
|
72
|
+
|
|
74
73
|
Rhoconnect.log_disabled = true
|
|
75
|
-
|
|
74
|
+
|
|
76
75
|
before(:each) do
|
|
77
76
|
$rand_id ||= 0
|
|
78
77
|
$content_table ||= []
|
|
@@ -85,58 +84,58 @@ describe "Protocol" do
|
|
|
85
84
|
Rhoconnect::Server.set :run, false
|
|
86
85
|
Rhoconnect::Server.set :secret, "secure!"
|
|
87
86
|
end
|
|
88
|
-
|
|
87
|
+
|
|
89
88
|
before(:each) do
|
|
90
89
|
do_post "/#{@a.name}/clientlogin", "login" => @u.login, "password" => 'testpass'
|
|
91
90
|
@title,@description = nil,nil
|
|
92
91
|
$rand_id += 1
|
|
93
92
|
end
|
|
94
|
-
|
|
93
|
+
|
|
95
94
|
def app
|
|
96
95
|
@app ||= Rhoconnect::Server.new
|
|
97
96
|
end
|
|
98
|
-
|
|
97
|
+
|
|
99
98
|
after(:each) do
|
|
100
99
|
#_print_messages
|
|
101
100
|
_print_markdown if @title and @description
|
|
102
101
|
end
|
|
103
|
-
|
|
102
|
+
|
|
104
103
|
after(:all) do
|
|
105
104
|
_write_doc if $content and $content.length > 0
|
|
106
105
|
end
|
|
107
|
-
|
|
106
|
+
|
|
108
107
|
it "clientlogin" do
|
|
109
108
|
do_post "/#{@a.name}/clientlogin", "login" => @u.login, "password" => 'testpass'
|
|
110
109
|
@title,@description = 'clientlogin', 'authenticate client'
|
|
111
110
|
end
|
|
112
|
-
|
|
111
|
+
|
|
113
112
|
it "wrong login or password clientlogin" do
|
|
114
113
|
do_post "/#{@a.name}/clientlogin", "login" => @u.login, "password" => 'wrongpass'
|
|
115
114
|
@title,@description = 'clientlogin', 'login failure'
|
|
116
115
|
end
|
|
117
|
-
|
|
118
|
-
it "clientcreate" do
|
|
116
|
+
|
|
117
|
+
it "clientcreate" do
|
|
119
118
|
get "/#{@a.name}/clientcreate"
|
|
120
|
-
@title,@description = 'clientcreate', 'create client id'
|
|
119
|
+
@title,@description = 'clientcreate', 'create client id'
|
|
121
120
|
end
|
|
122
|
-
|
|
123
|
-
it "clientcreate" do
|
|
121
|
+
|
|
122
|
+
it "clientcreate" do
|
|
124
123
|
get "/#{@a.name}/clientcreate?device_type=iPhone&device_pin=abcd&device_port=3333"
|
|
125
|
-
@title,@description = 'clientcreate-and-register', 'create client id with register params'
|
|
124
|
+
@title,@description = 'clientcreate-and-register', 'create client id with register params'
|
|
126
125
|
end
|
|
127
|
-
|
|
126
|
+
|
|
128
127
|
it "clientregister" do
|
|
129
|
-
do_post "/#{@a.name}/clientregister",
|
|
130
|
-
"device_type" => "iPhone", "device_pin" => "abcd",
|
|
128
|
+
do_post "/#{@a.name}/clientregister",
|
|
129
|
+
"device_type" => "iPhone", "device_pin" => "abcd",
|
|
131
130
|
"device_port" => "3333", "client_id" => @c.id
|
|
132
|
-
@title,@description = 'clientregister', 'register client with params'
|
|
131
|
+
@title,@description = 'clientregister', 'register client with params'
|
|
133
132
|
end
|
|
134
|
-
|
|
133
|
+
|
|
135
134
|
it "clientreset" do
|
|
136
135
|
get "/#{@a.name}/clientreset", :client_id => @c.id
|
|
137
136
|
@title,@description = 'clientreset', 'reset client database'
|
|
138
137
|
end
|
|
139
|
-
|
|
138
|
+
|
|
140
139
|
['create','update','delete'].each do |operation|
|
|
141
140
|
it "client #{operation} object(s)" do
|
|
142
141
|
params = {operation=>{'1'=>product1},
|
|
@@ -146,7 +145,7 @@ describe "Protocol" do
|
|
|
146
145
|
@title,@description = operation, "#{operation} object(s)"
|
|
147
146
|
end
|
|
148
147
|
end
|
|
149
|
-
|
|
148
|
+
|
|
150
149
|
it "client creates blobs" do
|
|
151
150
|
body = <<eol
|
|
152
151
|
<pre>------------XnJLe9ZIbbGUYtzPQJ16u1
|
|
@@ -167,7 +166,7 @@ Content-Disposition: form-data; name="cud"
|
|
|
167
166
|
{"client_id":"278c76a7ab2a4f64ba804c1aa22504f3","source_name":"SampleAdapter","version":3,"create":{"1":{"price":"199.99","brand":"Apple","name":"iPhone","txtfile-rhoblob":"upload1.txt","_id":"tempobj1"},"2":{"price":"99.99","brand":"Android","name":"G2","txtfile-rhoblob":"upload2.txt","_id":"tempobj2"}},"blob_fields":["txtfile-rhoblob"]}
|
|
168
167
|
------------XnJLe9ZIbbGUYtzPQJ16u1--</pre>
|
|
169
168
|
eol
|
|
170
|
-
@title,@description = 'create', 'client creates blobs'
|
|
169
|
+
@title,@description = 'create', 'client creates blobs'
|
|
171
170
|
$content_table << {$rand_id => "#{@title} - #{@description}"}
|
|
172
171
|
data = {
|
|
173
172
|
:title => @title,
|
|
@@ -187,9 +186,9 @@ eol
|
|
|
187
186
|
:res_body => ''
|
|
188
187
|
}
|
|
189
188
|
$content << data
|
|
190
|
-
@title,@description = nil,nil
|
|
189
|
+
@title,@description = nil,nil
|
|
191
190
|
end
|
|
192
|
-
|
|
191
|
+
|
|
193
192
|
it "client create,update,delete objects" do
|
|
194
193
|
params = {'create'=>{'1'=>product1},
|
|
195
194
|
'update'=>{'2'=>product2},
|
|
@@ -199,7 +198,7 @@ eol
|
|
|
199
198
|
do_post "/#{@a.name}", params
|
|
200
199
|
@title,@description = 'create-update-delete', 'create,update,delete object(s)'
|
|
201
200
|
end
|
|
202
|
-
|
|
201
|
+
|
|
203
202
|
it "server sends link created object" do
|
|
204
203
|
product4['link'] = 'test link'
|
|
205
204
|
params = {'create'=>{'4'=>product4},
|
|
@@ -210,25 +209,25 @@ eol
|
|
|
210
209
|
:version => Rhoconnect::SYNC_VERSION
|
|
211
210
|
@title,@description = 'create-with-link', 'send link for created object'
|
|
212
211
|
end
|
|
213
|
-
|
|
212
|
+
|
|
214
213
|
it "server send source query error to client" do
|
|
215
214
|
set_test_data('test_db_storage',{},"Error during query",'query error')
|
|
216
215
|
get "/#{@a.name}",:client_id => @c.id,:source_name => @s.name,:version => Rhoconnect::SYNC_VERSION
|
|
217
216
|
@title,@description = 'query-error', 'send query error'
|
|
218
217
|
end
|
|
219
|
-
|
|
218
|
+
|
|
220
219
|
it "server send source login error to client" do
|
|
221
220
|
@u.login = nil
|
|
222
221
|
get "/#{@a.name}",:client_id => @c.id,:source_name => @s.name,:version => Rhoconnect::SYNC_VERSION
|
|
223
222
|
@title,@description = 'login-error', 'send login error'
|
|
224
223
|
end
|
|
225
|
-
|
|
224
|
+
|
|
226
225
|
it "server send source logoff error to client" do
|
|
227
226
|
set_test_data('test_db_storage',{},"Error logging off",'logoff error')
|
|
228
227
|
get "/#{@a.name}",:client_id => @c.id,:source_name => @s.name,:version => Rhoconnect::SYNC_VERSION
|
|
229
228
|
@title,@description = 'logoff-error', 'send logoff error'
|
|
230
229
|
end
|
|
231
|
-
|
|
230
|
+
|
|
232
231
|
['create','update','delete'].each do |operation|
|
|
233
232
|
it "client #{operation} object(s) with error" do
|
|
234
233
|
if operation == 'update'
|
|
@@ -244,7 +243,7 @@ eol
|
|
|
244
243
|
@title,@description = "#{operation}-error", "send #{operation} error"
|
|
245
244
|
end
|
|
246
245
|
end
|
|
247
|
-
|
|
246
|
+
|
|
248
247
|
it "server send insert objects to client" do
|
|
249
248
|
cs = ClientSync.new(@s,@c,1)
|
|
250
249
|
data = {'1'=>product1,'2'=>product2}
|
|
@@ -252,7 +251,7 @@ eol
|
|
|
252
251
|
get "/#{@a.name}",:client_id => @c.id,:source_name => @s.name,:version => Rhoconnect::SYNC_VERSION
|
|
253
252
|
@title,@description = 'insert objects', 'send insert objects'
|
|
254
253
|
end
|
|
255
|
-
|
|
254
|
+
|
|
256
255
|
it "server send metadata to client" do
|
|
257
256
|
mock_metadata_method([SampleAdapter]) do
|
|
258
257
|
cs = ClientSync.new(@s,@c,1)
|
|
@@ -261,8 +260,8 @@ eol
|
|
|
261
260
|
end
|
|
262
261
|
@title,@description = 'metadata', 'send metadata'
|
|
263
262
|
end
|
|
264
|
-
|
|
265
|
-
it "server send delete objects to client" do
|
|
263
|
+
|
|
264
|
+
it "server send delete objects to client" do
|
|
266
265
|
cs = ClientSync.new(@s,@c,1)
|
|
267
266
|
data = {'1'=>product1,'2'=>product2}
|
|
268
267
|
set_test_data('test_db_storage',data)
|
|
@@ -274,8 +273,8 @@ eol
|
|
|
274
273
|
:version => Rhoconnect::SYNC_VERSION
|
|
275
274
|
@title,@description = 'delete objects', 'send delete objects'
|
|
276
275
|
end
|
|
277
|
-
|
|
278
|
-
it "server send insert,delete objects to client" do
|
|
276
|
+
|
|
277
|
+
it "server send insert,delete objects to client" do
|
|
279
278
|
cs = ClientSync.new(@s,@c,1)
|
|
280
279
|
data = {'1'=>product1,'2'=>product2}
|
|
281
280
|
set_test_data('test_db_storage',data)
|
|
@@ -287,7 +286,7 @@ eol
|
|
|
287
286
|
:version => Rhoconnect::SYNC_VERSION
|
|
288
287
|
@title,@description = 'insert-delete objects', 'send insert and delete objects'
|
|
289
288
|
end
|
|
290
|
-
|
|
289
|
+
|
|
291
290
|
it "server send search results" do
|
|
292
291
|
sources = [{:name=>'SampleAdapter'}]
|
|
293
292
|
Store.put_data('test_db_storage',products)
|
|
@@ -296,7 +295,7 @@ eol
|
|
|
296
295
|
get "/#{@a.name}/search",params
|
|
297
296
|
@title,@description = 'search result', 'send search results'
|
|
298
297
|
end
|
|
299
|
-
|
|
298
|
+
|
|
300
299
|
it "should get search results with error" do
|
|
301
300
|
sources = [{:name=>'SampleAdapter'}]
|
|
302
301
|
msg = "Error during search"
|
|
@@ -306,7 +305,7 @@ eol
|
|
|
306
305
|
get "/#{@a.name}/search",params
|
|
307
306
|
@title,@description = 'search error', 'send search error'
|
|
308
307
|
end
|
|
309
|
-
|
|
308
|
+
|
|
310
309
|
it "should get multiple source search results" do
|
|
311
310
|
Store.put_data('test_db_storage',products)
|
|
312
311
|
sources = [{:name=>'SimpleAdapter'},{:name=>'SampleAdapter'}]
|
|
@@ -314,8 +313,8 @@ eol
|
|
|
314
313
|
:version => Rhoconnect::SYNC_VERSION}
|
|
315
314
|
get "/#{@a.name}/search",params
|
|
316
315
|
@title,@description = 'multi source search', 'send multiple sources in search results'
|
|
317
|
-
end
|
|
318
|
-
|
|
316
|
+
end
|
|
317
|
+
|
|
319
318
|
it "should ack multiple sources search results" do
|
|
320
319
|
set_test_data('test_db_storage',products)
|
|
321
320
|
sources = [{'name'=>'SimpleAdapter'},{'name'=>'SampleAdapter'}]
|
|
@@ -332,7 +331,7 @@ eol
|
|
|
332
331
|
get "/#{@a.name}/search",params
|
|
333
332
|
@title,@description = 'multi source search ack', 'acknowledge search result on multiple sources'
|
|
334
333
|
end
|
|
335
|
-
|
|
334
|
+
|
|
336
335
|
private
|
|
337
336
|
def _print_markdown
|
|
338
337
|
$content_table << {$rand_id => "#{@title} - #{@description}"}
|
|
@@ -356,7 +355,7 @@ eol
|
|
|
356
355
|
last_request.body.rewind
|
|
357
356
|
$content << data
|
|
358
357
|
end
|
|
359
|
-
|
|
358
|
+
|
|
360
359
|
def _write_doc
|
|
361
360
|
File.open(File.join('doc','protocol.html'),'w') do |file|
|
|
362
361
|
header = ERB.new(File.read(File.join(File.dirname(__FILE__),'header.html'))).result(binding)
|
|
@@ -369,7 +368,7 @@ eol
|
|
|
369
368
|
file.write(footer)
|
|
370
369
|
end
|
|
371
370
|
end
|
|
372
|
-
|
|
371
|
+
|
|
373
372
|
def _get_header_text(header)
|
|
374
373
|
header ? header : ' '
|
|
375
374
|
end
|