rhoconnect 3.4.5 → 4.0.0.beta.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +57 -3
- data/Gemfile +9 -7
- data/Gemfile.lock +37 -37
- data/Rakefile +18 -7
- data/bench/benchapp/Gemfile +1 -1
- data/bench/benchapp/config.ru +0 -3
- data/bench/benchapp/controllers/ruby/application.rb +17 -0
- data/bench/benchapp/controllers/ruby/application_controller.rb +17 -0
- data/bench/benchapp/controllers/ruby/mock_adapter_controller.rb +8 -0
- data/bench/benchapp/controllers/ruby/queue_mock_adapter_controller.rb +8 -0
- data/bench/benchapp/{sources → models/ruby}/mock_adapter.rb +1 -1
- data/bench/benchapp/{sources → models/ruby}/queue_mock_adapter.rb +0 -0
- data/bench/benchapp/spec/{sources → models/ruby}/mock_adapter_spec.rb +1 -1
- data/bench/benchapp/spec/{sources → models/ruby}/queue_mock_adapter_spec.rb +1 -1
- data/bench/benchapp/spec/spec_helper.rb +2 -2
- data/bench/blobapp/Gemfile +1 -1
- data/bench/blobapp/config.ru +0 -3
- data/bench/blobapp/controllers/ruby/application_controller.rb +17 -0
- data/bench/blobapp/controllers/ruby/blob_adapter_controller.rb +8 -0
- data/bench/blobapp/{sources → models/ruby}/blob_adapter.rb +9 -2
- data/bench/blobapp/spec/{sources → models/ruby}/blob_adapter_spec.rb +1 -1
- data/bench/blobapp/spec/spec_helper.rb +1 -1
- data/bench/lib/bench/cli.rb +1 -1
- data/bench/scripts/blob_cud_script.rb +1 -1
- data/bench/scripts/query_md_script.rb +1 -1
- data/bench/scripts/query_only_script.rb +1 -1
- data/bench/scripts/query_script.rb +1 -1
- data/bench/scripts/test_query_script.rb +7 -1
- data/bench/spec/mock_adapter_spec.rb +1 -1
- data/bench/spec/result_spec.rb +3 -3
- data/bin/rhoconnect +5 -3
- data/commands/dtach/dtach_install.rb +2 -2
- data/commands/execute.rb +8 -3
- data/commands/generators/app.rb +3 -3
- data/commands/generators/controller.rb +6 -0
- data/commands/generators/model.rb +6 -0
- data/commands/generators/source.rb +3 -3
- data/commands/generators/update.rb +1 -1
- data/commands/redis/redis_about.rb +2 -2
- data/commands/redis/redis_download.rb +1 -1
- data/commands/redis/redis_install.rb +4 -3
- data/commands/redis/redis_restart.rb +4 -4
- data/commands/redis/redis_start.rb +5 -4
- data/commands/redis/redis_startbg.rb +5 -4
- data/commands/redis/redis_status.rb +13 -0
- data/commands/redis/redis_stop.rb +3 -3
- data/commands/rhoconnect/config.rb +28 -16
- data/commands/rhoconnect/flushdb.rb +1 -2
- data/commands/rhoconnect/get_token.rb +15 -11
- data/commands/rhoconnect/restart.rb +13 -5
- data/commands/rhoconnect/set_admin_password.rb +8 -8
- data/commands/rhoconnect/start.rb +74 -16
- data/commands/rhoconnect/startbg.rb +1 -1
- data/commands/rhoconnect/startdebug.rb +1 -1
- data/commands/rhoconnect/stop.rb +13 -1
- data/commands/rhoconnect/web.rb +5 -5
- data/commands/rhoconnect_console/console.rb +7 -5
- data/commands/{rhoconnect → rhoconnect_spec}/spec.rb +0 -0
- data/commands/rhoconnect_war/war.rb +9 -9
- data/commands/utilities/blank_app.ru +56 -0
- data/commands/utilities/redis_runner.rb +54 -19
- data/doc/authentication.txt +80 -6
- data/doc/blob-sync.txt +104 -97
- data/doc/bulk-sync.txt +1 -1
- data/doc/client-java.txt +3 -3
- data/doc/client-objc.txt +2 -2
- data/doc/client.txt +4 -4
- data/doc/command-line.txt +105 -200
- data/doc/data-partitioning.txt +40 -0
- data/doc/deploying.txt +249 -77
- data/doc/extending-rhoconnect-server.txt +40 -57
- data/doc/heroku-addon.txt +2 -0
- data/doc/install.txt +45 -95
- data/doc/introduction.txt +1 -1
- data/doc/java-plugin.txt +365 -190
- data/doc/metadata.txt +1 -1
- data/doc/migration.txt +108 -142
- data/doc/preparing-production.txt +1 -1
- data/doc/push-backend-setup.txt +2 -0
- data/doc/push-client-setup-android.txt +78 -0
- data/doc/push-client-setup-bb.txt +81 -0
- data/doc/push-client-setup-ios.txt +70 -0
- data/doc/push-client-setup-rps.txt +200 -0
- data/doc/push-client-setup.txt +63 -66
- data/doc/push-server-setup.txt +67 -40
- data/doc/push-testing.txt +29 -0
- data/doc/push.txt +21 -6
- data/doc/rest-api.txt +128 -55
- data/doc/rhoconnect-redis-stack.txt +120 -0
- data/doc/settings.txt +4 -12
- data/doc/source-adapters-intro.txt +28 -0
- data/doc/source-adapters.txt +235 -272
- data/doc/stats-middleware.txt +9 -29
- data/doc/supported-platforms.txt +21 -30
- data/doc/testing.txt +40 -42
- data/doc/tutorial.txt +72 -57
- data/examples/simple/Gemfile +1 -1
- data/examples/simple/application.rb +4 -5
- data/examples/simple/my_server.rb +2 -2
- data/examples/simple/settings/settings.yml +1 -1
- data/generators/rhoconnect.rb +151 -50
- data/generators/templates/application/Gemfile +1 -1
- data/generators/templates/application/Rakefile +3 -3
- data/generators/templates/application/config.ru +1 -4
- data/generators/templates/application/controllers/application_controller.rb +17 -0
- data/generators/templates/application/controllers/js/application_controller.js +14 -0
- data/generators/templates/application/controllers/ruby/application_controller.rb +17 -0
- data/generators/templates/application/package.json +8 -0
- data/generators/templates/application/rcgemfile +2 -5
- data/generators/templates/application/settings/settings.yml +3 -3
- data/generators/templates/application/spec/application_controller_spec.rb +23 -0
- data/generators/templates/application/spec/js_spec.rb +25 -0
- data/generators/templates/application/spec/spec_helper.rb +21 -7
- data/generators/templates/source/controllers/js/controller.js +7 -0
- data/generators/templates/source/controllers/ruby/controller.rb +8 -0
- data/generators/templates/source/controllers/ruby/controller_spec.rb +27 -0
- data/generators/templates/source/models/js/model.js +46 -0
- data/generators/templates/source/{source_adapter.rb → models/ruby/model.rb} +15 -10
- data/generators/templates/source/{source_spec.rb → models/ruby/model_spec.rb} +1 -1
- data/install.sh +5 -5
- data/installer/unix-like/create_texts.rb +2 -2
- data/installer/unix-like/rho_connect_install_constants.rb +2 -2
- data/installer/unix-like/rho_connect_install_utilities.rb +1 -1
- data/installer/utils/constants.rb +4 -4
- data/js-adapters/ballroom.js +216 -0
- data/js-adapters/node.rb +52 -0
- data/js-adapters/node_channel.rb +181 -0
- data/js-adapters/request.js +27 -0
- data/js-adapters/response.js +57 -0
- data/js-adapters/rhoconnect_helpers.js +60 -0
- data/js-adapters/router.js +60 -0
- data/js-adapters/server.js +5 -0
- data/lib/rhoconnect/api/app/ans_login.rb +3 -3
- data/lib/rhoconnect/api/app/bulk_data.rb +10 -10
- data/lib/rhoconnect/api/app/fast_delete.rb +11 -10
- data/lib/rhoconnect/api/app/fast_insert.rb +11 -10
- data/lib/rhoconnect/api/app/fast_update.rb +11 -10
- data/lib/rhoconnect/api/app/login.rb +5 -5
- data/lib/rhoconnect/api/app/push_deletes.rb +12 -11
- data/lib/rhoconnect/api/app/push_objects.rb +12 -11
- data/lib/rhoconnect/api/app/query.rb +8 -7
- data/lib/rhoconnect/api/app/queue_updates.rb +98 -94
- data/lib/rhoconnect/api/app/search.rb +8 -7
- data/lib/rhoconnect/api/client/client_get_db_doc.rb +5 -5
- data/lib/rhoconnect/api/client/client_set_db_doc.rb +8 -8
- data/lib/rhoconnect/api/client/create.rb +7 -7
- data/lib/rhoconnect/api/client/get_client_params.rb +4 -4
- data/lib/rhoconnect/api/client/list_client_docs.rb +17 -17
- data/lib/rhoconnect/api/client/register.rb +12 -12
- data/lib/rhoconnect/api/client/reset.rb +5 -5
- data/lib/rhoconnect/api/readstate/set_refresh_time.rb +9 -9
- data/lib/rhoconnect/api/source/get_source_params.rb +4 -4
- data/lib/rhoconnect/api/source/list_sources.rb +16 -16
- data/lib/rhoconnect/api/source/update_source_params.rb +6 -6
- data/lib/rhoconnect/api/store/get_db_doc.rb +4 -4
- data/lib/rhoconnect/api/store/set_db_doc.rb +7 -7
- data/lib/rhoconnect/api/system/get_adapter.rb +4 -4
- data/lib/rhoconnect/api/system/get_license_info.rb +8 -8
- data/lib/rhoconnect/api/system/login.rb +15 -15
- data/lib/rhoconnect/api/system/reset.rb +11 -11
- data/lib/rhoconnect/api/system/save_adapter.rb +4 -4
- data/lib/rhoconnect/api/system/stats.rb +22 -22
- data/lib/rhoconnect/api/user/create_user.rb +7 -7
- data/lib/rhoconnect/api/user/delete_client.rb +6 -6
- data/lib/rhoconnect/api/user/delete_user.rb +11 -10
- data/lib/rhoconnect/api/user/list_clients.rb +4 -4
- data/lib/rhoconnect/api/user/list_source_docs.rb +10 -10
- data/lib/rhoconnect/api/user/list_users.rb +3 -3
- data/lib/rhoconnect/api/user/ping.rb +3 -3
- data/lib/rhoconnect/api/user/show_user.rb +3 -3
- data/lib/rhoconnect/api/user/update_user.rb +5 -5
- data/lib/rhoconnect/api/user/user_get_db_doc.rb +5 -5
- data/lib/rhoconnect/api/user/user_set_db_doc.rb +10 -10
- data/lib/rhoconnect/api_token.rb +5 -6
- data/lib/rhoconnect/app.rb +6 -46
- data/lib/rhoconnect/application/init.rb +5 -2
- data/lib/rhoconnect/async.rb +76 -39
- data/lib/rhoconnect/bulk_data/bulk_data.rb +6 -4
- data/lib/rhoconnect/client.rb +59 -9
- data/lib/rhoconnect/condition/admin_required.rb +27 -0
- data/lib/rhoconnect/condition/client_required.rb +50 -0
- data/lib/rhoconnect/condition/login_required.rb +22 -0
- data/lib/rhoconnect/condition/source_required.rb +49 -0
- data/lib/rhoconnect/condition/verbs.rb +17 -0
- data/lib/rhoconnect/condition/verify_success.rb +19 -0
- data/lib/rhoconnect/controller/app_base.rb +74 -0
- data/lib/rhoconnect/controller/base.rb +68 -0
- data/lib/rhoconnect/controller/clients_controller.rb +79 -0
- data/lib/rhoconnect/controller/dynamic_adapter_controller.rb +93 -0
- data/lib/rhoconnect/controller/js_base.rb +124 -0
- data/lib/rhoconnect/controller/read_state_controller.rb +22 -0
- data/lib/rhoconnect/controller/source_adapter_base.rb +14 -0
- data/lib/rhoconnect/controller/sources_controller.rb +44 -0
- data/lib/rhoconnect/controller/store_controller.rb +25 -0
- data/lib/rhoconnect/controller/system_controller.rb +67 -0
- data/lib/rhoconnect/controller/users_controller.rb +99 -0
- data/lib/rhoconnect/db_adapter.rb +1 -3
- data/lib/rhoconnect/document.rb +159 -50
- data/lib/rhoconnect/handler/authenticate/execute_methods.rb +77 -0
- data/lib/rhoconnect/handler/authenticate/runner.rb +49 -0
- data/lib/rhoconnect/handler/authenticate.rb +3 -0
- data/lib/rhoconnect/handler/bulk_data.rb +28 -0
- data/lib/rhoconnect/handler/changes/engine.rb +271 -0
- data/lib/rhoconnect/handler/changes/execute_methods.rb +88 -0
- data/lib/rhoconnect/handler/changes/pass_through_runner.rb +11 -0
- data/lib/rhoconnect/handler/changes/runner.rb +53 -0
- data/lib/rhoconnect/handler/changes.rb +31 -0
- data/lib/rhoconnect/handler/helpers/auth_method.rb +29 -0
- data/lib/rhoconnect/handler/helpers/binding.rb +18 -0
- data/lib/rhoconnect/handler/helpers/bulk_data.rb +53 -0
- data/lib/rhoconnect/handler/helpers/source_job.rb +14 -0
- data/lib/rhoconnect/handler/helpers.rb +4 -0
- data/lib/rhoconnect/handler/plugin_callbacks/execute_methods.rb +99 -0
- data/lib/rhoconnect/handler/plugin_callbacks/runner.rb +28 -0
- data/lib/rhoconnect/handler/plugin_callbacks.rb +67 -0
- data/lib/rhoconnect/handler/query/engine.rb +93 -0
- data/lib/rhoconnect/handler/query/execute_methods.rb +21 -0
- data/lib/rhoconnect/handler/query/pass_through_runner.rb +35 -0
- data/lib/rhoconnect/handler/query/runner.rb +270 -0
- data/lib/rhoconnect/handler/query.rb +19 -0
- data/lib/rhoconnect/handler/search/engine.rb +60 -0
- data/lib/rhoconnect/handler/search/execute_methods.rb +32 -0
- data/lib/rhoconnect/handler/search/pass_through_runner.rb +18 -0
- data/lib/rhoconnect/handler/search/runner.rb +104 -0
- data/lib/rhoconnect/handler/search.rb +26 -0
- data/lib/rhoconnect/handler/sync.rb +29 -0
- data/lib/rhoconnect/jobs/source_job.rb +13 -4
- data/lib/rhoconnect/js_adapter.rb +79 -0
- data/lib/rhoconnect/license.rb +10 -2
- data/lib/rhoconnect/middleware/current_user.rb +14 -1
- data/lib/rhoconnect/middleware/helpers.rb +10 -93
- data/lib/rhoconnect/middleware/x_domain_session_wrapper.rb +1 -1
- data/lib/rhoconnect/model/base.rb +229 -0
- data/lib/rhoconnect/model/dynamic_adapter_model.rb +90 -0
- data/lib/rhoconnect/model/js_base.rb +121 -0
- data/lib/rhoconnect/ping/android.rb +1 -1
- data/lib/rhoconnect/predefined_adapters/bench_adapter.rb +7 -4
- data/lib/rhoconnect/read_state.rb +3 -3
- data/lib/rhoconnect/server.rb +159 -190
- data/lib/rhoconnect/source.rb +100 -11
- data/lib/rhoconnect/stats/record.rb +10 -10
- data/lib/rhoconnect/store.rb +905 -591
- data/lib/rhoconnect/{model.rb → store_orm.rb} +53 -115
- data/lib/rhoconnect/tasks.rb +18 -4
- data/lib/rhoconnect/test_methods.rb +30 -17
- data/lib/rhoconnect/user.rb +35 -17
- data/lib/rhoconnect/utilities.rb +1 -1
- data/lib/rhoconnect/version.rb +2 -2
- data/lib/rhoconnect/web-console/server.rb +29 -14
- data/lib/rhoconnect/web-console/views/home.js +10 -10
- data/lib/rhoconnect/web-console/views/new_ping.js +1 -1
- data/lib/rhoconnect.rb +120 -51
- data/rhoconnect.gemspec +4 -3
- data/spec/api/api_helper.rb +1 -6
- data/spec/api/app/fast_delete_spec.rb +4 -4
- data/spec/api/app/fast_insert_spec.rb +4 -4
- data/spec/api/app/fast_update_spec.rb +8 -8
- data/spec/api/app/push_deletes_spec.rb +2 -2
- data/spec/api/app/push_objects_spec.rb +5 -5
- data/spec/api/client/client_get_db_doc_spec.rb +6 -4
- data/spec/api/client/client_set_db_doc_spec.rb +3 -2
- data/spec/api/client/get_client_params_spec.rb +14 -0
- data/spec/api/client/list_client_docs_spec.rb +30 -20
- data/spec/api/client/reset_spec.rb +36 -0
- data/spec/api/source/get_source_params_spec.rb +23 -17
- data/spec/api/system/get_license_info_spec.rb +0 -20
- data/spec/api/system/login_spec.rb +8 -0
- data/spec/api/system/reset_spec.rb +0 -1
- data/spec/api/system/stats_spec.rb +5 -5
- data/spec/api/user/create_user_spec.rb +14 -6
- data/spec/api/user/delete_user_spec.rb +20 -18
- data/spec/api/user/list_users_spec.rb +5 -6
- data/spec/api/user/update_user_spec.rb +5 -4
- data/spec/apps/rhotestapp/config.ru +16 -1
- data/spec/apps/rhotestapp/controllers/js/js_sample_controller.js +23 -0
- data/spec/apps/rhotestapp/controllers/js/sample2_controller.js +32 -0
- data/spec/apps/rhotestapp/controllers/ruby/application_controller.rb +21 -0
- data/spec/apps/rhotestapp/controllers/ruby/sample_adapter_controller.rb +8 -0
- data/spec/apps/rhotestapp/models/js/js_sample.js +55 -0
- data/spec/apps/rhotestapp/models/js/sample2.js +25 -0
- data/spec/apps/rhotestapp/{sources → models/ruby}/base_adapter.rb +0 -0
- data/spec/apps/rhotestapp/{sources → models/ruby}/fixed_schema_adapter.rb +0 -0
- data/spec/apps/rhotestapp/{sources → models/ruby}/other_adapter.rb +0 -0
- data/spec/apps/rhotestapp/{sources → models/ruby}/sample_adapter.rb +0 -0
- data/spec/apps/rhotestapp/{sources → models/ruby}/simple_adapter.rb +2 -2
- data/spec/apps/rhotestapp/{sources → models/ruby}/sub_adapter.rb +0 -0
- data/spec/apps/rhotestapp/settings/settings.yml +0 -1
- data/spec/bulk_data/bulk_data_spec.rb +20 -5
- data/spec/cli/cli_spec.rb +83 -0
- data/spec/client_spec.rb +20 -17
- data/spec/client_sync_spec.rb +244 -406
- data/spec/controllers/js_base_spec.rb +89 -0
- data/spec/doc/doc_spec.rb +18 -18
- data/spec/document_spec.rb +29 -13
- data/spec/dynamic_adapter_spec.rb +6 -6
- data/spec/generator/generator_spec.rb +7 -4
- data/spec/jobs/bulk_data_job_spec.rb +14 -10
- data/spec/jobs/source_job_spec.rb +8 -8
- data/spec/license_spec.rb +5 -2
- data/spec/models/js_model_spec.rb +39 -0
- data/spec/node_spec.rb +42 -0
- data/spec/perf/store_perf_spec.rb +67 -12
- data/spec/ping/android_spec.rb +1 -1
- data/spec/read_state_spec.rb +1 -1
- data/spec/rhoconnect_spec.rb +1 -1
- data/spec/server/cors_spec.rb +14 -18
- data/spec/server/server_spec.rb +265 -88
- data/spec/server/stats_spec.rb +1 -1
- data/spec/source_adapter_spec.rb +54 -27
- data/spec/source_spec.rb +8 -3
- data/spec/source_sync_spec.rb +538 -468
- data/spec/spec_helper.rb +35 -4
- data/spec/stats/record_spec.rb +10 -10
- data/spec/{model_spec.rb → store_orm_spec.rb} +56 -54
- data/spec/store_spec.rb +159 -179
- data/spec/support/shared_examples.rb +36 -27
- data/spec/sync_states_spec.rb +40 -33
- data/spec/test_methods_spec.rb +18 -14
- data/spec/user_spec.rb +17 -30
- metadata +156 -52
- data/bench/benchapp/application.rb +0 -39
- data/bench/blobapp/application.rb +0 -44
- data/commands/rhoconnect/clean_start.rb +0 -9
- data/commands/rhoconnect/create_user.rb +0 -18
- data/commands/rhoconnect/delete_device.rb +0 -9
- data/commands/rhoconnect/delete_user.rb +0 -8
- data/commands/rhoconnect/reset.rb +0 -16
- data/commands/rhoconnect/reset_refresh.rb +0 -11
- data/generators/templates/application/application.rb +0 -43
- data/lib/rhoconnect/client_sync.rb +0 -434
- data/lib/rhoconnect/dynamic_adapter.rb +0 -91
- data/lib/rhoconnect/middleware/admin_user.rb +0 -23
- data/lib/rhoconnect/middleware/current_request.rb +0 -16
- data/lib/rhoconnect/middleware/login_required.rb +0 -22
- data/lib/rhoconnect/source_adapter.rb +0 -132
- data/lib/rhoconnect/source_sync.rb +0 -464
- data/spec/apps/rhotestapp/application.rb +0 -23
data/spec/server/server_spec.rb
CHANGED
@@ -9,20 +9,13 @@ describe "Server" do
|
|
9
9
|
|
10
10
|
it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
|
11
11
|
before(:each) do
|
12
|
-
require File.join(get_testapp_path,test_app_name)
|
13
|
-
Rhoconnect.bootstrap(get_testapp_path) do |rhoconnect|
|
14
|
-
rhoconnect.vendor_directory = File.join(rhoconnect.base_directory,'..','..','..','vendor')
|
15
|
-
rhoconnect.appserver = nil
|
16
|
-
end
|
17
|
-
Rhoconnect::Server.set :environment, :test
|
18
|
-
Rhoconnect::Server.set :run, false
|
19
12
|
Rhoconnect::Server.set :secret, "secure!"
|
20
|
-
Rhoconnect::Server.use Rack::Static, :urls => ["/data"],
|
13
|
+
Rhoconnect::Server.use Rack::Static, :urls => ["/data"],
|
21
14
|
:root => File.expand_path(File.join(File.dirname(__FILE__),'..','apps','rhotestapp'))
|
22
15
|
end
|
23
16
|
|
24
17
|
def app
|
25
|
-
@app ||=
|
18
|
+
@app ||= Rack::URLMap.new Rhoconnect.url_map
|
26
19
|
end
|
27
20
|
|
28
21
|
it "should show status page" do
|
@@ -31,12 +24,12 @@ describe "Server" do
|
|
31
24
|
end
|
32
25
|
|
33
26
|
it "should login if content-type contains extra parameters" do
|
34
|
-
post "/rc/#{Rhoconnect::API_VERSION}/system/login", {"login" => 'rhoadmin', "password" => ''}.to_json, {'CONTENT_TYPE'=>'application/json; charset=UTF-8'}
|
27
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/login", {"login" => 'rhoadmin', "password" => ''}.to_json, {'CONTENT_TYPE'=>'application/json; charset=UTF-8'}
|
35
28
|
last_response.should be_ok
|
36
29
|
end
|
37
30
|
|
38
31
|
it "should fail to login if wrong content-type" do
|
39
|
-
post "/rc/#{Rhoconnect::API_VERSION}/system/login", {"login" => 'rhoadmin', "password" => ''}.to_json, {'CONTENT_TYPE'=>'application/x-www-form-urlencoded'}
|
32
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/login", {"login" => 'rhoadmin', "password" => ''}.to_json, {'CONTENT_TYPE'=>'application/x-www-form-urlencoded'}
|
40
33
|
last_response.should_not be_ok
|
41
34
|
end
|
42
35
|
|
@@ -44,34 +37,25 @@ describe "Server" do
|
|
44
37
|
post "/rc/#{Rhoconnect::API_VERSION}/system/login", "login" => 'rhoadmin', "password" => ''
|
45
38
|
last_response.should be_ok
|
46
39
|
end
|
47
|
-
|
40
|
+
|
48
41
|
it "should extract api token from the header" do
|
49
42
|
post "/rc/#{Rhoconnect::API_VERSION}/system/login", "login" => 'rhoadmin', "password" => ''
|
50
43
|
last_response.should be_ok
|
51
44
|
api_token = last_response.body
|
52
|
-
|
45
|
+
|
53
46
|
get "/rc/#{Rhoconnect::API_VERSION}/system/license", {}, {Rhoconnect::API_TOKEN_HEADER => api_token}
|
54
47
|
last_response.should be_ok
|
55
48
|
JSON.parse(last_response.body).should == {
|
56
|
-
"available" => 9,
|
57
|
-
"issued" => "Fri Apr 23 17:20:13 -0700 2010",
|
58
|
-
"seats" => 10,
|
49
|
+
"available" => 9,
|
50
|
+
"issued" => "Fri Apr 23 17:20:13 -0700 2010",
|
51
|
+
"seats" => 10,
|
59
52
|
"rhoconnect_version" => "Version 1",
|
60
53
|
"licensee" => "Rhomobile" }
|
61
54
|
end
|
62
|
-
|
63
|
-
it "should register custom_route and process it" do
|
64
|
-
Rhoconnect::Server.api4 :my_custom_route, :get, "/my_custom_route", false, nil do |params,user,server|
|
65
|
-
"Hello World!"
|
66
|
-
end
|
67
|
-
|
68
|
-
get "/my_custom_route", {}
|
69
|
-
last_response.body.should == "Hello World!"
|
70
|
-
end
|
71
55
|
|
72
|
-
it "should respond with
|
73
|
-
get "/app/"
|
74
|
-
last_response.status.should ==
|
56
|
+
it "should respond with 404 if controller name is not specified" do
|
57
|
+
get "/app/#{Rhoconnect::API_VERSION}/"
|
58
|
+
last_response.status.should == 404
|
75
59
|
end
|
76
60
|
|
77
61
|
it "should have default session secret" do
|
@@ -92,7 +76,7 @@ describe "Server" do
|
|
92
76
|
check_hsql_lib!
|
93
77
|
end
|
94
78
|
|
95
|
-
describe "helpers" do
|
79
|
+
describe "helpers" do
|
96
80
|
before(:each) do
|
97
81
|
do_post "/rc/#{Rhoconnect::API_VERSION}/app/login", "login" => @u.login, "password" => 'testpass'
|
98
82
|
end
|
@@ -108,13 +92,13 @@ describe "Server" do
|
|
108
92
|
do_post "/rc/#{Rhoconnect::API_VERSION}/app/login", "login" => @u.login, "password" => 'testpass'
|
109
93
|
last_response.should be_ok
|
110
94
|
end
|
111
|
-
|
95
|
+
|
112
96
|
it "should login user with correct username,password old route and deprecation warning" do
|
113
97
|
do_post "/application/clientlogin", "login" => @u.login, "password" => 'testpass'
|
114
98
|
last_response.should be_ok
|
115
99
|
last_response.headers["Warning"].index('deprecated').should_not == nil
|
116
100
|
end
|
117
|
-
|
101
|
+
|
118
102
|
it "should login user with correct username,password if backend service defined" do
|
119
103
|
stub_request(:post, "http://test.com/rhoconnect/authenticate").to_return(:body => "lucas")
|
120
104
|
Rhoconnect.appserver = 'http://test.com'
|
@@ -152,15 +136,49 @@ describe "Server" do
|
|
152
136
|
@a.users.members.sort.should == ['different','testuser']
|
153
137
|
end
|
154
138
|
|
155
|
-
context "
|
156
|
-
it "should authenticate user with
|
157
|
-
|
158
|
-
|
139
|
+
context "rps authenticate" do
|
140
|
+
it "should authenticate user with rps route" do
|
141
|
+
# RPS login should always come after normal login
|
142
|
+
do_post "/rc/#{Rhoconnect::API_VERSION}/app/login", "login" => @u.login, "password" => 'testpass'
|
143
|
+
authorize 'rpsuser', 'secret'
|
144
|
+
get "/rc/#{Rhoconnect::API_VERSION}/app/rps_login", {}
|
159
145
|
last_response.status.should == 204
|
160
146
|
end
|
161
147
|
end
|
162
148
|
end
|
163
149
|
|
150
|
+
describe "controller custom routes" do
|
151
|
+
before(:each) do
|
152
|
+
do_post "/rc/#{Rhoconnect::API_VERSION}/app/login", "login" => @u.login, "password" => 'testpass'
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should register custom_route in DefaultServer and process it" do
|
156
|
+
Rhoconnect::Server.api4 '', "/my_custom_route", :get do
|
157
|
+
"Hello World!"
|
158
|
+
end
|
159
|
+
|
160
|
+
get "/my_custom_route", {}
|
161
|
+
last_response.body.should == "Hello World!"
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should register custom_route in SimpleAdapter controller and process it" do
|
165
|
+
SimpleAdapterController.get '/my_custom_route', {:client_required => true, :source_required => true} do
|
166
|
+
"Hello World!"
|
167
|
+
end
|
168
|
+
get "/app/#{Rhoconnect::API_VERSION}/SimpleAdapter/my_custom_route", {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
169
|
+
last_response.body.should == "Hello World!"
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should register custom_route in SimpleAdapter controller, require client condition and return error if client is missing" do
|
173
|
+
SimpleAdapterController.get '/my_custom_route_with_client', {:client_required => true, :source_required => true} do
|
174
|
+
"Hello World!"
|
175
|
+
end
|
176
|
+
get "/app/#{Rhoconnect::API_VERSION}/SimpleAdapter/my_custom_route_with_client", {}
|
177
|
+
last_response.body.should == "Unknown client"
|
178
|
+
last_response.status.should == 500
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
164
182
|
describe "client management routes" do
|
165
183
|
before(:each) do
|
166
184
|
do_post "/rc/#{Rhoconnect::API_VERSION}/app/login", "login" => @u.login, "password" => 'testpass'
|
@@ -172,13 +190,13 @@ describe "Server" do
|
|
172
190
|
last_response.content_type.should =~ /application\/json/
|
173
191
|
id = JSON.parse(last_response.body)['client']['client_id']
|
174
192
|
id.length.should == 32
|
175
|
-
JSON.parse(last_response.body).should ==
|
193
|
+
JSON.parse(last_response.body).should ==
|
176
194
|
{"client"=>{"client_id"=>id}}
|
177
195
|
c = Client.load(id,{:source_name => '*'})
|
178
196
|
c.user_id.should == 'testuser'
|
179
197
|
c.device_type.should == 'blackberry'
|
180
198
|
end
|
181
|
-
|
199
|
+
|
182
200
|
it "should respond to clientcreate with old route and deprecation warning" do
|
183
201
|
get "/application/clientcreate?device_type=blackberry"
|
184
202
|
last_response.should be_ok
|
@@ -186,7 +204,7 @@ describe "Server" do
|
|
186
204
|
last_response.content_type.should =~ /application\/json/
|
187
205
|
id = JSON.parse(last_response.body)['client']['client_id']
|
188
206
|
id.length.should == 32
|
189
|
-
JSON.parse(last_response.body).should ==
|
207
|
+
JSON.parse(last_response.body).should ==
|
190
208
|
{"client"=>{"client_id"=>id}}
|
191
209
|
c = Client.load(id,{:source_name => '*'})
|
192
210
|
c.user_id.should == 'testuser'
|
@@ -194,19 +212,19 @@ describe "Server" do
|
|
194
212
|
end
|
195
213
|
|
196
214
|
it "should respond to clientregister" do
|
197
|
-
do_post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/register",
|
215
|
+
do_post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/register",
|
198
216
|
"device_type" => "iPhone", "device_pin" => 'abcd'
|
199
217
|
last_response.should be_ok
|
200
218
|
@c.device_type.should == 'Apple'
|
201
219
|
@c.device_pin.should == 'abcd'
|
202
220
|
@c.id.length.should == 32
|
203
221
|
end
|
204
|
-
|
222
|
+
|
205
223
|
it "should respond to clientregister without clientcreate" do
|
206
|
-
Store.
|
224
|
+
Store.flush_data("client*")
|
207
225
|
client_id = @c.id.clone
|
208
226
|
@c = nil
|
209
|
-
do_post "/rc/#{Rhoconnect::API_VERSION}/clients/#{client_id}/register",
|
227
|
+
do_post "/rc/#{Rhoconnect::API_VERSION}/clients/#{client_id}/register",
|
210
228
|
"device_type" => "iPhone", "device_pin" => 'abcd'
|
211
229
|
last_response.should be_ok
|
212
230
|
@c = Client.load(client_id, {:source_name => '*'})
|
@@ -216,30 +234,30 @@ describe "Server" do
|
|
216
234
|
end
|
217
235
|
|
218
236
|
it "should respond to clientreset" do
|
219
|
-
|
237
|
+
set_doc_state(@c, :cd => @data)
|
220
238
|
do_post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/reset", {}
|
221
|
-
|
239
|
+
verify_doc_result(@c, :cd => {})
|
222
240
|
end
|
223
|
-
|
241
|
+
|
224
242
|
it "should respond to clientreset with old route and deprecation warning" do
|
225
|
-
|
243
|
+
set_doc_state(@c, :cd => @data)
|
226
244
|
get "/application/clientreset", 'client_id' => @c.id
|
227
245
|
last_response.headers["Warning"].index('deprecated').should_not == nil
|
228
|
-
|
246
|
+
verify_doc_result(@c, :cd => {})
|
229
247
|
end
|
230
|
-
|
248
|
+
|
231
249
|
it "should respond to clientreset with individual adapters" do
|
232
250
|
@c.source_name = 'SimpleAdapter'
|
233
|
-
|
251
|
+
set_doc_state(@c, :cd => @data)
|
234
252
|
@c.source_name = 'SampleAdapter'
|
235
|
-
|
253
|
+
set_doc_state(@c, :cd => @data)
|
236
254
|
sources = [{'name' => 'SimpleAdapter'}]
|
237
255
|
do_post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/reset", 'sources' => sources
|
238
256
|
last_response.should be_ok
|
239
257
|
@c.source_name = 'SampleAdapter'
|
240
|
-
|
258
|
+
verify_doc_result(@c, :cd => @data)
|
241
259
|
@c.source_name = 'SimpleAdapter'
|
242
|
-
|
260
|
+
verify_doc_result(@c, :cd => {})
|
243
261
|
end
|
244
262
|
|
245
263
|
it "should switch client user if client user_id doesn't match session user" do
|
@@ -252,7 +270,7 @@ describe "Server" do
|
|
252
270
|
get "/app/#{Rhoconnect::API_VERSION}/#{@s.name}", {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
253
271
|
JSON.parse(last_response.body).last['insert'].should == data
|
254
272
|
end
|
255
|
-
|
273
|
+
|
256
274
|
it "should return error on routes if client doesn't exist" do
|
257
275
|
get "/app/#{Rhoconnect::API_VERSION}/#{@s.name}",{}, {Rhoconnect::CLIENT_ID_HEADER => "BrokenClient"}
|
258
276
|
last_response.body.should == "Unknown client"
|
@@ -281,19 +299,19 @@ describe "Server" do
|
|
281
299
|
last_response.body.should == ''
|
282
300
|
verify_result("test_update_storage" => {'1'=>@product1})
|
283
301
|
end
|
284
|
-
|
302
|
+
|
285
303
|
it "should post records for update using the old route and have the deprecation warning" do
|
286
304
|
params = {'update'=>{'1'=>@product1},:client_id => @c.id,:source_name => @s.name,
|
287
|
-
:version =>
|
305
|
+
:version => Rhoconnect::SYNC_VERSION}
|
288
306
|
do_post "/application", params
|
289
307
|
last_response.should be_ok
|
290
308
|
last_response.body.should == ''
|
291
309
|
last_response.headers["Warning"].index('deprecated').should_not == nil
|
292
310
|
verify_result("test_update_storage" => {'1'=>@product1})
|
293
311
|
end
|
294
|
-
|
312
|
+
|
295
313
|
it "should post records for delete" do
|
296
|
-
|
314
|
+
set_doc_state(@c, :cd => @data)
|
297
315
|
delete "/app/#{Rhoconnect::API_VERSION}/#{@s.name}/1", {}, { Rhoconnect::CLIENT_ID_HEADER => @c.id }
|
298
316
|
last_response.should be_ok
|
299
317
|
last_response.body.should == ''
|
@@ -302,7 +320,7 @@ describe "Server" do
|
|
302
320
|
|
303
321
|
it "should post records for delete using the old route with deprecation warning" do
|
304
322
|
params = {'delete'=>{'1'=>@product1},:client_id => @c.id,:source_name => @s.name,
|
305
|
-
:version =>
|
323
|
+
:version => Rhoconnect::SYNC_VERSION}
|
306
324
|
do_post "/api/application/queue_updates", params
|
307
325
|
last_response.should be_ok
|
308
326
|
last_response.headers["Warning"].index('deprecated').should_not == nil
|
@@ -323,43 +341,74 @@ describe "Server" do
|
|
323
341
|
last_response.body.should == "Unable to authenticate ''"
|
324
342
|
end
|
325
343
|
|
344
|
+
it "should resend page if page exists and no token provided" do
|
345
|
+
expected = {'1'=>@product1}
|
346
|
+
set_test_data('test_db_storage',{'1'=>@product1,'2'=>@product2,'4'=>@product4})
|
347
|
+
params = {'name' => 'iPhone'}
|
348
|
+
get "/app/#{Rhoconnect::API_VERSION}/#{@s.name}", {:query => params}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
349
|
+
last_response.should be_ok
|
350
|
+
last_response.content_type.should =~ /application\/json/
|
351
|
+
token = @c.get_value(:page_token)
|
352
|
+
last_response.headers[Rhoconnect::PAGE_TOKEN_HEADER].should == token
|
353
|
+
last_response.headers[Rhoconnect::PAGE_OBJECT_COUNT_HEADER].should == 1.to_s
|
354
|
+
JSON.parse(last_response.body).should == [{'version'=>Rhoconnect::SYNC_VERSION}, {"token"=>token},
|
355
|
+
{"count"=>1}, {"progress_count"=>0},{"total_count"=>1},{'insert'=>expected}]
|
356
|
+
# this should re-send the page
|
357
|
+
get "/app/#{Rhoconnect::API_VERSION}/#{@s.name}", {:query => params}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
358
|
+
last_response.should be_ok
|
359
|
+
last_response.content_type.should =~ /application\/json/
|
360
|
+
token1 = @c.get_value(:page_token)
|
361
|
+
token1.should == token
|
362
|
+
last_response.headers[Rhoconnect::PAGE_TOKEN_HEADER].should == token1
|
363
|
+
last_response.headers[Rhoconnect::PAGE_OBJECT_COUNT_HEADER].should == 1.to_s
|
364
|
+
JSON.parse(last_response.body).should == [{'version'=>Rhoconnect::SYNC_VERSION}, {"token"=>token1},
|
365
|
+
{"count"=>1}, {"progress_count"=>0},{"total_count"=>1},{'insert'=>expected}]
|
366
|
+
# this should ack_token
|
367
|
+
get "/app/#{Rhoconnect::API_VERSION}/#{@s.name}", {:token => token, :query => params}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
368
|
+
last_response.should be_ok
|
369
|
+
last_response.content_type.should =~ /application\/json/
|
370
|
+
last_response.headers[Rhoconnect::PAGE_TOKEN_HEADER].should == ""
|
371
|
+
last_response.headers[Rhoconnect::PAGE_OBJECT_COUNT_HEADER].should == 0.to_s
|
372
|
+
JSON.parse(last_response.body).should == [{'version'=>Rhoconnect::SYNC_VERSION}, {"token"=>""},
|
373
|
+
{"count"=>0}, {"progress_count"=>0},{"total_count"=>1},{}]
|
374
|
+
@c.get_data(:page).should == {}
|
375
|
+
@c.get_value(:page_token).should be_nil
|
376
|
+
end
|
377
|
+
|
326
378
|
it "should get inserts json" do
|
327
|
-
cs = ClientSync.new(@s,@c,1)
|
328
379
|
data = {'1'=>@product1,'2'=>@product2}
|
329
380
|
set_test_data('test_db_storage',data)
|
330
381
|
get "/app/#{Rhoconnect::API_VERSION}/#{@s.name}", {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
331
382
|
last_response.should be_ok
|
332
383
|
last_response.content_type.should =~ /application\/json/
|
333
384
|
token = @c.get_value(:page_token)
|
334
|
-
JSON.parse(last_response.body).should == [{'version'=>
|
385
|
+
JSON.parse(last_response.body).should == [{'version'=>Rhoconnect::SYNC_VERSION}, {"token"=>token},
|
335
386
|
{"count"=>2}, {"progress_count"=>0},{"total_count"=>2},{'insert'=>data}]
|
336
387
|
end
|
337
|
-
|
388
|
+
|
338
389
|
it "should get inserts json with the old route and show deprecation warning" do
|
339
|
-
cs = ClientSync.new(@s,@c,1)
|
340
390
|
data = {'1'=>@product1,'2'=>@product2}
|
341
391
|
set_test_data('test_db_storage',data)
|
342
|
-
get "/application",:client_id => @c.id,:source_name => @s.name,:version =>
|
392
|
+
get "/application",:client_id => @c.id,:source_name => @s.name,:version => Rhoconnect::SYNC_VERSION
|
343
393
|
last_response.should be_ok
|
344
394
|
last_response.headers["Warning"].index('deprecated').should_not == nil
|
345
395
|
last_response.content_type.should =~ /application\/json/
|
346
396
|
token = @c.get_value(:page_token)
|
347
|
-
JSON.parse(last_response.body).should == [{'version'=>
|
397
|
+
JSON.parse(last_response.body).should == [{'version'=>Rhoconnect::SYNC_VERSION},{"token"=>token},
|
348
398
|
{"count"=>2}, {"progress_count"=>0},{"total_count"=>2},{'insert'=>data}]
|
349
399
|
end
|
350
|
-
|
400
|
+
|
351
401
|
it "should get inserts json and confirm token" do
|
352
|
-
cs = ClientSync.new(@s,@c,1)
|
353
402
|
data = {'1'=>@product1,'2'=>@product2}
|
354
403
|
set_test_data('test_db_storage',data)
|
355
404
|
get "/app/#{Rhoconnect::API_VERSION}/#{@s.name}", {}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
356
405
|
last_response.should be_ok
|
357
406
|
token = @c.get_value(:page_token)
|
358
|
-
JSON.parse(last_response.body).should == [{'version'=>
|
407
|
+
JSON.parse(last_response.body).should == [{'version'=>Rhoconnect::SYNC_VERSION},{"token"=>token},
|
359
408
|
{"count"=>2}, {"progress_count"=>0}, {"total_count"=>2},{'insert'=>data}]
|
360
409
|
get "/app/#{Rhoconnect::API_VERSION}/#{@s.name}", {:token => token}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
361
410
|
last_response.should be_ok
|
362
|
-
JSON.parse(last_response.body).should == [{'version'=>
|
411
|
+
JSON.parse(last_response.body).should == [{'version'=>Rhoconnect::SYNC_VERSION},{"token"=>''},
|
363
412
|
{"count"=>0}, {"progress_count"=>0}, {"total_count"=>2},{}]
|
364
413
|
end
|
365
414
|
|
@@ -375,7 +424,6 @@ describe "Server" do
|
|
375
424
|
|
376
425
|
it "should get deletes json" do
|
377
426
|
@s = Source.load(@s_fields[:name],@s_params)
|
378
|
-
cs = ClientSync.new(@s,@c,1)
|
379
427
|
data = {'1'=>@product1,'2'=>@product2}
|
380
428
|
set_test_data('test_db_storage',data)
|
381
429
|
|
@@ -384,46 +432,44 @@ describe "Server" do
|
|
384
432
|
token = @c.get_value(:page_token)
|
385
433
|
last_response.headers[Rhoconnect::PAGE_TOKEN_HEADER].should == token
|
386
434
|
last_response.headers[Rhoconnect::PAGE_OBJECT_COUNT_HEADER].should == 2.to_s
|
387
|
-
JSON.parse(last_response.body).should == [{'version'=>
|
435
|
+
JSON.parse(last_response.body).should == [{'version'=>Rhoconnect::SYNC_VERSION},{"token"=>token},
|
388
436
|
{"count"=>2}, {"progress_count"=>0}, {"total_count"=>2},{'insert'=>data}]
|
389
437
|
|
390
|
-
Store.
|
391
|
-
@s.read_state.refresh_time = Time.now.to_i
|
438
|
+
Store.flush_data('test_db_storage')
|
439
|
+
@s.read_state.refresh_time = Time.now.to_i
|
392
440
|
|
393
441
|
get "/app/#{Rhoconnect::API_VERSION}/#{@s.name}",{:token => token}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
394
442
|
last_response.should be_ok
|
395
443
|
token = @c.get_value(:page_token)
|
396
444
|
last_response.headers[Rhoconnect::PAGE_TOKEN_HEADER].should == token
|
397
445
|
last_response.headers[Rhoconnect::PAGE_OBJECT_COUNT_HEADER].should == 2.to_s
|
398
|
-
JSON.parse(last_response.body).should == [{'version'=>
|
446
|
+
JSON.parse(last_response.body).should == [{'version'=>Rhoconnect::SYNC_VERSION},{"token"=>token},
|
399
447
|
{"count"=>2}, {"progress_count"=>0}, {"total_count"=>0},{'delete'=>data}]
|
400
448
|
end
|
401
449
|
|
402
450
|
it "should get search results using the old route with deprecation warning" do
|
403
451
|
sources = [{:name=>'SampleAdapter'}]
|
404
|
-
cs = ClientSync.new(@s,@c,1)
|
405
452
|
Store.put_data('test_db_storage',@data)
|
406
453
|
params = {:client_id => @c.id,:sources => sources,:search => {'name' => 'iPhone'},
|
407
|
-
:version =>
|
454
|
+
:version => Rhoconnect::SYNC_VERSION}
|
408
455
|
get "/api/application/search",params
|
409
456
|
last_response.headers['Warning'].index('deprecated').should_not == nil
|
410
457
|
last_response.content_type.should =~ /application\/json/
|
411
458
|
token = @c.get_value(:search_token)
|
412
459
|
last_response.headers[Rhoconnect::PAGE_TOKEN_HEADER].should == token
|
413
460
|
last_response.headers[Rhoconnect::PAGE_OBJECT_COUNT_HEADER].should == 1.to_s
|
414
|
-
JSON.parse(last_response.body).should == [[{'version'=>
|
461
|
+
JSON.parse(last_response.body).should == [[{'version'=>Rhoconnect::SYNC_VERSION},{'token'=>token},
|
415
462
|
{'source'=>sources[0][:name]},{'count'=>1},{'insert'=>{'1'=>@product1}}]]
|
416
463
|
end
|
417
|
-
|
464
|
+
|
418
465
|
it "should get search results" do
|
419
466
|
sources = [{:name=>'SampleAdapter'}]
|
420
|
-
cs = ClientSync.new(@s,@c,1)
|
421
467
|
Store.put_data('test_db_storage',@data)
|
422
468
|
params = {:sources => sources,:search => {'name' => 'iPhone'}}
|
423
469
|
do_post "/rc/#{Rhoconnect::API_VERSION}/app/search",params, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
424
470
|
last_response.content_type.should =~ /application\/json/
|
425
471
|
token = @c.get_value(:search_token)
|
426
|
-
JSON.parse(last_response.body).should == [[{'version'=>
|
472
|
+
JSON.parse(last_response.body).should == [[{'version'=>Rhoconnect::SYNC_VERSION},{'token'=>token},
|
427
473
|
{'source'=>sources[0][:name]},{'count'=>1},{'insert'=>{'1'=>@product1}}]]
|
428
474
|
end
|
429
475
|
|
@@ -433,8 +479,9 @@ describe "Server" do
|
|
433
479
|
error = set_test_data('test_db_storage',@data,msg,'search error')
|
434
480
|
params = {:sources => sources,:search => {'name' => 'iPhone'}}
|
435
481
|
do_post "/rc/#{Rhoconnect::API_VERSION}/app/search", params, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
436
|
-
JSON.parse(last_response.body).should == [[{'version'=>
|
482
|
+
JSON.parse(last_response.body).should == [[{'version'=>Rhoconnect::SYNC_VERSION},{'source'=>sources[0][:name]},
|
437
483
|
{'search-error'=>{'search-error'=>{'message'=>msg}}}]]
|
484
|
+
verify_doc_result(@c, :search => {})
|
438
485
|
end
|
439
486
|
|
440
487
|
it "should get multiple source search results" do
|
@@ -447,10 +494,66 @@ describe "Server" do
|
|
447
494
|
@c.source_name = 'SampleAdapter'
|
448
495
|
token = @c.get_value(:search_token)
|
449
496
|
JSON.parse(last_response.body).should == [
|
450
|
-
[{'version'=>
|
497
|
+
[{'version'=>Rhoconnect::SYNC_VERSION},{'token'=>token1},{"source"=>"SimpleAdapter"},
|
451
498
|
{"count"=>1}, {"insert"=>{'obj'=>{'foo'=>'bar'}}}],
|
452
|
-
[{'version'=>
|
499
|
+
[{'version'=>Rhoconnect::SYNC_VERSION},{'token'=>token},{"source"=>"SampleAdapter"},
|
453
500
|
{"count"=>1}, {"insert"=>{'1'=>@product1}}]]
|
501
|
+
verify_doc_result(@c, {:search => {'1'=>@product1},
|
502
|
+
:search_errors => {}})
|
503
|
+
end
|
504
|
+
|
505
|
+
it "should handle search for pass through" do
|
506
|
+
sources = [{'name'=>'SampleAdapter'}]
|
507
|
+
set_state('test_db_storage' => @data)
|
508
|
+
@s.pass_through = 'true'
|
509
|
+
params = {:sources => sources, :search => {'name' => 'iPhone'}}
|
510
|
+
do_post "/rc/#{Rhoconnect::API_VERSION}/app/search", params, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
511
|
+
token = @c.get_value(:search_token)
|
512
|
+
JSON.parse(last_response.body).should == [[{'version'=>Rhoconnect::SYNC_VERSION},{'token'=>token},
|
513
|
+
{'source'=>sources[0]['name']},{'count'=>1},{'insert'=>{'1'=>@product1}}]]
|
514
|
+
verify_doc_result(@c, {:search => {},
|
515
|
+
:search_errors => {}})
|
516
|
+
end
|
517
|
+
|
518
|
+
it "should handle multiple source search with one source returning nothing" do
|
519
|
+
set_test_data('test_db_storage',@data)
|
520
|
+
sources = [{'name'=>'SimpleAdapter'},{'name'=>'SampleAdapter'}]
|
521
|
+
params = {:sources => sources,:search => {'name' => 'iPhone'}}
|
522
|
+
do_post "/rc/#{Rhoconnect::API_VERSION}/app/search", params, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
523
|
+
@c.source_name = 'SimpleAdapter'
|
524
|
+
token1 = @c.get_value(:search_token)
|
525
|
+
token1.should be_nil
|
526
|
+
@c.source_name = 'SampleAdapter'
|
527
|
+
token = @c.get_value(:search_token)
|
528
|
+
JSON.parse(last_response.body).should == [[],[{'version'=>Rhoconnect::SYNC_VERSION},{'token'=>token},
|
529
|
+
{"source"=>"SampleAdapter"},{"count"=>1},{"insert"=>{'1'=>@product1}}]]
|
530
|
+
end
|
531
|
+
|
532
|
+
it "should handle search and ack of search results" do
|
533
|
+
set_test_data('test_db_storage',@data)
|
534
|
+
sources = [{'name'=>'SimpleAdapter'},{'name'=>'SampleAdapter'}]
|
535
|
+
params = {:sources => sources,:search => {'search'=>'bar'}}
|
536
|
+
do_post "/rc/#{Rhoconnect::API_VERSION}/app/search", params, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
537
|
+
@c.source_name = 'SimpleAdapter'
|
538
|
+
token = @c.get_value(:search_token)
|
539
|
+
token.should_not be_nil
|
540
|
+
sources[0]['token'] = token
|
541
|
+
@c.get_data(:search).should == {'obj'=>{'foo'=>'bar'}}
|
542
|
+
@c.source_name = 'SampleAdapter'
|
543
|
+
token1 = @c.get_value(:search_token)
|
544
|
+
token1.should_not be_nil
|
545
|
+
sources[1]['token'] = token1
|
546
|
+
@c.get_data(:search).should == {'1'=>@product1}
|
547
|
+
# do ack on multiple sources
|
548
|
+
do_post "/rc/#{Rhoconnect::API_VERSION}/app/search", params, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
549
|
+
@c.source_name = 'SimpleAdapter'
|
550
|
+
token = @c.get_value(:search_token)
|
551
|
+
token.should be_nil
|
552
|
+
@c.get_data(:search).should == {}
|
553
|
+
@c.source_name = 'SampleAdapter'
|
554
|
+
token1 = @c.get_value(:search_token)
|
555
|
+
token1.should be_nil
|
556
|
+
@c.get_data(:search).should == {}
|
454
557
|
end
|
455
558
|
end
|
456
559
|
|
@@ -463,15 +566,18 @@ describe "Server" do
|
|
463
566
|
delete_data_directory
|
464
567
|
end
|
465
568
|
|
466
|
-
it "should make initial bulk data request and receive wait (and no deprecation warning)" do
|
569
|
+
it "should make initial bulk data request (which creates Resque job) and receive wait (and no deprecation warning)" do
|
467
570
|
set_state('test_db_storage' => @data)
|
468
571
|
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :user}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
469
572
|
last_response.should be_ok
|
470
573
|
last_response.body.should == {:result => :wait}.to_json
|
471
574
|
warning_header = last_response.headers['Warning']
|
472
575
|
warning_header.should == nil or warning_header.index('deprecated').should == nil
|
576
|
+
Resque.peek(:bulk_data).should == {"args"=>
|
577
|
+
[{"data_name"=>File.join(@a_fields[:name],@u_fields[:login],@u_fields[:login])}],
|
578
|
+
"class"=>"Rhoconnect::BulkDataJob"}
|
473
579
|
end
|
474
|
-
|
580
|
+
|
475
581
|
it "should make old-way initial bulk data request and receive wait along with deprecation warning" do
|
476
582
|
set_state('test_db_storage' => @data)
|
477
583
|
get "/application/bulk_data", :partition => :user, :client_id => @c.id
|
@@ -479,7 +585,7 @@ describe "Server" do
|
|
479
585
|
last_response.body.should == {:result => :wait}.to_json
|
480
586
|
last_response.headers['Warning'].index('deprecated').should_not == nil
|
481
587
|
end
|
482
|
-
|
588
|
+
|
483
589
|
it "should make old-way initial bulk data request and receive wait along with deprecation warning (Sources sent as String)" do
|
484
590
|
set_state('test_db_storage' => @data)
|
485
591
|
get "/application/bulk_data?sources=FixedSchemaAdapter,SampleAdapter", :partition => :user, :client_id => @c.id
|
@@ -495,7 +601,7 @@ describe "Server" do
|
|
495
601
|
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :user}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
496
602
|
last_response.should be_ok
|
497
603
|
data = BulkData.load(bulk_data_docname(@a.id,@u.id))
|
498
|
-
last_response.body.should == {:result => :url,
|
604
|
+
last_response.body.should == {:result => :url,
|
499
605
|
:url => data.url}.to_json
|
500
606
|
validate_db(data,{@s.name => @data, 'FixedSchemaAdapter' => @data})
|
501
607
|
end
|
@@ -505,11 +611,16 @@ describe "Server" do
|
|
505
611
|
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :user}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
506
612
|
do_bulk_data_job("data_name" => bulk_data_docname(@a.id,@u.id))
|
507
613
|
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :user}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
614
|
+
JSON.parse(last_response.body).should == {'result' => 'url',
|
615
|
+
'url' => BulkData.load(bulk_data_docname(@a.id,@u.id)).url}
|
508
616
|
get JSON.parse(last_response.body)["url"]
|
509
617
|
last_response.should be_ok
|
510
618
|
File.open('test.data','wb') {|f| f.puts last_response.body}
|
511
619
|
validate_db_file('test.data',[@s.name,'FixedSchemaAdapter'],{@s.name => @data, 'FixedSchemaAdapter' => @data})
|
512
620
|
File.delete('test.data')
|
621
|
+
verify_doc_result(@c, :cd => @data)
|
622
|
+
verify_doc_result(@s, {:md => @data,
|
623
|
+
:md_copy => @data})
|
513
624
|
end
|
514
625
|
|
515
626
|
it "should receive nop when no sources are available for partition" do
|
@@ -520,6 +631,72 @@ describe "Server" do
|
|
520
631
|
last_response.should be_ok
|
521
632
|
last_response.body.should == {:result => :nop}.to_json
|
522
633
|
end
|
634
|
+
|
635
|
+
it "should create bulk data job app partition with partition sources" do
|
636
|
+
@s.partition = :app
|
637
|
+
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :app}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
638
|
+
last_response.should be_ok
|
639
|
+
last_response.body.should == {:result => :wait}.to_json
|
640
|
+
warning_header = last_response.headers['Warning']
|
641
|
+
warning_header.should == nil or warning_header.index('deprecated').should == nil
|
642
|
+
Resque.peek(:bulk_data).should == {"args"=>
|
643
|
+
[{"data_name"=>File.join(@a_fields[:name],@a_fields[:name])}],
|
644
|
+
"class"=>"Rhoconnect::BulkDataJob"}
|
645
|
+
end
|
646
|
+
|
647
|
+
it "should return empty bulk data url if there are errors in query" do
|
648
|
+
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :user}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
649
|
+
do_bulk_data_job("data_name" => bulk_data_docname(@a.id,@u.id))
|
650
|
+
operation = 'query'
|
651
|
+
@s.lock(:errors) do
|
652
|
+
@s.put_data(:errors,{"#{operation}-error"=>{'message'=>"Some exception message"}}, true)
|
653
|
+
end
|
654
|
+
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :user}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
655
|
+
JSON.parse(last_response.body).should == {'result' => 'url', 'url' => ''}
|
656
|
+
end
|
657
|
+
|
658
|
+
it "should return bulk data url for completed bulk data app partition" do
|
659
|
+
set_state('test_db_storage' => @data)
|
660
|
+
@s.partition = :app
|
661
|
+
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :app}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
662
|
+
do_bulk_data_job("data_name" => bulk_data_docname(@a.id,"*"))
|
663
|
+
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :app}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
664
|
+
JSON.parse(last_response.body).should == {'result' => 'url',
|
665
|
+
'url' => BulkData.load(bulk_data_docname(@a.id,"*")).url}
|
666
|
+
@c.source_name = @s.name
|
667
|
+
verify_doc_result(@c, :cd => @data)
|
668
|
+
verify_doc_result(@s, {:md => @data,
|
669
|
+
:md_copy => @data})
|
670
|
+
end
|
671
|
+
|
672
|
+
it "should return bulk data url for completed bulk data with bulk_sync_only source" do
|
673
|
+
set_state('test_db_storage' => @data)
|
674
|
+
@s.sync_type = :bulk_sync_only
|
675
|
+
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :user}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
676
|
+
do_bulk_data_job("data_name" => bulk_data_docname(@a.id,@u.id))
|
677
|
+
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :user}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
678
|
+
JSON.parse(last_response.body).should == {'result' => 'url',
|
679
|
+
'url' => BulkData.load(bulk_data_docname(@a.id,@u.id)).url}
|
680
|
+
@c.source_name = @s.name
|
681
|
+
verify_doc_result(@c, :cd => {})
|
682
|
+
verify_doc_result(@s, {:md => @data,
|
683
|
+
:md_copy => {}})
|
684
|
+
end
|
685
|
+
|
686
|
+
it "should create bulk data job if no file exists" do
|
687
|
+
set_state('test_db_storage' => @data)
|
688
|
+
Rhoconnect.blackberry_bulk_sync = true
|
689
|
+
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :user}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
690
|
+
do_bulk_data_job("data_name" => bulk_data_docname(@a.id,@u.id))
|
691
|
+
data = BulkData.load(bulk_data_docname(@a.id,@u.id))
|
692
|
+
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :user}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
693
|
+
JSON.parse(last_response.body).should == {'result' => 'url', 'url' => data.url}
|
694
|
+
File.delete(data.dbfile)
|
695
|
+
post "/rc/#{Rhoconnect::API_VERSION}/app/bulk_data", {:partition => :user}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
696
|
+
JSON.parse(last_response.body).should == {'result' => 'wait'}
|
697
|
+
Resque.peek(:bulk_data).should == {"args"=>
|
698
|
+
[{"data_name"=>bulk_data_docname(@a.id,@u.id)}], "class"=>"Rhoconnect::BulkDataJob"}
|
699
|
+
end
|
523
700
|
end
|
524
701
|
|
525
702
|
describe "blob sync" do
|
@@ -535,9 +712,9 @@ describe "Server" do
|
|
535
712
|
cud = {'create'=>{'1'=>@product1,'2'=>@product2},
|
536
713
|
:blob_fields => ['txtfile-rhoblob']}.to_json
|
537
714
|
post "/app/#{Rhoconnect::API_VERSION}/#{@s.name}",
|
538
|
-
{:cud => cud,'txtfile-rhoblob-1' =>
|
715
|
+
{:cud => cud,'txtfile-rhoblob-1' =>
|
539
716
|
Rack::Test::UploadedFile.new(File.join(File.dirname(__FILE__),'..','testdata',file1), "application/octet-stream"),
|
540
|
-
'txtfile-rhoblob-2' =>
|
717
|
+
'txtfile-rhoblob-2' =>
|
541
718
|
Rack::Test::UploadedFile.new(File.join(File.dirname(__FILE__),'..','testdata',file2), "application/octet-stream")}, {Rhoconnect::CLIENT_ID_HEADER => @c.id}
|
542
719
|
last_response.should be_ok
|
543
720
|
data = Store.get_data('test_create_storage')
|