rhoconnect 4.0.4 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,41 +1,41 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
2
2
|
|
3
3
|
describe "RhoconnectApiCreateUser" 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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
data/spec/api/user/ping_spec.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
2
2
|
|
3
3
|
describe "RhoconnectApiPing" do
|
4
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|