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,41 +1,41 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiCreateUser" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should create user" do
6
- params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
7
- post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
8
- last_response.should be_ok
9
- User.load(params[:attributes][:login]).login.should == params[:attributes][:login]
10
- User.authenticate(params[:attributes][:login],
11
- params[:attributes][:password]).login.should == params[:attributes][:login]
12
- @a.users.members.sort.should == [@u.login, params[:attributes][:login]]
13
- end
14
-
15
- it "should create user and post a deprecation warning with the old route" do
16
- params = {:api_token => @api_token,
17
- :attributes => {:login => 'testuser1', :password => 'testpass1'}}
18
- post "/api/create_user", params
19
- last_response.should be_ok
20
- last_response.headers["Warning"].index('deprecated').should_not == nil
21
- User.load(params[:attributes][:login]).login.should == params[:attributes][:login]
22
- User.authenticate(params[:attributes][:login],
23
- params[:attributes][:password]).login.should == params[:attributes][:login]
24
- @a.users.members.sort.should == [@u.login, params[:attributes][:login]]
25
- end
26
-
27
- it "should not create user without the api_token" do
28
- params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
29
- post "/rc/#{Rhoconnect::API_VERSION}/users", params, {}
30
- last_response.status.should == 422
31
- User.is_exist?('testuser1').should == false
32
- end
33
-
34
- it "should not create user with empty login" do
35
- params = {:attributes => {:login => '', :password => ''}}
36
- post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
37
- last_response.should_not be_ok
38
- User.is_exist?('').should == false
39
- end
40
- end
4
+ include_examples "ApiHelper"
5
+
6
+ it "should create user" do
7
+ params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
8
+ post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
+ last_response.should be_ok
10
+ User.load(params[:attributes][:login]).login.should == params[:attributes][:login]
11
+ User.authenticate(params[:attributes][:login],
12
+ params[:attributes][:password]).login.should == params[:attributes][:login]
13
+ @a.users.members.sort.should == [@u.login, params[:attributes][:login]]
14
+ end
15
+
16
+ it "should create user and post a deprecation warning with the old route" do
17
+ params = {:api_token => @api_token,
18
+ :attributes => {:login => 'testuser1', :password => 'testpass1'}}
19
+ post "/api/create_user", params
20
+ last_response.should be_ok
21
+ last_response.headers["Warning"].index('deprecated').should_not == nil
22
+ User.load(params[:attributes][:login]).login.should == params[:attributes][:login]
23
+ User.authenticate(params[:attributes][:login],
24
+ params[:attributes][:password]).login.should == params[:attributes][:login]
25
+ @a.users.members.sort.should == [@u.login, params[:attributes][:login]]
26
+ end
27
+
28
+ it "should not create user without the api_token" do
29
+ params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
30
+ post "/rc/#{Rhoconnect::API_VERSION}/users", params, {}
31
+ last_response.status.should == 422
32
+ User.is_exist?('testuser1').should == false
33
+ end
34
+
35
+ it "should not create user with empty login" do
36
+ params = {:attributes => {:login => '', :password => ''}}
37
+ post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
38
+ last_response.should_not be_ok
39
+ User.is_exist?('').should == false
40
+ end
41
41
  end
@@ -1,12 +1,12 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiDeleteClient" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should delete client for the user" do
6
- delete "/rc/#{Rhoconnect::API_VERSION}/users/#{@u_fields[:login]}/clients/#{@c.id}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
7
- last_response.should be_ok
8
- Client.is_exist?(@c.id).should == false
9
- User.load(@u_fields[:login]).clients.members.should == []
10
- end
4
+ include_examples "ApiHelper"
5
+
6
+ it "should delete client for the user" do
7
+ delete "/rc/#{Rhoconnect::API_VERSION}/users/#{@u_fields[:login]}/clients/#{@c.id}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
8
+ last_response.should be_ok
9
+ Client.is_exist?(@c.id).should == false
10
+ User.load(@u_fields[:login]).clients.members.should == []
11
11
  end
12
12
  end
@@ -1,67 +1,67 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiDeleteUser" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should delete user" do
6
- params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
7
- post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
8
- last_response.should be_ok
9
- User.is_exist?(params[:attributes][:login]).should == true
10
-
11
- #set up two users with data for the same source
12
- params2 = {:app_id => APP_NAME,:user_id => 'testuser1'}
13
- params3 = {:app_id => APP_NAME,:user_id => 'testuser'}
14
- time = Time.now.to_i
15
- s = Source.load('SampleAdapter', params2)
16
- s.read_state.refresh_time = time
17
- s2 = Source.load('SampleAdapter', params3)
18
- s2.read_state.refresh_time = time
19
- Source.define_valid_doctypes([:doc1])
20
- set_doc_state(s, :doc1 => {'4'=>@product4})
21
- set_doc_state(s2, :doc1 => {'4'=>@product4})
22
- verify_doc_result(s, :doc1 => {'4'=>@product4})
23
- verify_doc_result(s2, :doc1 => {'4'=>@product4})
24
-
25
- delete "/rc/#{Rhoconnect::API_VERSION}/users/#{params[:attributes][:login]}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
26
- last_response.should be_ok
27
- verify_doc_result(s, :doc1 => {})
28
- verify_doc_result(s2, :doc1 => {'4'=>@product4})
29
- s.load_read_state.should == nil
30
- s2.load_read_state.refresh_time.should == time
31
- User.is_exist?(params[:attributes][:login]).should == false
32
- App.load(test_app_name).users.members.should == ["testuser"]
33
- Source.valid_doctypes.delete(:doc1)
34
- end
35
-
36
- it "should delete user and print deprecation warning with the old route" do
37
- params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
38
- post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
39
- last_response.should be_ok
40
- User.is_exist?(params[:attributes][:login]).should == true
41
-
42
- #set up two users with data for the same source
43
- params2 = {:app_id => APP_NAME,:user_id => 'testuser1'}
44
- params3 = {:app_id => APP_NAME,:user_id => 'testuser'}
45
- time = Time.now.to_i
46
- s = Source.load('SampleAdapter', params2)
47
- s.read_state.refresh_time = time
48
- s2 = Source.load('SampleAdapter', params3)
49
- s2.read_state.refresh_time = time
50
- Source.define_valid_doctypes([:doc1])
51
- set_state(s.docname(:doc1) => {'4'=>@product4})
52
- set_state(s2.docname(:doc1) => {'4'=>@product4})
53
- verify_result(s.docname(:doc1) => {'4'=>@product4})
54
- verify_result(s2.docname(:doc1) => {'4'=>@product4})
55
- post "/api/delete_user", {:api_token => @api_token, :user_id => params[:attributes][:login]}
56
- last_response.should be_ok
57
- last_response.headers['Warning'].index('deprecated').should_not == nil
58
- verify_result(s.docname(:doc1) => {})
59
- verify_result(s2.docname(:doc1) => {'4'=>@product4})
60
- s.load_read_state.should == nil
61
- s2.load_read_state.refresh_time.should == time
62
- User.is_exist?(params[:attributes][:login]).should == false
63
- App.load(test_app_name).users.members.should == ["testuser"]
64
- Source.valid_doctypes.delete(:doc1)
65
- end
4
+ include_examples "ApiHelper"
5
+
6
+ it "should delete user" do
7
+ params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
8
+ post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
+ last_response.should be_ok
10
+ User.is_exist?(params[:attributes][:login]).should == true
11
+
12
+ #set up two users with data for the same source
13
+ params2 = {:app_id => APP_NAME,:user_id => 'testuser1'}
14
+ params3 = {:app_id => APP_NAME,:user_id => 'testuser'}
15
+ time = Time.now.to_i
16
+ s = Source.load('SampleAdapter', params2)
17
+ s.read_state.refresh_time = time
18
+ s2 = Source.load('SampleAdapter', params3)
19
+ s2.read_state.refresh_time = time
20
+ Source.define_valid_doctypes([:doc1])
21
+ set_doc_state(s, :doc1 => {'4'=>@product4})
22
+ set_doc_state(s2, :doc1 => {'4'=>@product4})
23
+ verify_doc_result(s, :doc1 => {'4'=>@product4})
24
+ verify_doc_result(s2, :doc1 => {'4'=>@product4})
25
+
26
+ delete "/rc/#{Rhoconnect::API_VERSION}/users/#{params[:attributes][:login]}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
27
+ last_response.should be_ok
28
+ verify_doc_result(s, :doc1 => {})
29
+ verify_doc_result(s2, :doc1 => {'4'=>@product4})
30
+ s.load_read_state.should == nil
31
+ s2.load_read_state.refresh_time.should == time
32
+ User.is_exist?(params[:attributes][:login]).should == false
33
+ App.load(test_app_name).users.members.should == ["testuser"]
34
+ Source.valid_doctypes.delete(:doc1)
35
+ end
36
+
37
+ it "should delete user and print deprecation warning with the old route" do
38
+ params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
39
+ post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
40
+ last_response.should be_ok
41
+ User.is_exist?(params[:attributes][:login]).should == true
42
+
43
+ #set up two users with data for the same source
44
+ params2 = {:app_id => APP_NAME,:user_id => 'testuser1'}
45
+ params3 = {:app_id => APP_NAME,:user_id => 'testuser'}
46
+ time = Time.now.to_i
47
+ s = Source.load('SampleAdapter', params2)
48
+ s.read_state.refresh_time = time
49
+ s2 = Source.load('SampleAdapter', params3)
50
+ s2.read_state.refresh_time = time
51
+ Source.define_valid_doctypes([:doc1])
52
+ set_state(s.docname(:doc1) => {'4'=>@product4})
53
+ set_state(s2.docname(:doc1) => {'4'=>@product4})
54
+ verify_result(s.docname(:doc1) => {'4'=>@product4})
55
+ verify_result(s2.docname(:doc1) => {'4'=>@product4})
56
+ post "/api/delete_user", {:api_token => @api_token, :user_id => params[:attributes][:login]}
57
+ last_response.should be_ok
58
+ last_response.headers['Warning'].index('deprecated').should_not == nil
59
+ verify_result(s.docname(:doc1) => {})
60
+ verify_result(s2.docname(:doc1) => {'4'=>@product4})
61
+ s.load_read_state.should == nil
62
+ s2.load_read_state.refresh_time.should == time
63
+ User.is_exist?(params[:attributes][:login]).should == false
64
+ App.load(test_app_name).users.members.should == ["testuser"]
65
+ Source.valid_doctypes.delete(:doc1)
66
66
  end
67
67
  end
@@ -1,30 +1,30 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiListUserClients" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should list user's clients" do
6
- get "/rc/#{Rhoconnect::API_VERSION}/users/#{@u_fields[:login]}/clients", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
7
- res = JSON.parse(last_response.body)
8
- res.is_a?(Array).should == true
9
- res.size.should == 1
10
- res[0].is_a?(String) == true
11
- res[0].length.should == 32
12
- end
13
-
14
- it "should list user's clients with old route and show deprecation warning" do
15
- post "/api/list_clients", {:api_token => @api_token,
16
- :user_id => @u_fields[:login]}
17
- res = JSON.parse(last_response.body)
18
- res.is_a?(Array).should == true
19
- res.size.should == 1
20
- res[0].is_a?(String) == true
21
- res[0].length.should == 32
22
- end
4
+ include_examples "ApiHelper"
23
5
 
24
- it "should handle empty client's list" do
25
- @u.clients.delete(@c.id)
26
- get "/rc/#{Rhoconnect::API_VERSION}/users/#{@u_fields[:login]}/clients", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
27
- JSON.parse(last_response.body).should == []
28
- end
6
+ it "should list user's clients" do
7
+ get "/rc/#{Rhoconnect::API_VERSION}/users/#{@u_fields[:login]}/clients", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
8
+ res = JSON.parse(last_response.body)
9
+ res.is_a?(Array).should == true
10
+ res.size.should == 1
11
+ res[0].is_a?(String) == true
12
+ res[0].length.should == 32
13
+ end
14
+
15
+ it "should list user's clients with old route and show deprecation warning" do
16
+ post "/api/list_clients", {:api_token => @api_token,
17
+ :user_id => @u_fields[:login]}
18
+ res = JSON.parse(last_response.body)
19
+ res.is_a?(Array).should == true
20
+ res.size.should == 1
21
+ res[0].is_a?(String) == true
22
+ res[0].length.should == 32
23
+ end
24
+
25
+ it "should handle empty client's list" do
26
+ @u.clients.delete(@c.id)
27
+ get "/rc/#{Rhoconnect::API_VERSION}/users/#{@u_fields[:login]}/clients", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
28
+ JSON.parse(last_response.body).should == []
29
29
  end
30
30
  end
@@ -1,35 +1,35 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiListSourceDocs" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should list of shared source documents" do
6
- sourcename = "SimpleAdapter"
7
- user_id = '*'
8
- get "/rc/#{Rhoconnect::API_VERSION}/users/#{user_id}/sources/#{sourcename}/docnames", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
- JSON.parse(last_response.body).should == {
10
- "md"=>"source:application:__shared__:SimpleAdapter:md",
11
- "errors"=>"source:application:__shared__:SimpleAdapter:errors",
12
- "md_size"=>"source:application:__shared__:SimpleAdapter:md_size",
13
- "md_copy"=>"source:application:__shared__:SimpleAdapter:md_copy"}
14
- end
15
-
16
- it "should list of shared source documents with old route and deprecation warning" do
17
- post "/api/list_source_docs", {:source_id => "SimpleAdapter", :user_id => '*'}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
18
- JSON.parse(last_response.body).should == {
19
- "md"=>"source:application:__shared__:SimpleAdapter:md",
20
- "errors"=>"source:application:__shared__:SimpleAdapter:errors",
21
- "md_size"=>"source:application:__shared__:SimpleAdapter:md_size",
22
- "md_copy"=>"source:application:__shared__:SimpleAdapter:md_copy"}
23
- end
4
+ include_examples "ApiHelper"
24
5
 
25
- it "should list user source documents" do
26
- sourcename = "SampleAdapter"
27
- get "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{sourcename}/docnames", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
28
- JSON.parse(last_response.body).should == {
29
- "md"=>"source:application:testuser:SampleAdapter:md",
30
- "errors"=>"source:application:testuser:SampleAdapter:errors",
31
- "md_size"=>"source:application:testuser:SampleAdapter:md_size",
32
- "md_copy"=>"source:application:testuser:SampleAdapter:md_copy"}
33
- end
6
+ it "should list of shared source documents" do
7
+ sourcename = "SimpleAdapter"
8
+ user_id = '*'
9
+ get "/rc/#{Rhoconnect::API_VERSION}/users/#{user_id}/sources/#{sourcename}/docnames", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
10
+ JSON.parse(last_response.body).should == {
11
+ "md"=>"source:application:__shared__:SimpleAdapter:md",
12
+ "errors"=>"source:application:__shared__:SimpleAdapter:errors",
13
+ "md_size"=>"source:application:__shared__:SimpleAdapter:md_size",
14
+ "md_copy"=>"source:application:__shared__:SimpleAdapter:md_copy"}
15
+ end
16
+
17
+ it "should list of shared source documents with old route and deprecation warning" do
18
+ post "/api/list_source_docs", {:source_id => "SimpleAdapter", :user_id => '*'}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
19
+ JSON.parse(last_response.body).should == {
20
+ "md"=>"source:application:__shared__:SimpleAdapter:md",
21
+ "errors"=>"source:application:__shared__:SimpleAdapter:errors",
22
+ "md_size"=>"source:application:__shared__:SimpleAdapter:md_size",
23
+ "md_copy"=>"source:application:__shared__:SimpleAdapter:md_copy"}
24
+ end
25
+
26
+ it "should list user source documents" do
27
+ sourcename = "SampleAdapter"
28
+ get "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{sourcename}/docnames", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
29
+ JSON.parse(last_response.body).should == {
30
+ "md"=>"source:application:testuser:SampleAdapter:md",
31
+ "errors"=>"source:application:testuser:SampleAdapter:errors",
32
+ "md_size"=>"source:application:testuser:SampleAdapter:md_size",
33
+ "md_copy"=>"source:application:testuser:SampleAdapter:md_copy"}
34
34
  end
35
35
  end
@@ -1,28 +1,28 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiListUsers" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should list users" do
6
- params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
7
- post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
8
- last_response.should be_ok
9
- get "/rc/#{Rhoconnect::API_VERSION}/users", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
10
- JSON.parse(last_response.body).sort.should == ["testuser", "testuser1"].sort
11
- end
4
+ include_examples "ApiHelper"
12
5
 
13
- it "should handle empty user's list" do
14
- @a.delete; @a = App.create(@a_fields)
15
- get "/rc/#{Rhoconnect::API_VERSION}/users", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
16
- JSON.parse(last_response.body).should == []
17
- end
18
-
19
- it "should show the deprecation warning on /api/list_users" do
20
- params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
21
- post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
22
- last_response.should be_ok
23
- post "/api/list_users", {:api_token => @api_token}
24
- JSON.parse(last_response.body).sort.should == ["testuser", "testuser1"].sort
25
- last_response.headers['Warning'].index('deprecated').should_not == nil
26
- end
6
+ it "should list users" do
7
+ params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
8
+ post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
+ last_response.should be_ok
10
+ get "/rc/#{Rhoconnect::API_VERSION}/users", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
11
+ JSON.parse(last_response.body).sort.should == ["testuser", "testuser1"].sort
12
+ end
13
+
14
+ it "should handle empty user's list" do
15
+ @a.delete; @a = App.create(@a_fields)
16
+ get "/rc/#{Rhoconnect::API_VERSION}/users", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
17
+ JSON.parse(last_response.body).should == []
18
+ end
19
+
20
+ it "should show the deprecation warning on /api/list_users" do
21
+ params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
22
+ post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
23
+ last_response.should be_ok
24
+ post "/api/list_users", {:api_token => @api_token}
25
+ JSON.parse(last_response.body).sort.should == ["testuser", "testuser1"].sort
26
+ last_response.headers['Warning'].index('deprecated').should_not == nil
27
27
  end
28
28
  end
@@ -1,24 +1,24 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiPing" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should do ping synchronously" do
6
- params = {"user_id" => @u.id, "sources" => [@s.name], "message" => 'hello world',
7
- "vibrate" => '5', "badge" => '5', "sound" => 'hello.mp3'}
8
- PingJob.should respond_to :perform
9
- PingJob.should_receive(:perform).once.with(params)
10
- post "/rc/#{Rhoconnect::API_VERSION}/users/ping", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
11
- last_response.should be_ok
12
- end
4
+ include_examples "ApiHelper"
13
5
 
14
- it "should do ping asynchronously" do
15
- params = {"user_id" => @u.id, "async" => "true","sources" => [@s.name], "message" => 'hello world',
16
- "vibrate" => '5', "badge" => '5', "sound" => 'hello.mp3'}
6
+ it "should do ping synchronously" do
7
+ params = {"user_id" => @u.id, "sources" => [@s.name], "message" => 'hello world',
8
+ "vibrate" => '5', "badge" => '5', "sound" => 'hello.mp3'}
9
+ PingJob.should respond_to :perform
10
+ PingJob.should_receive(:perform).once.with(params)
11
+ post "/rc/#{Rhoconnect::API_VERSION}/users/ping", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
12
+ last_response.should be_ok
13
+ end
17
14
 
18
- PingJob.should respond_to :enqueue
19
- PingJob.should_receive(:enqueue).once.with(params)
20
- post "/rc/#{Rhoconnect::API_VERSION}/users/ping", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
21
- last_response.should be_ok
22
- end
23
- end
15
+ it "should do ping asynchronously" do
16
+ params = {"user_id" => @u.id, "async" => "true","sources" => [@s.name], "message" => 'hello world',
17
+ "vibrate" => '5', "badge" => '5', "sound" => 'hello.mp3'}
18
+
19
+ PingJob.should respond_to :enqueue
20
+ PingJob.should_receive(:enqueue).once.with(params)
21
+ post "/rc/#{Rhoconnect::API_VERSION}/users/ping", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
22
+ last_response.should be_ok
23
+ end
24
24
  end
@@ -1,14 +1,14 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiShowUser" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should show user" do
6
- params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
7
- post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
8
- last_response.should be_ok
9
- get "/rc/#{Rhoconnect::API_VERSION}/users/#{params[:attributes][:login]}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
10
- last_response.should be_ok
11
- JSON.parse(last_response.body).should include({"name"=>"login", "value"=>"testuser1", "type"=>"string"})
12
- end
13
- end
4
+ include_examples "ApiHelper"
5
+
6
+ it "should show user" do
7
+ params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
8
+ post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
+ last_response.should be_ok
10
+ get "/rc/#{Rhoconnect::API_VERSION}/users/#{params[:attributes][:login]}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
11
+ last_response.should be_ok
12
+ JSON.parse(last_response.body).should include({"name"=>"login", "value"=>"testuser1", "type"=>"string"})
13
+ end
14
14
  end
@@ -1,50 +1,50 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiUpdateUser" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should update user successfully" do
6
- login = 'rhoadmin'
7
- put "/rc/#{Rhoconnect::API_VERSION}/users/#{login}", {:attributes => {:new_password => '123'}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
8
- last_response.should be_ok
9
- user = User.authenticate('rhoadmin','123')
10
- user.login.should == 'rhoadmin'
11
- user.admin.should == 1
12
- end
13
-
14
- it "should update user successfully with old route and print deprecation warning" do
15
- login = 'rhoadmin'
16
- post "/api/update_user", {:api_token => @api_token, :user_id => login,
17
- :attributes => {:new_password => '123'}}
18
- last_response.should be_ok
19
- user = User.authenticate('rhoadmin','123')
20
- user.login.should == 'rhoadmin'
21
- user.admin.should == 1
22
- end
4
+ include_examples "ApiHelper"
23
5
 
24
- it "should fail to update user with wrong attributes" do
25
- params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
26
- post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
27
- last_response.should be_ok
28
- User.is_exist?(params[:attributes][:login]).should == true
29
-
30
- put "/rc/#{Rhoconnect::API_VERSION}/users/#{params[:attributes][:login]}", {:attributes => {:missingattrib => '123'}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
31
- last_response.status.should == 500
32
- last_response.body.match('undefined method').should_not be_nil
33
- end
6
+ it "should update user successfully" do
7
+ login = 'rhoadmin'
8
+ put "/rc/#{Rhoconnect::API_VERSION}/users/#{login}", {:attributes => {:new_password => '123'}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
+ last_response.should be_ok
10
+ user = User.authenticate('rhoadmin','123')
11
+ user.login.should == 'rhoadmin'
12
+ user.admin.should == 1
13
+ end
14
+
15
+ it "should update user successfully with old route and print deprecation warning" do
16
+ login = 'rhoadmin'
17
+ post "/api/update_user", {:api_token => @api_token, :user_id => login,
18
+ :attributes => {:new_password => '123'}}
19
+ last_response.should be_ok
20
+ user = User.authenticate('rhoadmin','123')
21
+ user.login.should == 'rhoadmin'
22
+ user.admin.should == 1
23
+ end
24
+
25
+ it "should fail to update user with wrong attributes" do
26
+ params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
27
+ post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
28
+ last_response.should be_ok
29
+ User.is_exist?(params[:attributes][:login]).should == true
30
+
31
+ put "/rc/#{Rhoconnect::API_VERSION}/users/#{params[:attributes][:login]}", {:attributes => {:missingattrib => '123'}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
32
+ last_response.status.should == 500
33
+ last_response.body.match('undefined method').should_not be_nil
34
+ end
35
+
36
+ it "should not update login attribute for user" do
37
+ params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
38
+ post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
39
+ last_response.should be_ok
40
+ User.is_exist?(params[:attributes][:login]).should == true
34
41
 
35
- it "should not update login attribute for user" do
36
- params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
37
- post "/rc/#{Rhoconnect::API_VERSION}/users", params, {Rhoconnect::API_TOKEN_HEADER => @api_token}
38
- last_response.should be_ok
39
- User.is_exist?(params[:attributes][:login]).should == true
40
-
41
- put "/rc/#{Rhoconnect::API_VERSION}/users/#{params[:attributes][:login]}",
42
- {:attributes => {:new_password => '123', :login => 'someotheruser1'}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
43
- last_response.should be_ok
44
- user = User.authenticate('testuser1','123')
45
- user.login.should == 'testuser1'
46
- user.admin.should_not == 1
47
- User.is_exist?('someotheruser1').should == false
48
- end
42
+ put "/rc/#{Rhoconnect::API_VERSION}/users/#{params[:attributes][:login]}",
43
+ {:attributes => {:new_password => '123', :login => 'someotheruser1'}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
44
+ last_response.should be_ok
45
+ user = User.authenticate('testuser1','123')
46
+ user.login.should == 'testuser1'
47
+ user.admin.should_not == 1
48
+ User.is_exist?('someotheruser1').should == false
49
49
  end
50
50
  end
@@ -1,16 +1,16 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiUserGetDbDoc" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should get user's db document by doc key and data" do
6
- data = {'1' => {'foo' => 'bar'}}
7
- dockey = 'myuserdoc'
8
- post "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{@s2.name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
- last_response.should be_ok
10
-
11
- get "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{@s2.name}/docs/#{dockey}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
12
- last_response.should be_ok
13
- JSON.parse(last_response.body).should == data
14
- end
15
- end
4
+ include_examples "ApiHelper"
5
+
6
+ it "should get user's db document by doc key and data" do
7
+ data = {'1' => {'foo' => 'bar'}}
8
+ dockey = 'myuserdoc'
9
+ post "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{@s2.name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
10
+ last_response.should be_ok
11
+
12
+ get "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{@s2.name}/docs/#{dockey}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
13
+ last_response.should be_ok
14
+ JSON.parse(last_response.body).should == data
15
+ end
16
16
  end