rhoconnect 3.2.1 → 3.3.1.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +24 -5
- data/Gemfile +2 -2
- data/Gemfile.lock +20 -20
- data/bench/benchapp/Gemfile +17 -20
- data/bench/benchapp/config.ru +2 -2
- data/bench/benchapp/settings/settings.yml +3 -3
- data/bench/blobapp/Gemfile +16 -13
- data/bench/blobapp/config.ru +2 -2
- data/bench/blobapp/settings/settings.yml +5 -3
- data/bench/lib/bench.rb +35 -32
- data/bench/lib/bench/session.rb +9 -1
- data/bench/scripts/blob_cud_script.rb +13 -17
- data/bench/scripts/cud_script.rb +11 -12
- data/bench/scripts/helpers.rb +5 -7
- data/bench/scripts/query_md_script.rb +18 -12
- data/bench/scripts/query_only_script.rb +19 -11
- data/bench/scripts/query_script.rb +17 -13
- data/bench/scripts/test_query_script.rb +46 -17
- data/bench/scripts/test_source_script.rb +7 -7
- data/commands/commands/dtach_commands/dtach_install.rb +44 -16
- data/commands/commands/rhoconnect/spec.rb +13 -9
- data/commands/commands/rhoconnect/version.rb +6 -0
- data/commands/execute.rb +10 -6
- data/doc/deploying.txt +75 -13
- data/doc/install.txt +3 -3
- data/doc/push-client-setup.txt +1 -1
- data/doc/rest-api.txt +4 -23
- data/doc/rhoconnect-redis-stack.txt +26 -7
- data/doc/settings.txt +9 -3
- data/examples/simple/Gemfile +3 -1
- data/examples/simple/application.rb +5 -0
- data/examples/simple/config.ru +3 -2
- data/examples/simple/my_server.rb +14 -0
- data/examples/simple/settings/settings.yml +1 -0
- data/generators/templates/application/Gemfile +4 -4
- data/generators/templates/application/application.rb +4 -0
- data/generators/templates/application/settings/settings.yml +4 -1
- data/installer/unix-like/create_texts.rb +39 -1
- data/installer/unix-like/rho_connect_install_constants.rb +1 -1
- data/installer/utils/package_upload/repos.rake +7 -5
- data/lib/rhoconnect.rb +3 -2
- data/lib/rhoconnect/api/app/ans_login.rb +3 -0
- data/lib/rhoconnect/api/app/bulk_data.rb +6 -0
- data/lib/rhoconnect/api/{source → app}/fast_delete.rb +1 -1
- data/lib/rhoconnect/api/{source → app}/fast_insert.rb +2 -2
- data/lib/rhoconnect/api/{source → app}/fast_update.rb +2 -2
- data/lib/rhoconnect/api/app/login.rb +5 -0
- data/lib/rhoconnect/api/{source → app}/push_deletes.rb +1 -1
- data/lib/rhoconnect/api/{source → app}/push_objects.rb +1 -1
- data/lib/rhoconnect/api/app/query.rb +4 -0
- data/lib/rhoconnect/api/app/queue_updates.rb +94 -0
- data/lib/rhoconnect/api/app/search.rb +4 -0
- data/lib/rhoconnect/api/client/client_get_db_doc.rb +5 -0
- data/lib/rhoconnect/api/client/client_set_db_doc.rb +8 -0
- data/lib/rhoconnect/api/client/create.rb +7 -0
- data/lib/rhoconnect/api/client/get_client_params.rb +2 -1
- data/lib/rhoconnect/api/client/list_client_docs.rb +2 -1
- data/lib/rhoconnect/api/client/register.rb +12 -0
- data/lib/rhoconnect/api/client/reset.rb +5 -0
- data/lib/rhoconnect/api/{source → readstate}/set_refresh_time.rb +2 -1
- data/lib/rhoconnect/api/source/get_source_params.rb +3 -2
- data/lib/rhoconnect/api/source/list_sources.rb +2 -1
- data/lib/rhoconnect/api/source/update_source_params.rb +3 -3
- data/lib/rhoconnect/api/store/get_db_doc.rb +4 -0
- data/lib/rhoconnect/api/store/set_db_doc.rb +7 -0
- data/lib/rhoconnect/api/system/get_adapter.rb +4 -0
- data/lib/rhoconnect/api/{admin → system}/get_license_info.rb +2 -1
- data/lib/rhoconnect/api/system/login.rb +15 -0
- data/lib/rhoconnect/api/{admin → system}/reset.rb +3 -2
- data/lib/rhoconnect/api/system/save_adapter.rb +4 -0
- data/lib/rhoconnect/api/{admin → system}/stats.rb +2 -1
- data/lib/rhoconnect/api/user/create_user.rb +2 -2
- data/lib/rhoconnect/api/user/delete_client.rb +6 -0
- data/lib/rhoconnect/api/user/delete_user.rb +2 -1
- data/lib/rhoconnect/api/user/list_clients.rb +4 -0
- data/lib/rhoconnect/api/user/list_source_docs.rb +11 -0
- data/lib/rhoconnect/api/user/list_users.rb +1 -1
- data/lib/rhoconnect/api/user/ping.rb +7 -0
- data/lib/rhoconnect/api/user/show_user.rb +3 -0
- data/lib/rhoconnect/api/user/update_user.rb +3 -2
- data/lib/rhoconnect/api/user/user_get_db_doc.rb +5 -0
- data/lib/rhoconnect/api/user/user_set_db_doc.rb +10 -0
- data/lib/rhoconnect/app.rb +12 -2
- data/lib/rhoconnect/async.rb +6 -10
- data/lib/rhoconnect/bulk_data/bulk_data.rb +4 -4
- data/lib/rhoconnect/client.rb +10 -9
- data/lib/rhoconnect/client_sync.rb +24 -19
- data/lib/rhoconnect/document.rb +18 -4
- data/lib/rhoconnect/graph_helper.rb +4 -2
- data/lib/rhoconnect/jobs/bulk_data_job.rb +1 -1
- data/lib/rhoconnect/jobs/ping_job.rb +39 -29
- data/lib/rhoconnect/middleware/admin_user.rb +23 -0
- data/lib/rhoconnect/middleware/body_content_type_parser.rb +35 -0
- data/lib/rhoconnect/{cors.rb → middleware/cors.rb} +1 -0
- data/lib/rhoconnect/middleware/current_app.rb +16 -0
- data/lib/rhoconnect/middleware/current_request.rb +16 -0
- data/lib/rhoconnect/middleware/current_user.rb +17 -0
- data/lib/rhoconnect/middleware/helpers.rb +105 -0
- data/lib/rhoconnect/middleware/login_required.rb +22 -0
- data/lib/rhoconnect/{stats/middleware.rb → middleware/stats.rb} +5 -3
- data/lib/rhoconnect/middleware/x_domain_session_wrapper.rb +58 -0
- data/lib/rhoconnect/ping.rb +1 -0
- data/lib/rhoconnect/ping/apple.rb +18 -16
- data/lib/rhoconnect/ping/blackberry.rb +9 -9
- data/lib/rhoconnect/ping/rhoconnect_push.rb +45 -0
- data/lib/rhoconnect/server.rb +98 -91
- data/lib/rhoconnect/source.rb +5 -1
- data/lib/rhoconnect/source_sync.rb +4 -3
- data/lib/rhoconnect/stats/record.rb +15 -15
- data/lib/rhoconnect/store.rb +253 -75
- data/lib/rhoconnect/tasks.rb +3 -3
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect/web-console/controllers/admins.js +1 -14
- data/lib/rhoconnect/web-console/models/adapter.js +18 -8
- data/lib/rhoconnect/web-console/models/client.js +15 -9
- data/lib/rhoconnect/web-console/models/doc.js +7 -11
- data/lib/rhoconnect/web-console/models/session.js +5 -2
- data/lib/rhoconnect/web-console/models/source.js +55 -36
- data/lib/rhoconnect/web-console/models/user.js +20 -11
- data/lib/rhoconnect/web-console/public/backbone.js +8 -2
- data/lib/rhoconnect/web-console/templates/index.erb +11 -5
- data/lib/rhoconnect/web-console/views/doc.js +6 -8
- data/lib/rhoconnect/web-console/views/edit_user.js +6 -3
- data/lib/rhoconnect/web-console/views/home.js +98 -25
- data/lib/rhoconnect/web-console/views/index.js +1 -1
- data/lib/rhoconnect/web-console/views/new_ping.js +6 -3
- data/lib/rhoconnect/web-console/views/server_doc.js +12 -4
- data/lib/rhoconnect/web-console/views/show_device.js +6 -3
- data/rhoconnect.gemspec +1 -2
- data/spec/api/{source → app}/fast_delete_spec.rb +4 -4
- data/spec/api/{source → app}/fast_insert_spec.rb +4 -4
- data/spec/api/{source → app}/fast_update_spec.rb +22 -6
- data/spec/api/{source → app}/push_deletes_spec.rb +2 -2
- data/spec/api/app/push_objects_spec.rb +45 -0
- data/spec/api/client/client_get_db_doc_spec.rb +31 -0
- data/spec/api/client/client_set_db_doc_spec.rb +14 -0
- data/spec/api/client/get_client_params_spec.rb +3 -2
- data/spec/api/client/list_client_docs_spec.rb +2 -2
- data/spec/api/{source → readstate}/set_refresh_time_spec.rb +15 -9
- data/spec/api/source/get_source_params_spec.rb +3 -2
- data/spec/api/source/list_sources_spec.rb +3 -9
- data/spec/api/source/update_source_params_spec.rb +4 -4
- data/spec/api/store/get_db_doc_spec.rb +32 -0
- data/spec/api/store/set_db_doc_spec.rb +43 -0
- data/spec/api/system/adapter_spec.rb +33 -0
- data/spec/api/{admin → system}/get_license_info_spec.rb +2 -5
- data/spec/api/{admin/get_api_token_spec.rb → system/login_spec.rb} +4 -11
- data/spec/api/{admin → system}/reset_spec.rb +2 -2
- data/spec/api/{admin → system}/stats_spec.rb +19 -13
- data/spec/api/user/create_user_spec.rb +15 -8
- data/spec/api/{client → user}/delete_client_spec.rb +3 -4
- data/spec/api/user/delete_user_spec.rb +33 -4
- data/spec/api/user/list_clients_spec.rb +30 -0
- data/spec/api/user/list_source_docs_spec.rb +35 -0
- data/spec/api/user/list_users_spec.rb +5 -6
- data/spec/api/{client → user}/ping_spec.rb +4 -6
- data/spec/api/user/show_user_spec.rb +14 -0
- data/spec/api/user/update_user_spec.rb +28 -10
- data/spec/api/user/user_get_db_doc_spec.rb +16 -0
- data/spec/api/user/user_set_db_doc_spec.rb +41 -0
- data/spec/apps/rhotestapp/application.rb +4 -0
- data/spec/apps/rhotestapp/settings/settings.yml +3 -1
- data/spec/bulk_data/bulk_data_spec.rb +13 -0
- data/spec/client_sync_spec.rb +41 -59
- data/spec/document_spec.rb +23 -0
- data/spec/javascripts/doc_view_spec.js +1 -1
- data/spec/javascripts/home_view_spec.js +10 -5
- data/spec/javascripts/index_view_spec.js +1 -1
- data/spec/jobs/ping_job_spec.rb +26 -0
- data/spec/perf/store_perf_spec.rb +1 -1
- data/spec/ping/android_spec.rb +0 -7
- data/spec/ping/apple_spec.rb +7 -0
- data/spec/ping/blackberry_spec.rb +10 -0
- data/spec/ping/rhoconnect_push_spec.rb +58 -0
- data/spec/server/cors_spec.rb +1 -1
- data/spec/server/server_spec.rb +152 -104
- data/spec/{stats/middleware_spec.rb → server/stats_spec.rb} +4 -5
- data/spec/server/x_domain_session_wrapper_spec.rb +3 -3
- data/spec/source_spec.rb +2 -2
- data/spec/source_sync_spec.rb +2 -0
- data/spec/spec_helper.rb +17 -3
- data/spec/stats/record_spec.rb +18 -19
- data/spec/store_spec.rb +51 -26
- data/spec/support/shared_examples.rb +4 -0
- data/spec/sync_states_spec.rb +2 -2
- metadata +104 -88
- data/bench/benchapp/Gemfile.lock +0 -87
- data/bench/blobapp/Gemfile.lock +0 -107
- data/bench/lib/testdata/5-data.txt +0 -8
- data/doc/release.txt +0 -41
- data/lib/rhoconnect/api/admin/get_api_token.rb +0 -14
- data/lib/rhoconnect/api/admin/login.rb +0 -6
- data/lib/rhoconnect/api/application/bulk_data.rb +0 -7
- data/lib/rhoconnect/api/application/clientcreate.rb +0 -8
- data/lib/rhoconnect/api/application/clientlogin.rb +0 -6
- data/lib/rhoconnect/api/application/clientregister.rb +0 -13
- data/lib/rhoconnect/api/application/clientreset.rb +0 -6
- data/lib/rhoconnect/api/application/query.rb +0 -7
- data/lib/rhoconnect/api/application/queue_updates.rb +0 -20
- data/lib/rhoconnect/api/application/search.rb +0 -6
- data/lib/rhoconnect/api/client/create_client.rb +0 -3
- data/lib/rhoconnect/api/client/delete_client.rb +0 -5
- data/lib/rhoconnect/api/client/list_clients.rb +0 -3
- data/lib/rhoconnect/api/client/ping.rb +0 -7
- data/lib/rhoconnect/api/source/get_adapter.rb +0 -3
- data/lib/rhoconnect/api/source/get_db_doc.rb +0 -7
- data/lib/rhoconnect/api/source/list_source_docs.rb +0 -10
- data/lib/rhoconnect/api/source/save_adapter.rb +0 -3
- data/lib/rhoconnect/api/source/set_db_doc.rb +0 -10
- data/lib/rhoconnect/api/source/upload_file.rb +0 -4
- data/lib/rhoconnect/body_content_type_parser.rb +0 -32
- data/lib/rhoconnect/x_domain_session_wrapper.rb +0 -53
- data/spec/api/admin/api_token_spec.rb +0 -13
- data/spec/api/client/create_client_spec.rb +0 -13
- data/spec/api/client/list_clients_spec.rb +0 -22
- data/spec/api/source/adapter_spec.rb +0 -29
- data/spec/api/source/get_db_doc_spec.rb +0 -21
- data/spec/api/source/list_source_docs_spec.rb +0 -25
- data/spec/api/source/push_objects_spec.rb +0 -27
- data/spec/api/source/set_db_doc_spec.rb +0 -32
- data/spec/api/source/upload_file_spec.rb +0 -26
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'..','api_helper')
|
2
|
+
|
3
|
+
describe "RhoconnectApiClientSetDbDoc" do
|
4
|
+
it_should_behave_like "ApiHelper" do
|
5
|
+
it "should set client's db document by doc key and data" do
|
6
|
+
data = {'1' => {'foo' => 'bar'}}
|
7
|
+
dockey = 'myclientdoc'
|
8
|
+
cdocname = @c.docname(dockey)
|
9
|
+
post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
10
|
+
last_response.should be_ok
|
11
|
+
verify_result(cdocname => data)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -3,13 +3,14 @@ require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
3
3
|
describe "RhoconnectApiGetClientParams" do
|
4
4
|
it_should_behave_like "ApiHelper" do
|
5
5
|
it "should list client attributes" do
|
6
|
-
|
6
|
+
get "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
7
7
|
res = JSON.parse(last_response.body)
|
8
8
|
res.delete_if { |attrib| attrib['name'] == 'rho__id' || attrib['name'] == 'last_sync'}
|
9
9
|
res.sort{|x,y| x['name']<=>y['name']}.should == [
|
10
10
|
{"name"=>"device_type", "value"=>"Apple", "type"=>"string"},
|
11
11
|
{"name"=>"device_pin", "value"=>"abcd", "type"=>"string"},
|
12
|
-
{"name"=>"device_port", "value"=>"3333", "type"=>"string"},
|
12
|
+
{"name"=>"device_port", "value"=>"3333", "type"=>"string"},
|
13
|
+
{"name"=>"device_push_type", "type"=>"string", "value"=>nil},
|
13
14
|
{"name"=>"user_id", "value"=>"testuser", "type"=>"string"},
|
14
15
|
{"name"=>"phone_id", "value"=>nil, "type"=>"string"},
|
15
16
|
{"name"=>"app_id", "value"=>"application", "type"=>"string"}].sort{|x,y| x['name']<=>y['name']}
|
@@ -3,8 +3,8 @@ require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
3
3
|
describe "RhoconnectApiListClientDocs" do
|
4
4
|
it_should_behave_like "ApiHelper" do
|
5
5
|
it "should list client documents" do
|
6
|
-
|
7
|
-
|
6
|
+
source_id = "SimpleAdapter"
|
7
|
+
get "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{source_id}/docnames", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
8
8
|
JSON.parse(last_response.body).should == {
|
9
9
|
"cd"=>"client:application:testuser:#{@c.id}:SimpleAdapter:cd",
|
10
10
|
"cd_size"=>"client:application:testuser:#{@c.id}:SimpleAdapter:cd_size",
|
@@ -4,8 +4,8 @@ describe "RhoconnectApiSetRefreshTime" do
|
|
4
4
|
it_should_behave_like "ApiHelper" do
|
5
5
|
it "should set refresh time to 100s from 'now'" do
|
6
6
|
before = Time.now.to_i
|
7
|
-
|
8
|
-
:
|
7
|
+
put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}",
|
8
|
+
{:refresh_time => 100}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
9
9
|
after = Time.now.to_i
|
10
10
|
last_response.should be_ok
|
11
11
|
@s = Source.load(@s.id,@s_params)
|
@@ -15,8 +15,7 @@ describe "RhoconnectApiSetRefreshTime" do
|
|
15
15
|
|
16
16
|
it "should set refresh time to 'now' if no refresh_time provided" do
|
17
17
|
before = Time.now.to_i
|
18
|
-
|
19
|
-
:source_name => @s_fields[:name], :user_name => @u_fields[:login]
|
18
|
+
put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
20
19
|
after = Time.now.to_i
|
21
20
|
last_response.should be_ok
|
22
21
|
@s = Source.load(@s.id,@s_params)
|
@@ -25,17 +24,24 @@ describe "RhoconnectApiSetRefreshTime" do
|
|
25
24
|
end
|
26
25
|
|
27
26
|
it "should set poll interval" do
|
28
|
-
|
29
|
-
:source_name => @s_fields[:name], :user_name => @u_fields[:login], :poll_interval => 100
|
27
|
+
put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}", {:poll_interval => 100}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
30
28
|
last_response.should be_ok
|
31
29
|
@s = Source.load(@s.id,@s_params)
|
32
30
|
@s.poll_interval.should == 100
|
33
31
|
end
|
34
|
-
|
35
|
-
it "should should not set nil poll interval" do
|
36
|
-
post "/api/
|
32
|
+
|
33
|
+
it "should should not set nil poll interval with old route and deprecation warning" do
|
34
|
+
post "/api/set_refresh_time", :api_token => @api_token,
|
37
35
|
:source_name => @s_fields[:name], :user_name => @u_fields[:login], :poll_interval => nil
|
38
36
|
last_response.should be_ok
|
37
|
+
last_response.headers["Warning"].index('deprecated').should_not == nil
|
38
|
+
@s = Source.load(@s.id,@s_params)
|
39
|
+
@s.poll_interval.should == 300
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should should not set nil poll interval" do
|
43
|
+
put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}", {:poll_interval => nil}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
44
|
+
last_response.should be_ok
|
39
45
|
@s = Source.load(@s.id,@s_params)
|
40
46
|
@s.poll_interval.should == 300
|
41
47
|
end
|
@@ -5,7 +5,8 @@ describe "RhoconnectApiGetSourceParams" do
|
|
5
5
|
it_should_behave_like "ApiHelper" do
|
6
6
|
|
7
7
|
it "should list source attributes" do
|
8
|
-
|
8
|
+
source_id = "SampleAdapter"
|
9
|
+
get "/rc/#{Rhoconnect::API_VERSION}/sources/#{source_id}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
9
10
|
result = JSON.parse(last_response.body).sort {|x,y| y["name"] <=> x["name"] }
|
10
11
|
result.should == [
|
11
12
|
{"name"=>"rho__id", "value"=>"SampleAdapter", "type"=>"string"},
|
@@ -14,7 +15,7 @@ describe "RhoconnectApiGetSourceParams" do
|
|
14
15
|
{"name"=>"url", "value"=>"http://example.com", "type"=>"string"},
|
15
16
|
{"name"=>"login", "value"=>"testuser", "type"=>"string"},
|
16
17
|
{"name"=>"password", "value"=>"testpass", "type"=>"string"},
|
17
|
-
{"name"=>"priority", "value"=>
|
18
|
+
{"name"=>"priority", "value"=>1, "type"=>"integer"},
|
18
19
|
{"name"=>"callback_url", "value"=>nil, "type"=>"string"},
|
19
20
|
{"name"=>"poll_interval", "value"=>300, "type"=>"integer"},
|
20
21
|
{"name"=>"retry_limit", "type"=>"integer", "value"=>0},
|
@@ -2,24 +2,18 @@ require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
3
3
|
describe "RhoconnectApiListSources" do
|
4
4
|
it_should_behave_like "ApiHelper" do
|
5
|
-
it "should list all application sources" do
|
6
|
-
post "/api/source/list_sources", {:api_token => @api_token}
|
7
|
-
JSON.parse(last_response.body).sort.should == ["SimpleAdapter", "SampleAdapter", "FixedSchemaAdapter", "OtherAdapter"].sort
|
8
|
-
end
|
9
|
-
|
10
5
|
it "should list all application sources using partition_type param" do
|
11
|
-
|
12
|
-
{:api_token => @api_token, :partition_type => 'all'}
|
6
|
+
get "/rc/#{Rhoconnect::API_VERSION}/sources/type/all", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
13
7
|
JSON.parse(last_response.body).sort.should == ["SimpleAdapter", "SampleAdapter", "FixedSchemaAdapter", "OtherAdapter"].sort
|
14
8
|
end
|
15
9
|
|
16
10
|
it "should list app partition sources" do
|
17
|
-
|
11
|
+
get "/rc/#{Rhoconnect::API_VERSION}/sources/type/app", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
18
12
|
JSON.parse(last_response.body).sort.should == ["SimpleAdapter", "OtherAdapter"].sort
|
19
13
|
end
|
20
14
|
|
21
15
|
it "should list user partition sources" do
|
22
|
-
|
16
|
+
get "/rc/#{Rhoconnect::API_VERSION}/sources/type/user", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
23
17
|
JSON.parse(last_response.body).sort.should == ["SampleAdapter", "FixedSchemaAdapter"].sort
|
24
18
|
end
|
25
19
|
end
|
@@ -5,8 +5,8 @@ describe "RhoconnectApiUpdateSourceParams" do
|
|
5
5
|
it "should set poll_interval to 99 seconds" do
|
6
6
|
@s1 = Source.load(@s.id,@s_params)
|
7
7
|
before = @s1.poll_interval.to_i
|
8
|
-
|
9
|
-
:
|
8
|
+
put "/rc/#{Rhoconnect::API_VERSION}/sources/#{@s_fields[:name]}",
|
9
|
+
{:data => {:poll_interval => 99}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
10
10
|
last_response.should be_ok
|
11
11
|
@s2 = Source.load(@s.id,@s_params)
|
12
12
|
after = @s2.poll_interval
|
@@ -15,8 +15,8 @@ describe "RhoconnectApiUpdateSourceParams" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should fail to update the source if param is not found" do
|
18
|
-
|
19
|
-
:
|
18
|
+
put "/rc/#{Rhoconnect::API_VERSION}/sources/#{@s_fields[:name]}",
|
19
|
+
{:data => {:invalid_param => "invalid_data"}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
20
20
|
last_response.status.should == 500
|
21
21
|
last_response.body.match('undefined method').should_not be_nil
|
22
22
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'..','api_helper')
|
2
|
+
|
3
|
+
describe "RhoconnectApiGetDbDoc" do
|
4
|
+
it_should_behave_like "ApiHelper" do
|
5
|
+
it "should return db document by name" do
|
6
|
+
data = {'1' => {'foo' => 'bar'}}
|
7
|
+
set_state('abc:abc' => data)
|
8
|
+
dockey = 'abc:abc'
|
9
|
+
get "/rc/#{Rhoconnect::API_VERSION}/store/#{dockey}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
10
|
+
last_response.should be_ok
|
11
|
+
JSON.parse(last_response.body).should == data
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return db document by name and print deprecation warning with old route" do
|
15
|
+
data = {'1' => {'foo' => 'bar'}}
|
16
|
+
set_state('abc:abc' => data)
|
17
|
+
post "/api/get_db_doc", {:doc => 'abc:abc'}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
18
|
+
last_response.should be_ok
|
19
|
+
last_response.headers["Warning"].index('deprecated').should_not == nil
|
20
|
+
JSON.parse(last_response.body).should == data
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return db document by name and data_type" do
|
24
|
+
data = 'some string'
|
25
|
+
set_state('abc:abc' => data)
|
26
|
+
dockey = 'abc:abc'
|
27
|
+
get "/rc/#{Rhoconnect::API_VERSION}/store/#{dockey}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
28
|
+
last_response.should be_ok
|
29
|
+
last_response.body.should == data
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'..','api_helper')
|
2
|
+
|
3
|
+
describe "RhoconnectApiSetDbDoc" do
|
4
|
+
it_should_behave_like "ApiHelper" do
|
5
|
+
it "should set db document by doc name and data" do
|
6
|
+
data = {'1' => {'foo' => 'bar'}}
|
7
|
+
docname = 'application:abc'
|
8
|
+
post "/rc/#{Rhoconnect::API_VERSION}/store/#{docname}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
9
|
+
last_response.should be_ok
|
10
|
+
verify_result(docname => data)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set db document by doc name, data type, and data" do
|
14
|
+
data = 'some string'
|
15
|
+
docname = 'abc:abc:str'
|
16
|
+
post "/rc/#{Rhoconnect::API_VERSION}/store/#{docname}", {:data => data, :data_type => :string}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
17
|
+
last_response.should be_ok
|
18
|
+
verify_result('abc:abc:str' => data)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should set db document by doc name, data type, and data with old route and deprecation warning" do
|
22
|
+
data = 'some string'
|
23
|
+
post "/api/set_db_doc", {:doc => 'abc:abc:str', :data => data, :data_type => :string}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
24
|
+
last_response.headers['Warning'].index('deprecated').should_not == nil
|
25
|
+
last_response.should be_ok
|
26
|
+
verify_result('abc:abc:str' => data)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should append data in set db document by doc name and data" do
|
30
|
+
data = {'1' => {'foo' => 'bar'}}
|
31
|
+
data2 = {'2' => {'foo1' => 'bar1'}}
|
32
|
+
data3 = data.merge(data2)
|
33
|
+
docname = 'abc:abc'
|
34
|
+
post "/rc/#{Rhoconnect::API_VERSION}/store/#{docname}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
35
|
+
last_response.should be_ok
|
36
|
+
verify_result('abc:abc' => data)
|
37
|
+
|
38
|
+
post "/rc/#{Rhoconnect::API_VERSION}/store/#{docname}", {:data => data2, :append => true}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
39
|
+
last_response.should be_ok
|
40
|
+
verify_result('abc:abc' => data3)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'..','api_helper')
|
2
|
+
|
3
|
+
describe "RhoconnectApiAppServer" do
|
4
|
+
it_should_behave_like "ApiHelper" do
|
5
|
+
|
6
|
+
it "should save adapter url" do
|
7
|
+
params = {:attributes => {:adapter_url => 'http://test.com'}}
|
8
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/appserver", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
9
|
+
last_response.should be_ok
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should get adapter url" do
|
13
|
+
params = {}
|
14
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/appserver", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
15
|
+
last_response.should be_ok
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should get check deprecation warning in /api/get_adapter" do
|
19
|
+
params = {}
|
20
|
+
post "/api/get_adapter", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
21
|
+
last_response.should be_ok
|
22
|
+
last_response.headers["Warning"].index('deprecated').should_not == nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should get check deprecation warning in /api/source/get_adapter" do
|
26
|
+
params = {}
|
27
|
+
post "/api/source/get_adapter", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
28
|
+
last_response.should be_ok
|
29
|
+
last_response.headers["Warning"].index('deprecated').should_not == nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -3,8 +3,7 @@ require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
3
3
|
describe "RhoconnectApiGetLicenseInfo" do
|
4
4
|
it_should_behave_like "ApiHelper" do
|
5
5
|
it "should get license info" do
|
6
|
-
|
7
|
-
post "/api/admin/get_license_info", {:api_token => @api_token}
|
6
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/license", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
8
7
|
JSON.parse(last_response.body).should == {
|
9
8
|
"available" => 9,
|
10
9
|
"issued" => "Fri Apr 23 17:20:13 -0700 2010",
|
@@ -14,8 +13,6 @@ describe "RhoconnectApiGetLicenseInfo" do
|
|
14
13
|
end
|
15
14
|
|
16
15
|
it "should get custom_license info with deprecation warning" do
|
17
|
-
true.should == true
|
18
|
-
|
19
16
|
# this one for test purposes to make sure
|
20
17
|
# that an old way custom REST API still works
|
21
18
|
Rhoconnect::Server.api :custom_license_info do |params,user|
|
@@ -26,7 +23,7 @@ describe "RhoconnectApiGetLicenseInfo" do
|
|
26
23
|
:available => Rhoconnect.license.available }.to_json
|
27
24
|
end
|
28
25
|
|
29
|
-
post "/api/custom_license_info", {
|
26
|
+
post "/api/custom_license_info", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
30
27
|
JSON.parse(last_response.body).should == {
|
31
28
|
"available" => 9,
|
32
29
|
"issued" => "Fri Apr 23 17:20:13 -0700 2010",
|
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
3
3
|
describe "RhoconnectApiGetApiToken" do
|
4
4
|
it_should_behave_like "ApiHelper" do
|
5
5
|
it "should login and receive the token string" do
|
6
|
-
post "/
|
6
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => 'rhoadmin',:password => ''
|
7
7
|
last_response.body.should == @api_token
|
8
8
|
end
|
9
9
|
|
@@ -13,28 +13,21 @@ describe "RhoconnectApiGetApiToken" do
|
|
13
13
|
last_response.headers["Warning"].index('deprecated').should_not == nil
|
14
14
|
end
|
15
15
|
|
16
|
-
it "should get deprecation warning for get_api_token method" do
|
17
|
-
post "/api/admin/login", :login => 'rhoadmin',:password => ''
|
18
|
-
post "/api/admin/get_api_token"
|
19
|
-
last_response.body.should == @api_token
|
20
|
-
last_response.headers['Warning'].index('deprecated').should_not == nil
|
21
|
-
end
|
22
|
-
|
23
16
|
it "should fail to login and get token if user is not rhoadmin" do
|
24
17
|
Rhoconnect.appserver = nil
|
25
|
-
post "/
|
18
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => @u_fields[:login],:password => 'testpass'
|
26
19
|
last_response.status.should == 422
|
27
20
|
last_response.body.should == 'Invalid/missing API user'
|
28
21
|
end
|
29
22
|
|
30
23
|
it "should return 422 if no token provided" do
|
31
24
|
params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
|
32
|
-
post "/
|
25
|
+
post "/rc/#{Rhoconnect::API_VERSION}/users", params
|
33
26
|
last_response.status.should == 422
|
34
27
|
end
|
35
28
|
|
36
29
|
it "response should have cache-control and pragma headers set to no-cache" do
|
37
|
-
post "/login", :login => 'rhoadmin',:password => ''
|
30
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => 'rhoadmin',:password => ''
|
38
31
|
last_response.headers['Cache-Control'].should == 'no-cache'
|
39
32
|
last_response.headers['Pragma'].should == 'no-cache'
|
40
33
|
end
|
@@ -4,7 +4,7 @@ describe "RhoconnectApiReset" do
|
|
4
4
|
it_should_behave_like "ApiHelper" do
|
5
5
|
it "should reset and re-create rhoadmin user with bootstrap" do
|
6
6
|
Store.put_data('somedoc',{ '1' => {'foo'=>'bar'}})
|
7
|
-
post "/
|
7
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/reset", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
8
8
|
App.is_exist?(test_app_name).should == true
|
9
9
|
Store.get_data('somedoc').should == {}
|
10
10
|
User.authenticate('rhoadmin','').should_not be_nil
|
@@ -12,7 +12,7 @@ describe "RhoconnectApiReset" do
|
|
12
12
|
|
13
13
|
it "should reset and re-create rhoadmin user with initializer" do
|
14
14
|
Store.put_data('somedoc',{ '1' => {'foo'=>'bar'}})
|
15
|
-
post "/
|
15
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/reset", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
16
16
|
App.is_exist?(test_app_name).should == true
|
17
17
|
Store.get_data('somedoc').should == {}
|
18
18
|
User.authenticate('rhoadmin','').should_not be_nil
|
@@ -20,7 +20,7 @@ describe "RhoconnectApiStats" do
|
|
20
20
|
it "should retrieve metric names" do
|
21
21
|
Store.set_value('stat:foo', '1')
|
22
22
|
Store.set_value('stat:bar', '2')
|
23
|
-
|
23
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/stats", {
|
24
24
|
:api_token => @api_token,
|
25
25
|
:names => '*'
|
26
26
|
}
|
@@ -31,31 +31,38 @@ describe "RhoconnectApiStats" do
|
|
31
31
|
it "should retrieve range metric" do
|
32
32
|
Store.db.zadd('stat:foo', 2, "1:2")
|
33
33
|
Store.db.zadd('stat:foo', 3, "1:3")
|
34
|
-
|
35
|
-
:api_token => @api_token,
|
34
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/stats", {
|
36
35
|
:metric => 'foo',
|
37
36
|
:start => 0,
|
38
37
|
:finish => -1
|
39
|
-
}
|
38
|
+
}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
40
39
|
last_response.should be_ok
|
41
40
|
JSON.parse(last_response.body).should == ["1:2", "1:3"]
|
42
41
|
end
|
43
42
|
|
44
43
|
it "should retrieve string metric" do
|
45
44
|
Store.db.set('stat:foo', 'bar')
|
46
|
-
|
47
|
-
:api_token => @api_token,
|
45
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/stats", {
|
48
46
|
:metric => 'foo'
|
49
|
-
}
|
47
|
+
}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
48
|
+
last_response.should be_ok
|
49
|
+
last_response.body.should == 'bar'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should retrieve string metric with old route and print deprecation warning" do
|
53
|
+
Store.db.set('stat:foo', 'bar')
|
54
|
+
post "/api/stats", {
|
55
|
+
:metric => 'foo'
|
56
|
+
}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
50
57
|
last_response.should be_ok
|
58
|
+
last_response.headers["Warning"].index('deprecated').should_not == nil
|
51
59
|
last_response.body.should == 'bar'
|
52
60
|
end
|
53
61
|
|
54
62
|
it "should raise error on unknown metric" do
|
55
|
-
|
56
|
-
:api_token => @api_token,
|
63
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/stats", {
|
57
64
|
:metric => 'foo'
|
58
|
-
}
|
65
|
+
}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
59
66
|
last_response.status.should == 404
|
60
67
|
last_response.body.should == 'Unknown metric'
|
61
68
|
end
|
@@ -63,10 +70,9 @@ describe "RhoconnectApiStats" do
|
|
63
70
|
it "should raise error if stats not enabled" do
|
64
71
|
Rhoconnect::Server.set :stats, false
|
65
72
|
Rhoconnect.stats = false
|
66
|
-
|
67
|
-
:api_token => @api_token,
|
73
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/stats", {
|
68
74
|
:metric => 'foo'
|
69
|
-
}
|
75
|
+
}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
70
76
|
last_response.status.should == 500
|
71
77
|
last_response.body.should == 'Stats not enabled'
|
72
78
|
end
|
@@ -3,22 +3,29 @@ require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
3
3
|
describe "RhoconnectApiCreateUser" do
|
4
4
|
it_should_behave_like "ApiHelper" do
|
5
5
|
it "should create user" do
|
6
|
-
params = {:
|
7
|
-
|
8
|
-
post "/api/user/create_user", params
|
6
|
+
params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
|
7
|
+
post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
9
8
|
last_response.should be_ok
|
10
9
|
User.load(params[:attributes][:login]).login.should == params[:attributes][:login]
|
11
10
|
User.authenticate(params[:attributes][:login],
|
12
11
|
params[:attributes][:password]).login.should == params[:attributes][:login]
|
13
12
|
@a.users.members.sort.should == [@u.login, params[:attributes][:login]]
|
14
13
|
end
|
15
|
-
|
14
|
+
|
15
|
+
it "should create user and print a deprecation warning in the route" do
|
16
|
+
params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
|
17
|
+
post "/api/create_user", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
18
|
+
last_response.should be_ok
|
19
|
+
last_response.headers['Warning'].index('deprecated').should_not == nil
|
20
|
+
User.load(params[:attributes][:login]).login.should == params[:attributes][:login]
|
21
|
+
User.authenticate(params[:attributes][:login],
|
22
|
+
params[:attributes][:password]).login.should == params[:attributes][:login]
|
23
|
+
@a.users.members.sort.should == [@u.login, params[:attributes][:login]]
|
24
|
+
end
|
16
25
|
|
17
|
-
it_should_behave_like "ApiHelper" do
|
18
26
|
it "should not create user with empty login" do
|
19
|
-
params = {:
|
20
|
-
|
21
|
-
post "/api/user/create_user", params
|
27
|
+
params = {:attributes => {:login => '', :password => ''}}
|
28
|
+
post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
22
29
|
last_response.should_not be_ok
|
23
30
|
User.is_exist?('').should == false
|
24
31
|
end
|