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
data/spec/user_spec.rb
CHANGED
@@ -4,123 +4,123 @@ STATS_RECORD_RESOLUTION = 2 unless defined? STATS_RECORD_RESOLUTION
|
|
4
4
|
STATS_RECORD_SIZE = 8 unless defined? STATS_RECORD_SIZE
|
5
5
|
|
6
6
|
describe "User" do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => true
|
8
|
+
|
9
|
+
it "should not allow user created with reserved login" do
|
10
|
+
Store.get_value('user:count').should == "2"
|
11
|
+
lambda {
|
12
|
+
User.create({:login => '__shared__'})
|
13
|
+
}.should raise_error(ArgumentError, 'Reserved user id __shared__')
|
14
|
+
Store.get_value('user:count').should == "2"
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
it "should load user with fields" do
|
18
|
+
@u.id.should == @u_fields[:login]
|
19
|
+
@u1 = User.load(@u_fields[:login])
|
20
|
+
@u1.id.should == @u.id
|
21
|
+
@u1.login.should == @u_fields[:login]
|
22
|
+
@u1.email.should == @u_fields[:email]
|
23
|
+
Store.get_value('user:count').should == "2"
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
it "should delete seats for user's clients" do
|
27
|
+
@c_fields.delete(:id)
|
28
|
+
Client.create(@c_fields,{:source_name => @s_fields[:name]})
|
29
|
+
c_size = @u.clients.members.size
|
30
|
+
current = Store.get_value(License::CLIENT_DOCKEY).to_i
|
31
|
+
@u.delete
|
32
|
+
Store.get_value(License::CLIENT_DOCKEY).to_i.should == current - c_size
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
it "should create token for user" do
|
36
|
+
token = @u.create_token
|
37
|
+
token.length.should == 32
|
38
|
+
ApiToken.load(token).user_id.should == @u.id
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
it "should get token for user" do
|
42
|
+
token = @u.create_token
|
43
|
+
@u.token.value.length.should == 32
|
44
|
+
@u.token.value.should == token
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
it "should use token provisioned in settings if one" do
|
48
|
+
token = User.load('rhoadmin').token_id
|
49
|
+
token.should == Rhoconnect.api_token
|
50
|
+
ApiToken.is_exist?(token).should == true
|
51
|
+
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
it "should delete token if one exists" do
|
54
|
+
token = @u.create_token
|
55
|
+
ApiToken.is_exist?(token).should == true
|
56
|
+
token2 = @u.create_token
|
57
|
+
ApiToken.is_exist?(token).should == false
|
58
|
+
ApiToken.is_exist?(token2).should == true
|
59
|
+
end
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
it "should assign token to existing user" do
|
62
|
+
token = @u.create_token
|
63
|
+
@u.token = 'foo'
|
64
|
+
@u.token.value.should == 'foo'
|
65
|
+
ApiToken.is_exist?('foo').should == true
|
66
|
+
ApiToken.is_exist?(token).should == false
|
67
|
+
end
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
it "should authenticate with proper credentials" do
|
70
|
+
@u1 = User.authenticate(@u_fields[:login],'testpass')
|
71
|
+
@u1.should_not be_nil
|
72
|
+
@u1.login.should == @u_fields[:login]
|
73
|
+
@u1.email.should == @u_fields[:email]
|
74
|
+
end
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
it "should fail to authenticate with invalid credentials" do
|
77
|
+
User.authenticate(@u_fields[:login],'wrongpass').should be_nil
|
78
|
+
end
|
78
79
|
|
79
|
-
|
80
|
-
|
81
|
-
|
80
|
+
it "should fail to authenticate with nil user" do
|
81
|
+
User.authenticate('niluser','doesnotmatter').should be_nil
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should delete user and user clients" do
|
85
|
+
@c.put_data(:cd,@data)
|
86
|
+
cid = @c.id
|
87
|
+
@u.delete
|
88
|
+
Store.get_value('user:count').should == "1"
|
89
|
+
User.is_exist?(@u_fields[:login]).should == false
|
90
|
+
Client.is_exist?(cid).should == false
|
91
|
+
@c.get_data(:cd).should == {}
|
92
|
+
end
|
82
93
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
94
|
+
it "should delete token for user" do
|
95
|
+
token = @u.create_token
|
96
|
+
@u.delete
|
97
|
+
ApiToken.is_exist?(token).should == false
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "User Stats" do
|
101
|
+
|
102
|
+
before(:all) do
|
103
|
+
Store.stub(:lock).and_yield
|
91
104
|
end
|
92
105
|
|
93
|
-
it "should
|
94
|
-
|
95
|
-
|
96
|
-
|
106
|
+
it "should increment user stats on create" do
|
107
|
+
Time.stub(:now).and_return(10)
|
108
|
+
Rhoconnect.stats = true
|
109
|
+
User.create({:login => 'testuser2'})
|
110
|
+
Rhoconnect::Stats::Record.range('users',0,-1).should == ["3:10"]
|
111
|
+
Store.get_value('user:count').should == "3"
|
112
|
+
Rhoconnect.stats = false
|
97
113
|
end
|
98
114
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
User.create({:login => 'testuser2'})
|
109
|
-
Rhoconnect::Stats::Record.range('users',0,-1).should == ["3:10"]
|
110
|
-
Store.get_value('user:count').should == "3"
|
111
|
-
Rhoconnect.stats = false
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should decrement user stats on delete" do
|
115
|
-
Time.stub!(:now).and_return(10)
|
116
|
-
Rhoconnect.stats = true
|
117
|
-
u = User.create({:login => 'testuser1'})
|
118
|
-
Rhoconnect::Stats::Record.range('users',0,-1).should == ["3:10"]
|
119
|
-
u.delete
|
120
|
-
Rhoconnect::Stats::Record.range('users',0,-1).should == ["2:10"]
|
121
|
-
Store.get_value('user:count').should == "2"
|
122
|
-
Rhoconnect.stats = false
|
123
|
-
end
|
115
|
+
it "should decrement user stats on delete" do
|
116
|
+
Time.stub(:now).and_return(10)
|
117
|
+
Rhoconnect.stats = true
|
118
|
+
u = User.create({:login => 'testuser1'})
|
119
|
+
Rhoconnect::Stats::Record.range('users',0,-1).should == ["3:10"]
|
120
|
+
u.delete
|
121
|
+
Rhoconnect::Stats::Record.range('users',0,-1).should == ["2:10"]
|
122
|
+
Store.get_value('user:count').should == "2"
|
123
|
+
Rhoconnect.stats = false
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
data/tasks/redis.rake
CHANGED
@@ -4,7 +4,7 @@ require_relative '../commands/utilities/redis_runner'
|
|
4
4
|
include Utilities
|
5
5
|
include Rake::DSL
|
6
6
|
|
7
|
-
REDIS_RELEASE = "2.
|
7
|
+
REDIS_RELEASE = "2.8.17"
|
8
8
|
|
9
9
|
namespace :redis do
|
10
10
|
desc 'About redis'
|
@@ -40,7 +40,7 @@ namespace :redis do
|
|
40
40
|
|
41
41
|
desc 'Install the latest verison of Redis from Github (requires git, duh)'
|
42
42
|
task :install => [:about, :download, :make] do
|
43
|
-
|
43
|
+
unless windows?
|
44
44
|
ENV['PREFIX'] and bin_dir = "#{ENV['PREFIX']}/bin" or bin_dir = "#{RedisRunner.prefix}bin"
|
45
45
|
|
46
46
|
mk_bin_dir(bin_dir)
|
@@ -59,7 +59,7 @@ namespace :redis do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
task :make do
|
62
|
-
|
62
|
+
unless windows?
|
63
63
|
sh "cd #{RedisRunner.redisdir} && make clean"
|
64
64
|
sh "cd #{RedisRunner.redisdir} && make"
|
65
65
|
end
|