mongo 1.9.2 → 1.10.0.rc0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/LICENSE +1 -1
- data/README.md +94 -334
- data/Rakefile +6 -4
- data/VERSION +1 -1
- data/bin/mongo_console +13 -6
- data/lib/mongo.rb +22 -27
- data/lib/mongo/bulk_write_collection_view.rb +352 -0
- data/lib/mongo/collection.rb +128 -188
- data/lib/mongo/collection_writer.rb +348 -0
- data/lib/mongo/connection.rb +19 -0
- data/lib/mongo/{util → connection}/node.rb +15 -1
- data/lib/mongo/{util → connection}/pool.rb +34 -19
- data/lib/mongo/{util → connection}/pool_manager.rb +8 -2
- data/lib/mongo/{util → connection}/sharding_pool_manager.rb +1 -1
- data/lib/mongo/connection/socket.rb +18 -0
- data/lib/mongo/{util → connection/socket}/socket_util.rb +5 -2
- data/lib/mongo/{util → connection/socket}/ssl_socket.rb +3 -4
- data/lib/mongo/{util → connection/socket}/tcp_socket.rb +25 -15
- data/lib/mongo/{util → connection/socket}/unix_socket.rb +6 -4
- data/lib/mongo/cursor.rb +113 -47
- data/lib/mongo/db.rb +203 -131
- data/lib/mongo/{exceptions.rb → exception.rb} +7 -1
- data/lib/mongo/functional.rb +19 -0
- data/lib/mongo/functional/authentication.rb +303 -0
- data/lib/mongo/{util → functional}/logging.rb +1 -1
- data/lib/mongo/{util → functional}/read_preference.rb +49 -1
- data/lib/mongo/{util → functional}/uri_parser.rb +81 -69
- data/lib/mongo/{util → functional}/write_concern.rb +2 -1
- data/{test/unit/pool_test.rb → lib/mongo/gridfs.rb} +5 -10
- data/lib/mongo/gridfs/grid.rb +1 -3
- data/lib/mongo/gridfs/grid_ext.rb +1 -1
- data/lib/mongo/gridfs/grid_file_system.rb +1 -1
- data/lib/mongo/gridfs/grid_io.rb +1 -1
- data/lib/mongo/legacy.rb +63 -8
- data/lib/mongo/mongo_client.rb +128 -154
- data/lib/mongo/mongo_replica_set_client.rb +17 -11
- data/lib/mongo/mongo_sharded_client.rb +2 -1
- data/lib/mongo/networking.rb +19 -10
- data/lib/mongo/utils.rb +19 -0
- data/lib/mongo/{util → utils}/conversions.rb +1 -1
- data/lib/mongo/{util → utils}/core_ext.rb +1 -1
- data/lib/mongo/{util → utils}/server_version.rb +1 -1
- data/lib/mongo/{util → utils}/support.rb +10 -57
- data/lib/mongo/{util → utils}/thread_local_variable_manager.rb +1 -1
- data/test/functional/authentication_test.rb +8 -21
- data/test/functional/bulk_write_collection_view_test.rb +782 -0
- data/test/functional/{connection_test.rb → client_test.rb} +153 -78
- data/test/functional/collection_test.rb +343 -97
- data/test/functional/collection_writer_test.rb +83 -0
- data/test/functional/conversions_test.rb +1 -3
- data/test/functional/cursor_fail_test.rb +3 -3
- data/test/functional/cursor_message_test.rb +3 -3
- data/test/functional/cursor_test.rb +38 -3
- data/test/functional/db_api_test.rb +5 -5
- data/test/functional/db_connection_test.rb +2 -2
- data/test/functional/db_test.rb +35 -11
- data/test/functional/grid_file_system_test.rb +2 -2
- data/test/functional/grid_io_test.rb +2 -2
- data/test/functional/grid_test.rb +2 -2
- data/test/functional/pool_test.rb +2 -3
- data/test/functional/safe_test.rb +5 -5
- data/test/functional/ssl_test.rb +22 -102
- data/test/functional/support_test.rb +1 -1
- data/test/functional/timeout_test.rb +6 -22
- data/test/functional/uri_test.rb +113 -12
- data/test/functional/write_concern_test.rb +6 -6
- data/test/helpers/general.rb +50 -0
- data/test/helpers/test_unit.rb +309 -0
- data/test/replica_set/authentication_test.rb +8 -23
- data/test/replica_set/basic_test.rb +41 -14
- data/test/replica_set/client_test.rb +179 -117
- data/test/replica_set/complex_connect_test.rb +6 -7
- data/test/replica_set/connection_test.rb +46 -38
- data/test/replica_set/count_test.rb +2 -2
- data/test/replica_set/cursor_test.rb +8 -8
- data/test/replica_set/insert_test.rb +64 -2
- data/test/replica_set/max_values_test.rb +59 -10
- data/test/replica_set/pinning_test.rb +2 -2
- data/test/replica_set/query_test.rb +2 -2
- data/test/replica_set/read_preference_test.rb +6 -6
- data/test/replica_set/refresh_test.rb +7 -7
- data/test/replica_set/replication_ack_test.rb +5 -5
- data/test/replica_set/ssl_test.rb +24 -106
- data/test/sharded_cluster/basic_test.rb +43 -15
- data/test/shared/authentication/basic_auth_shared.rb +215 -0
- data/test/shared/authentication/sasl_plain_shared.rb +96 -0
- data/test/shared/ssl_shared.rb +173 -0
- data/test/test_helper.rb +31 -199
- data/test/threading/basic_test.rb +29 -3
- data/test/tools/mongo_config.rb +45 -20
- data/test/tools/mongo_config_test.rb +1 -1
- data/test/unit/client_test.rb +136 -57
- data/test/unit/collection_test.rb +31 -55
- data/test/unit/connection_test.rb +135 -72
- data/test/unit/cursor_test.rb +2 -2
- data/test/unit/db_test.rb +19 -15
- data/test/unit/grid_test.rb +2 -2
- data/test/unit/mongo_sharded_client_test.rb +17 -15
- data/test/unit/node_test.rb +2 -2
- data/test/unit/pool_manager_test.rb +7 -5
- data/test/unit/read_pref_test.rb +82 -2
- data/test/unit/read_test.rb +14 -14
- data/test/unit/safe_test.rb +9 -9
- data/test/unit/sharding_pool_manager_test.rb +11 -5
- data/test/unit/write_concern_test.rb +9 -9
- metadata +71 -56
- metadata.gz.sig +0 -0
- data/test/functional/threading_test.rb +0 -109
- data/test/shared/authentication.rb +0 -121
- data/test/unit/util_test.rb +0 -69
@@ -1,121 +0,0 @@
|
|
1
|
-
# Copyright (C) 2013 10gen Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module AuthenticationTests
|
16
|
-
|
17
|
-
def init_auth
|
18
|
-
# enable authentication by creating and logging in as admin user
|
19
|
-
@admin = @client['admin']
|
20
|
-
@admin.add_user('admin', 'password')
|
21
|
-
@admin.authenticate('admin', 'password')
|
22
|
-
end
|
23
|
-
|
24
|
-
def teardown
|
25
|
-
@admin.logout
|
26
|
-
@admin.authenticate('admin','password')
|
27
|
-
@admin['system.users'].remove
|
28
|
-
@db['system.users'].remove
|
29
|
-
@db['test'].remove
|
30
|
-
@admin.logout
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_add_user
|
34
|
-
@db.add_user('bob','user')
|
35
|
-
assert @db['system.users'].find_one({:user => 'bob'})
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_remove_user
|
39
|
-
@db.remove_user('bob')
|
40
|
-
assert_nil @db['system.users'].find_one({:user => 'bob'})
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_remove_non_existent_user
|
44
|
-
assert_equal @db.remove_user('joe'), false
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_authenticate
|
48
|
-
@db.add_user('peggy', 'user')
|
49
|
-
assert @db.authenticate('peggy', 'user')
|
50
|
-
@db.remove_user('peggy')
|
51
|
-
@db.logout
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_authenticate_non_existent_user
|
55
|
-
assert_raise Mongo::AuthenticationError do
|
56
|
-
@db.authenticate('frank', 'thetank')
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_delegated_authentication
|
61
|
-
return if @client.server_version < '2.4'
|
62
|
-
|
63
|
-
# TODO: remove this line when slaves have this code:
|
64
|
-
# https://github.com/travis-ci/travis-cookbooks/pull/180
|
65
|
-
return if ENV['TRAVIS']
|
66
|
-
|
67
|
-
doc = {'_id' => 'test'}
|
68
|
-
# create accounts database to hold user credentials
|
69
|
-
accounts = @client['accounts']
|
70
|
-
accounts['system.users'].remove
|
71
|
-
accounts.add_user('tyler', 'brock', nil, :roles => [])
|
72
|
-
|
73
|
-
# insert test data and give user permissions on test db
|
74
|
-
@db['test'].remove
|
75
|
-
@db['test'].insert(doc)
|
76
|
-
@db.add_user('tyler', nil, nil, :roles => ['read'], :userSource => 'accounts')
|
77
|
-
@admin.logout
|
78
|
-
|
79
|
-
# auth must occur on the db where the user is defined
|
80
|
-
assert_raise Mongo::AuthenticationError do
|
81
|
-
@db.authenticate('tyler', 'brock')
|
82
|
-
end
|
83
|
-
|
84
|
-
# auth directly
|
85
|
-
assert accounts.authenticate('tyler', 'brock')
|
86
|
-
assert_equal doc, @db['test'].find_one
|
87
|
-
accounts.logout
|
88
|
-
assert_raise Mongo::OperationFailure do
|
89
|
-
@db['test'].find_one
|
90
|
-
end
|
91
|
-
|
92
|
-
# auth using source
|
93
|
-
@db.authenticate('tyler', 'brock', true, 'accounts')
|
94
|
-
assert_equal doc, @db['test'].find_one
|
95
|
-
@db.logout
|
96
|
-
assert_raise Mongo::OperationFailure do
|
97
|
-
@db['test'].find_one
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_logout
|
102
|
-
@db.add_user('peggy', 'user')
|
103
|
-
assert @db.authenticate('peggy', 'user')
|
104
|
-
assert @db.logout
|
105
|
-
@db.remove_user('peggy')
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_authenticate_with_special_characters
|
109
|
-
assert @db.add_user('foo:bar','@foo')
|
110
|
-
assert @db.authenticate('foo:bar','@foo')
|
111
|
-
@db.remove_user('foo:bar')
|
112
|
-
@db.logout
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_authenticate_read_only
|
116
|
-
@db.add_user('randy', 'readonly', true)
|
117
|
-
assert @db.authenticate('randy', 'readonly')
|
118
|
-
@db.remove_user('randy')
|
119
|
-
@db.logout
|
120
|
-
end
|
121
|
-
end
|
data/test/unit/util_test.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
# Copyright (C) 2013 10gen Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require File.expand_path("../../test_helper", __FILE__)
|
16
|
-
|
17
|
-
class UtilTest < Test::Unit::TestCase
|
18
|
-
context "Support" do
|
19
|
-
context ".secondary_ok?" do
|
20
|
-
should "return false for mapreduces with a string for out" do
|
21
|
-
assert_equal false, Mongo::Support.secondary_ok?(BSON::OrderedHash[
|
22
|
-
'mapreduce', 'test-collection',
|
23
|
-
'out', 'new-test-collection'
|
24
|
-
])
|
25
|
-
end
|
26
|
-
|
27
|
-
should "return false for mapreduces replacing a collection" do
|
28
|
-
assert_equal false, Mongo::Support.secondary_ok?(BSON::OrderedHash[
|
29
|
-
'mapreduce', 'test-collection',
|
30
|
-
'out', BSON::OrderedHash['replace', 'new-test-collection']
|
31
|
-
])
|
32
|
-
end
|
33
|
-
|
34
|
-
should "return false for mapreduces replacing the inline collection" do
|
35
|
-
assert_equal false, Mongo::Support.secondary_ok?(BSON::OrderedHash[
|
36
|
-
'mapreduce', 'test-collection',
|
37
|
-
'out', 'inline'
|
38
|
-
])
|
39
|
-
end
|
40
|
-
|
41
|
-
should "return true for inline output mapreduces when inline is a symbol" do
|
42
|
-
assert_equal true, Mongo::Support.secondary_ok?(BSON::OrderedHash[
|
43
|
-
'mapreduce', 'test-collection',
|
44
|
-
'out', BSON::OrderedHash[:inline, 'true']
|
45
|
-
])
|
46
|
-
end
|
47
|
-
|
48
|
-
should "return true for inline output mapreduces when inline is a string" do
|
49
|
-
assert_equal true, Mongo::Support.secondary_ok?(BSON::OrderedHash[
|
50
|
-
'mapreduce', 'test-collection',
|
51
|
-
'out', BSON::OrderedHash['inline', 'true']
|
52
|
-
])
|
53
|
-
end
|
54
|
-
|
55
|
-
should 'return true for count' do
|
56
|
-
assert_equal true, Mongo::Support.secondary_ok?(BSON::OrderedHash[
|
57
|
-
'count', 'test-collection',
|
58
|
-
'query', BSON::OrderedHash['a', 'b']
|
59
|
-
])
|
60
|
-
end
|
61
|
-
|
62
|
-
should 'return false for serverStatus' do
|
63
|
-
assert_equal false, Mongo::Support.secondary_ok?(BSON::OrderedHash[
|
64
|
-
'serverStatus', 1
|
65
|
-
])
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|