rhoconnect 4.0.4 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG.md +54 -5
  3. data/CREDITS +219 -219
  4. data/Gemfile +2 -2
  5. data/Gemfile.lock +68 -79
  6. data/Rakefile +1 -2
  7. data/bench/benchapp/spec/models/ruby/mock_adapter_spec.rb +17 -17
  8. data/bench/benchapp/spec/models/ruby/queue_mock_adapter_spec.rb +17 -17
  9. data/bench/benchapp/spec/spec_helper.rb +3 -3
  10. data/bench/blobapp/spec/models/ruby/blob_adapter_spec.rb +17 -17
  11. data/bench/blobapp/spec/spec_helper.rb +3 -3
  12. data/bench/lib/bench/runner.rb +1 -69
  13. data/bench/lib/bench.rb +18 -18
  14. data/bench/spec/mock_adapter_spec.rb +54 -55
  15. data/bench/spec/mock_client_spec.rb +47 -48
  16. data/bench/spec/result_spec.rb +41 -44
  17. data/bench/spec/utils_spec.rb +24 -25
  18. data/commands/generators/app.rb +7 -5
  19. data/commands/generators/controller.rb +7 -5
  20. data/commands/generators/model.rb +7 -5
  21. data/commands/generators/source.rb +7 -5
  22. data/commands/parser.rb +1 -1
  23. data/commands/redis/redis_download.rb +1 -1
  24. data/doc/async-jobs.txt +9 -9
  25. data/doc/supported-platforms.txt +0 -2
  26. data/generators/rhoconnect.rb +92 -212
  27. data/generators/templates/application/rcgemfile +3 -3
  28. data/generators/templates/application/spec/application_controller_spec.rb +14 -16
  29. data/generators/templates/application/spec/js_spec.rb +20 -20
  30. data/generators/templates/application/spec/spec_helper.rb +1 -1
  31. data/generators/templates/source/controllers/ruby/controller_spec.rb +18 -19
  32. data/generators/templates/source/models/ruby/model_spec.rb +17 -17
  33. data/install.sh +10 -21
  34. data/installer/unix-like/rho_connect_install_constants.rb +5 -5
  35. data/installer/unix-like/rho_connect_install_installers.rb +4 -4
  36. data/installer/utils/constants.rb +6 -6
  37. data/installer/utils/nix_install_test.rb +29 -29
  38. data/installer/utils/package_upload/repos.rake +16 -26
  39. data/js-adapters/node.rb +4 -4
  40. data/js-adapters/node_channel.rb +4 -8
  41. data/lib/rhoconnect/db_adapter.rb +13 -13
  42. data/lib/rhoconnect/handler/changes/engine.rb +1 -1
  43. data/lib/rhoconnect/jobs/bulk_data_job.rb +29 -29
  44. data/lib/rhoconnect/license.rb +7 -7
  45. data/lib/rhoconnect/model/helpers/find_duplicates_on_update.rb +13 -13
  46. data/lib/rhoconnect/ping/apple.rb +4 -4
  47. data/lib/rhoconnect/server.rb +2 -2
  48. data/lib/rhoconnect/source.rb +2 -2
  49. data/lib/rhoconnect/store.rb +12 -6
  50. data/lib/rhoconnect/utilities.rb +2 -2
  51. data/lib/rhoconnect/version.rb +1 -1
  52. data/lib/rhoconnect.rb +6 -4
  53. data/rhoconnect.gemspec +5 -6
  54. data/spec/api/api_helper.rb +1 -1
  55. data/spec/api/app/fast_delete_spec.rb +22 -22
  56. data/spec/api/app/fast_insert_spec.rb +23 -23
  57. data/spec/api/app/fast_update_spec.rb +63 -63
  58. data/spec/api/app/push_deletes_spec.rb +11 -13
  59. data/spec/api/app/push_objects_spec.rb +39 -39
  60. data/spec/api/client/client_get_db_doc_spec.rb +29 -29
  61. data/spec/api/client/client_set_db_doc_spec.rb +11 -11
  62. data/spec/api/client/get_client_params_spec.rb +29 -29
  63. data/spec/api/client/list_client_docs_spec.rb +32 -34
  64. data/spec/api/client/reset_spec.rb +30 -30
  65. data/spec/api/readstate/set_refresh_time_spec.rb +43 -43
  66. data/spec/api/source/get_source_params_spec.rb +32 -34
  67. data/spec/api/source/list_sources_spec.rb +13 -13
  68. data/spec/api/source/update_source_params_spec.rb +19 -19
  69. data/spec/api/store/get_db_doc_spec.rb +27 -27
  70. data/spec/api/store/set_db_doc_spec.rb +38 -38
  71. data/spec/api/system/adapter_spec.rb +27 -29
  72. data/spec/api/system/get_license_info_spec.rb +11 -11
  73. data/spec/api/system/login_spec.rb +37 -37
  74. data/spec/api/system/reset_spec.rb +15 -15
  75. data/spec/api/system/stats_spec.rb +70 -71
  76. data/spec/api/user/create_user_spec.rb +37 -37
  77. data/spec/api/user/delete_client_spec.rb +7 -7
  78. data/spec/api/user/delete_user_spec.rb +62 -62
  79. data/spec/api/user/list_clients_spec.rb +24 -24
  80. data/spec/api/user/list_source_docs_spec.rb +29 -29
  81. data/spec/api/user/list_users_spec.rb +22 -22
  82. data/spec/api/user/ping_spec.rb +18 -18
  83. data/spec/api/user/show_user_spec.rb +10 -10
  84. data/spec/api/user/update_user_spec.rb +43 -43
  85. data/spec/api/user/user_get_db_doc_spec.rb +12 -12
  86. data/spec/api/user/user_set_db_doc_spec.rb +37 -37
  87. data/spec/api_token_spec.rb +8 -8
  88. data/spec/app_spec.rb +18 -17
  89. data/spec/apps/jstestapp/settings/settings.yml +2 -0
  90. data/spec/async_spec.rb +9 -11
  91. data/spec/bulk_data/bulk_data_spec.rb +120 -120
  92. data/spec/cli/cli_spec.rb +50 -53
  93. data/spec/client_spec.rb +105 -105
  94. data/spec/client_sync_spec.rb +529 -528
  95. data/spec/controllers/js_base_spec.rb +147 -141
  96. data/spec/doc/doc_spec.rb +51 -52
  97. data/spec/document_spec.rb +58 -58
  98. data/spec/dynamic_adapter_spec.rb +33 -36
  99. data/spec/generator/generator_spec.rb +76 -42
  100. data/spec/jobs/bulk_data_job_spec.rb +101 -102
  101. data/spec/jobs/ping_job_spec.rb +176 -177
  102. data/spec/jobs/source_job_spec.rb +24 -25
  103. data/spec/license_spec.rb +54 -55
  104. data/spec/models/js_base_spec.rb +121 -120
  105. data/spec/perf/bulk_data_perf_spec.rb +23 -24
  106. data/spec/perf/perf_spec_helper.rb +7 -7
  107. data/spec/perf/store_perf_spec.rb +139 -140
  108. data/spec/ping/apple_spec.rb +65 -65
  109. data/spec/ping/gcm_spec.rb +83 -84
  110. data/spec/ping/rhoconnect_push_spec.rb +52 -53
  111. data/spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb +100 -101
  112. data/spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb +29 -31
  113. data/spec/read_state_spec.rb +24 -25
  114. data/spec/rhoconnect_spec.rb +7 -7
  115. data/spec/server/server_spec.rb +664 -662
  116. data/spec/server/stats_spec.rb +12 -12
  117. data/spec/source_adapter_spec.rb +124 -125
  118. data/spec/source_spec.rb +148 -149
  119. data/spec/source_sync_spec.rb +736 -736
  120. data/spec/spec_helper.rb +4 -5
  121. data/spec/stats/record_spec.rb +22 -21
  122. data/spec/store_orm_spec.rb +48 -48
  123. data/spec/store_spec.rb +428 -426
  124. data/spec/support/shared_examples.rb +5 -7
  125. data/spec/sync_states_spec.rb +67 -67
  126. data/spec/test_methods_spec.rb +121 -123
  127. data/spec/testdata/10000-data.txt +0 -0
  128. data/spec/testdata/5000-data.txt +0 -0
  129. data/spec/user_spec.rb +102 -102
  130. data/tasks/redis.rake +3 -3
  131. metadata +154 -195
  132. data/bench/benchapp/tmp/pids/passenger.9292.pid.lock +0 -0
  133. data/bench/benchapp/tmp/restart.txt +0 -0
  134. data/bench/blobapp/settings/license.key.bak +0 -2
  135. data/bench/blobapp/tmp/restart.txt +0 -0
  136. data/bench/lib/testdata/1-data.txt +0 -0
  137. data/bench/lib/testdata/10-data.txt +0 -0
  138. data/bench/lib/testdata/2-data.txt +0 -0
  139. data/bench/lib/testdata/250-data.txt +0 -0
  140. data/bench/lib/testdata/5-blob_data.txt +0 -0
  141. data/bench/lib/testdata/5-data.txt +0 -0
  142. data/bench/lib/testdata/50-data.txt +0 -0
  143. data/bench/lib/testdata/500-data.txt +0 -0
  144. data/doc/protocol.html +0 -1993
  145. data/spec/coverage/rcov/assets/0.2.3/jquery-1.3.2.min.js +0 -19
  146. data/spec/coverage/rcov/assets/0.2.3/jquery.tablesorter.min.js +0 -15
  147. data/spec/coverage/rcov/assets/0.2.3/print.css +0 -12
  148. data/spec/coverage/rcov/assets/0.2.3/rcov.js +0 -42
  149. data/spec/coverage/rcov/assets/0.2.3/screen.css +0 -270
  150. data/spec/coverage/rcov/index.html +0 -88
  151. 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
- it_should_behave_like "ApiHelper" do
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
- it "should list app partition sources" do
11
- get "/rc/#{Rhoconnect::API_VERSION}/sources/type/app", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
12
- JSON.parse(last_response.body).sort.should == ["SimpleAdapter", "OtherAdapter"].sort
13
- end
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
- it "should list user partition sources" do
16
- get "/rc/#{Rhoconnect::API_VERSION}/sources/type/user", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
17
- JSON.parse(last_response.body).sort.should == ["SampleAdapter", "FixedSchemaAdapter", "JsSample"].sort
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
- it_should_behave_like "ApiHelper" do
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
- it "should fail to update the source if param is not found" do
18
- put "/rc/#{Rhoconnect::API_VERSION}/sources/#{@s_fields[:name]}",
19
- {:data => {:invalid_param => "invalid_data"}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
20
- last_response.status.should == 500
21
- last_response.body.match('undefined method').should_not be_nil
22
- end
23
- end
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
- 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
4
+ include_examples "ApiHelper"
22
5
 
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
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
- 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
4
+ include_examples "ApiHelper"
12
5
 
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
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
- 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
-
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
- it_should_behave_like "ApiHelper" do
5
- it "should get license info" do
6
- get "/rc/#{Rhoconnect::API_VERSION}/system/license", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
7
- JSON.parse(last_response.body).should == {
8
- "available" => 9,
9
- "issued" => "Fri Apr 23 17:20:13 -0700 2010",
10
- "seats" => 10,
11
- "rhoconnect_version" => "Version 1",
12
- "licensee" => "Rhomobile" }
13
- end
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
- it_should_behave_like "ApiHelper" do
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
- it "should return 422 if token doesn't belong to the API user" do
24
- invalid_api_token = ApiToken.create({:value => 'mytoken', :user_id => 'notadmin'})
25
- params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
26
- post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => invalid_api_token.value}
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
- it "should return 422 if no token provided" do
32
- params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
33
- post "/rc/#{Rhoconnect::API_VERSION}/users", params
34
- last_response.status.should == 422
35
- end
36
-
37
- it "response should have cache-control and pragma headers set to no-cache" do
38
- post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => 'rhoadmin',:password => ''
39
- last_response.headers['Cache-Control'].should == 'no-cache'
40
- last_response.headers['Pragma'].should == 'no-cache'
41
- end
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
- it_should_behave_like "ApiHelper" do
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
- it "should reset and re-create rhoadmin user with initializer" do
14
- Store.put_data('somedoc',{ '1' => {'foo'=>'bar'}})
15
- post "/rc/#{Rhoconnect::API_VERSION}/system/reset", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
16
- App.is_exist?(test_app_name).should == true
17
- Store.get_data('somedoc').should == {}
18
- User.authenticate('rhoadmin','').should_not be_nil
19
- end
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
- it_should_behave_like "ApiHelper" do
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
- 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
6
+ def app
7
+ @app ||= Rack::URLMap.new Rhoconnect.url_map
8
+ end
30
9
 
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
10
+ before(:each) do
11
+ Rhoconnect::Server.set :stats, true
12
+ Rhoconnect.stats = true
13
+ end
42
14
 
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
15
+ after(:each) do
16
+ Rhoconnect::Server.set :stats, false
17
+ Rhoconnect.stats = false
18
+ end
61
19
 
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
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
- 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
79
- end
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