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
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiListSources" do
|
|
4
|
-
|
|
5
|
-
it "should list all application sources using partition_type param" do
|
|
6
|
-
get "/rc/#{Rhoconnect::API_VERSION}/sources/type/all", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
7
|
-
JSON.parse(last_response.body).sort.should == ["SimpleAdapter", "SampleAdapter", "FixedSchemaAdapter", "OtherAdapter", "JsSample"].sort
|
|
8
|
-
end
|
|
4
|
+
include_examples "ApiHelper"
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
it "should list all application sources using partition_type param" do
|
|
7
|
+
get "/rc/#{Rhoconnect::API_VERSION}/sources/type/all", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
8
|
+
JSON.parse(last_response.body).sort.should == ["SimpleAdapter", "SampleAdapter", "FixedSchemaAdapter", "OtherAdapter", "JsSample"].sort
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should list app partition sources" do
|
|
12
|
+
get "/rc/#{Rhoconnect::API_VERSION}/sources/type/app", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
13
|
+
JSON.parse(last_response.body).sort.should == ["SimpleAdapter", "OtherAdapter"].sort
|
|
14
|
+
end
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
end
|
|
16
|
+
it "should list user partition sources" do
|
|
17
|
+
get "/rc/#{Rhoconnect::API_VERSION}/sources/type/user", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
18
|
+
JSON.parse(last_response.body).sort.should == ["SampleAdapter", "FixedSchemaAdapter", "JsSample"].sort
|
|
19
19
|
end
|
|
20
20
|
end
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiUpdateSourceParams" do
|
|
4
|
-
|
|
5
|
-
it "should set poll_interval to 99 seconds" do
|
|
6
|
-
@s1 = Source.load(@s.id,@s_params)
|
|
7
|
-
before = @s1.poll_interval.to_i
|
|
8
|
-
put "/rc/#{Rhoconnect::API_VERSION}/sources/#{@s_fields[:name]}",
|
|
9
|
-
{:data => {:poll_interval => 99}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
10
|
-
last_response.should be_ok
|
|
11
|
-
@s2 = Source.load(@s.id,@s_params)
|
|
12
|
-
after = @s2.poll_interval
|
|
13
|
-
before.should == 300
|
|
14
|
-
after.should == 99
|
|
15
|
-
end
|
|
4
|
+
include_examples "ApiHelper"
|
|
16
5
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
it "should set poll_interval to 99 seconds" do
|
|
7
|
+
@s1 = Source.load(@s.id,@s_params)
|
|
8
|
+
before = @s1.poll_interval.to_i
|
|
9
|
+
put "/rc/#{Rhoconnect::API_VERSION}/sources/#{@s_fields[:name]}",
|
|
10
|
+
{:data => {:poll_interval => 99}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
11
|
+
last_response.should be_ok
|
|
12
|
+
@s2 = Source.load(@s.id,@s_params)
|
|
13
|
+
after = @s2.poll_interval
|
|
14
|
+
before.should == 300
|
|
15
|
+
after.should == 99
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should fail to update the source if param is not found" do
|
|
19
|
+
put "/rc/#{Rhoconnect::API_VERSION}/sources/#{@s_fields[:name]}",
|
|
20
|
+
{:data => {:invalid_param => "invalid_data"}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
21
|
+
last_response.status.should == 500
|
|
22
|
+
last_response.body.match('undefined method').should_not be_nil
|
|
23
|
+
end
|
|
24
24
|
end
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiGetDbDoc" do
|
|
4
|
-
|
|
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
|
|
4
|
+
include_examples "ApiHelper"
|
|
22
5
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
6
|
+
it "should return db document by name" do
|
|
7
|
+
data = {'1' => {'foo' => 'bar'}}
|
|
8
|
+
set_state('abc:abc' => data)
|
|
9
|
+
dockey = 'abc:abc'
|
|
10
|
+
get "/rc/#{Rhoconnect::API_VERSION}/store/#{dockey}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
11
|
+
last_response.should be_ok
|
|
12
|
+
JSON.parse(last_response.body).should == data
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return db document by name and print deprecation warning with old route" do
|
|
16
|
+
data = {'1' => {'foo' => 'bar'}}
|
|
17
|
+
set_state('abc:abc' => data)
|
|
18
|
+
post "/api/get_db_doc", {:doc => 'abc:abc'}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
19
|
+
last_response.should be_ok
|
|
20
|
+
last_response.headers["Warning"].index('deprecated').should_not == nil
|
|
21
|
+
JSON.parse(last_response.body).should == data
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should return db document by name and data_type" do
|
|
25
|
+
data = 'some string'
|
|
26
|
+
set_state('abc:abc' => data)
|
|
27
|
+
dockey = 'abc:abc'
|
|
28
|
+
get "/rc/#{Rhoconnect::API_VERSION}/store/#{dockey}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
29
|
+
last_response.should be_ok
|
|
30
|
+
last_response.body.should == data
|
|
31
|
+
end
|
|
32
32
|
end
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiSetDbDoc" do
|
|
4
|
-
|
|
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
|
|
4
|
+
include_examples "ApiHelper"
|
|
12
5
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
6
|
+
it "should set db document by doc name and data" do
|
|
7
|
+
data = {'1' => {'foo' => 'bar'}}
|
|
8
|
+
docname = 'application:abc'
|
|
9
|
+
post "/rc/#{Rhoconnect::API_VERSION}/store/#{docname}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
10
|
+
last_response.should be_ok
|
|
11
|
+
verify_result(docname => data)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should set db document by doc name, data type, and data" do
|
|
15
|
+
data = 'some string'
|
|
16
|
+
docname = 'abc:abc:str'
|
|
17
|
+
post "/rc/#{Rhoconnect::API_VERSION}/store/#{docname}", {:data => data, :data_type => :string}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
18
|
+
last_response.should be_ok
|
|
19
|
+
verify_result('abc:abc:str' => data)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should set db document by doc name, data type, and data with old route and deprecation warning" do
|
|
23
|
+
data = 'some string'
|
|
24
|
+
post "/api/set_db_doc", {:doc => 'abc:abc:str', :data => data, :data_type => :string}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
25
|
+
last_response.headers['Warning'].index('deprecated').should_not == nil
|
|
26
|
+
last_response.should be_ok
|
|
27
|
+
verify_result('abc:abc:str' => data)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should append data in set db document by doc name and data" do
|
|
31
|
+
data = {'1' => {'foo' => 'bar'}}
|
|
32
|
+
data2 = {'2' => {'foo1' => 'bar1'}}
|
|
33
|
+
data3 = data.merge(data2)
|
|
34
|
+
docname = 'abc:abc'
|
|
35
|
+
post "/rc/#{Rhoconnect::API_VERSION}/store/#{docname}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
36
|
+
last_response.should be_ok
|
|
37
|
+
verify_result('abc:abc' => data)
|
|
38
|
+
|
|
39
|
+
post "/rc/#{Rhoconnect::API_VERSION}/store/#{docname}", {:data => data2, :append => true}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
40
|
+
last_response.should be_ok
|
|
41
|
+
verify_result('abc:abc' => data3)
|
|
42
|
+
end
|
|
43
43
|
end
|
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiAppServer" do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
|
|
4
|
+
include_examples "ApiHelper"
|
|
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
|
|
33
31
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiGetLicenseInfo" do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
end
|
|
4
|
+
include_examples "ApiHelper"
|
|
5
|
+
|
|
6
|
+
it "should get license info" do
|
|
7
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/license", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
8
|
+
JSON.parse(last_response.body).should == {
|
|
9
|
+
"available" => 9,
|
|
10
|
+
"issued" => "Fri Apr 23 17:20:13 -0700 2010",
|
|
11
|
+
"seats" => 10,
|
|
12
|
+
"rhoconnect_version" => "Version 1",
|
|
13
|
+
"licensee" => "Rhomobile" }
|
|
14
|
+
end
|
|
15
15
|
end
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiGetApiToken" do
|
|
4
|
-
|
|
5
|
-
it "should login and receive the token string" do
|
|
6
|
-
post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => 'rhoadmin',:password => ''
|
|
7
|
-
last_response.body.should == @api_token
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "should login using the old route and show deprecation warning" do
|
|
11
|
-
post "/login", :login => 'rhoadmin',:password => ''
|
|
12
|
-
last_response.body.should == @api_token
|
|
13
|
-
last_response.headers["Warning"].index('deprecated').should_not == nil
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should fail to login and get token if user is not rhoadmin" do
|
|
17
|
-
Rhoconnect.appserver = nil
|
|
18
|
-
post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => @u_fields[:login],:password => 'testpass'
|
|
19
|
-
last_response.status.should == 422
|
|
20
|
-
last_response.body.should == 'Invalid/missing API user'
|
|
21
|
-
end
|
|
4
|
+
include_examples "ApiHelper"
|
|
22
5
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
last_response.status.should == 422
|
|
28
|
-
last_response.body.should == 'Invalid/missing API user'
|
|
29
|
-
end
|
|
6
|
+
it "should login and receive the token string" do
|
|
7
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => 'rhoadmin',:password => ''
|
|
8
|
+
last_response.body.should == @api_token
|
|
9
|
+
end
|
|
30
10
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
end
|
|
11
|
+
it "should login using the old route and show deprecation warning" do
|
|
12
|
+
post "/login", :login => 'rhoadmin',:password => ''
|
|
13
|
+
last_response.body.should == @api_token
|
|
14
|
+
last_response.headers["Warning"].index('deprecated').should_not == nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should fail to login and get token if user is not rhoadmin" do
|
|
18
|
+
Rhoconnect.appserver = nil
|
|
19
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => @u_fields[:login],:password => 'testpass'
|
|
20
|
+
last_response.status.should == 422
|
|
21
|
+
last_response.body.should == 'Invalid/missing API user'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should return 422 if token doesn't belong to the API user" do
|
|
25
|
+
invalid_api_token = ApiToken.create({:value => 'mytoken', :user_id => 'notadmin'})
|
|
26
|
+
params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
|
|
27
|
+
post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => invalid_api_token.value}
|
|
28
|
+
last_response.status.should == 422
|
|
29
|
+
last_response.body.should == 'Invalid/missing API user'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should return 422 if no token provided" do
|
|
33
|
+
params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
|
|
34
|
+
post "/rc/#{Rhoconnect::API_VERSION}/users", params
|
|
35
|
+
last_response.status.should == 422
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "response should have cache-control and pragma headers set to no-cache" do
|
|
39
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => 'rhoadmin',:password => ''
|
|
40
|
+
last_response.headers['Cache-Control'].should == 'no-cache'
|
|
41
|
+
last_response.headers['Pragma'].should == 'no-cache'
|
|
42
|
+
end
|
|
43
43
|
end
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiReset" do
|
|
4
|
-
|
|
5
|
-
it "should reset and re-create rhoadmin user with bootstrap" do
|
|
6
|
-
Store.put_data('somedoc',{ '1' => {'foo'=>'bar'}})
|
|
7
|
-
post "/rc/#{Rhoconnect::API_VERSION}/system/reset", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
8
|
-
App.is_exist?(test_app_name).should == true
|
|
9
|
-
Store.get_data('somedoc').should == {}
|
|
10
|
-
User.authenticate('rhoadmin','').should_not be_nil
|
|
11
|
-
end
|
|
4
|
+
include_examples "ApiHelper"
|
|
12
5
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
it "should reset and re-create rhoadmin user with bootstrap" do
|
|
7
|
+
Store.put_data('somedoc',{ '1' => {'foo'=>'bar'}})
|
|
8
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/reset", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
9
|
+
App.is_exist?(test_app_name).should == true
|
|
10
|
+
Store.get_data('somedoc').should == {}
|
|
11
|
+
User.authenticate('rhoadmin','').should_not be_nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should reset and re-create rhoadmin user with initializer" do
|
|
15
|
+
Store.put_data('somedoc',{ '1' => {'foo'=>'bar'}})
|
|
16
|
+
post "/rc/#{Rhoconnect::API_VERSION}/system/reset", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
17
|
+
App.is_exist?(test_app_name).should == true
|
|
18
|
+
Store.get_data('somedoc').should == {}
|
|
19
|
+
User.authenticate('rhoadmin','').should_not be_nil
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -1,80 +1,79 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiStats" do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def app
|
|
7
|
-
@app ||= Rack::URLMap.new Rhoconnect.url_map
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
before(:each) do
|
|
11
|
-
Rhoconnect::Server.set :stats, true
|
|
12
|
-
Rhoconnect.stats = true
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
after(:each) do
|
|
16
|
-
Rhoconnect::Server.set :stats, false
|
|
17
|
-
Rhoconnect.stats = false
|
|
18
|
-
end
|
|
4
|
+
include_examples "ApiHelper"
|
|
19
5
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
get "/rc/#{Rhoconnect::API_VERSION}/system/stats", {
|
|
24
|
-
:api_token => @api_token,
|
|
25
|
-
:names => '*'
|
|
26
|
-
}
|
|
27
|
-
last_response.should be_ok
|
|
28
|
-
JSON.parse(last_response.body).sort.should == ['bar', 'foo']
|
|
29
|
-
end
|
|
6
|
+
def app
|
|
7
|
+
@app ||= Rack::URLMap.new Rhoconnect.url_map
|
|
8
|
+
end
|
|
30
9
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
:metric => 'foo',
|
|
36
|
-
:start => 0,
|
|
37
|
-
:finish => -1
|
|
38
|
-
}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
39
|
-
last_response.should be_ok
|
|
40
|
-
JSON.parse(last_response.body).should == ["1:2", "1:3"]
|
|
41
|
-
end
|
|
10
|
+
before(:each) do
|
|
11
|
+
Rhoconnect::Server.set :stats, true
|
|
12
|
+
Rhoconnect.stats = true
|
|
13
|
+
end
|
|
42
14
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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.put_value('stat:foo', 'bar')
|
|
54
|
-
post "/api/stats", {
|
|
55
|
-
:metric => 'foo'
|
|
56
|
-
}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
57
|
-
last_response.should be_ok
|
|
58
|
-
last_response.headers["Warning"].index('deprecated').should_not == nil
|
|
59
|
-
last_response.body.should == 'bar'
|
|
60
|
-
end
|
|
15
|
+
after(:each) do
|
|
16
|
+
Rhoconnect::Server.set :stats, false
|
|
17
|
+
Rhoconnect.stats = false
|
|
18
|
+
end
|
|
61
19
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
20
|
+
it "should retrieve metric names" do
|
|
21
|
+
Store.set_value('stat:foo', '1')
|
|
22
|
+
Store.set_value('stat:bar', '2')
|
|
23
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/stats", {
|
|
24
|
+
:api_token => @api_token,
|
|
25
|
+
:names => '*'
|
|
26
|
+
}
|
|
27
|
+
last_response.should be_ok
|
|
28
|
+
JSON.parse(last_response.body).sort.should == ['bar', 'foo']
|
|
29
|
+
end
|
|
69
30
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
31
|
+
it "should retrieve range metric" do
|
|
32
|
+
Store.zadd('stat:foo', 2, "1:2")
|
|
33
|
+
Store.zadd('stat:foo', 3, "1:3")
|
|
34
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/stats", {
|
|
35
|
+
:metric => 'foo',
|
|
36
|
+
:start => 0,
|
|
37
|
+
:finish => -1
|
|
38
|
+
}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
39
|
+
last_response.should be_ok
|
|
40
|
+
JSON.parse(last_response.body).should == ["1:2", "1:3"]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should retrieve string metric" do
|
|
44
|
+
Store.put_value('stat:foo', 'bar')
|
|
45
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/stats", {
|
|
46
|
+
:metric => 'foo'
|
|
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.put_value('stat:foo', 'bar')
|
|
54
|
+
post "/api/stats", {
|
|
55
|
+
:metric => 'foo'
|
|
56
|
+
}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
57
|
+
last_response.should be_ok
|
|
58
|
+
last_response.headers["Warning"].index('deprecated').should_not == nil
|
|
59
|
+
last_response.body.should == 'bar'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should raise error on unknown metric" do
|
|
63
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/stats", {
|
|
64
|
+
:metric => 'foo'
|
|
65
|
+
}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
66
|
+
last_response.status.should == 404
|
|
67
|
+
last_response.body.should == 'Unknown metric'
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should raise error if stats not enabled" do
|
|
71
|
+
Rhoconnect::Server.set :stats, false
|
|
72
|
+
Rhoconnect.stats = false
|
|
73
|
+
get "/rc/#{Rhoconnect::API_VERSION}/system/stats", {
|
|
74
|
+
:metric => 'foo'
|
|
75
|
+
}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
76
|
+
last_response.status.should == 500
|
|
77
|
+
last_response.body.should == 'Stats not enabled'
|
|
78
|
+
end
|
|
80
79
|
end
|