mongo 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d95f4cbddad1184a95d53cb257befaceb5b9d1b0
4
- data.tar.gz: 2639f1045f2be8059283b80bcd4e7a867b1ee35c
3
+ metadata.gz: efe6bb7e6b47adaa8d2552af028e6c77510659ec
4
+ data.tar.gz: fcf01b4299f65ab1b0604f7c6ad5be3f470774cf
5
5
  SHA512:
6
- metadata.gz: 806e70e8f37683ba17c3416a9eb4c6d662305c4b8138f62b9af82c234b3cd98c10d1cd3119040b2b5751208e2058cd57532b4dfd63acee6628da692e8af55bad
7
- data.tar.gz: e5a1c81c7930634054d5ace16c452ef4ba0c313a1fc779c2cc3deca75910b7014cae202b73cdd659d50f47d2e66f549fbd1e6017651815fec257b09db6ff4bd6
6
+ metadata.gz: 84f370d047ea3d27dd06940145be29bc2d6655b1b9676be732010a1d13d17f1fb5f86be35ba47e6a7b2c122dd2fadf02f0d4e37334f0f2446fa66da09d91e68e
7
+ data.tar.gz: 84902c053cf3394d8b821e4b6e4ada9906010f4221015e86a14ae1897d9c1be7c772c0848a19aabcc7446b1032e6e23f54475f96418dda607bead0143dc1e9fd
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require 'securerandom'
15
16
  require 'base64'
16
17
 
17
18
  module Mongo
@@ -24,7 +24,7 @@ module Mongo
24
24
  end
25
25
 
26
26
  def has_id?(doc)
27
- id(doc)
27
+ !!id(doc)
28
28
  end
29
29
 
30
30
  def ensure_ids(documents)
@@ -76,7 +76,7 @@ module Mongo
76
76
  # @since 2.0.0
77
77
  def log_message
78
78
  fields = []
79
- fields << ["%s |", "QUERY"]
79
+ fields << ["%s |", query_type]
80
80
  fields << ["namespace=%s", namespace]
81
81
  fields << ["selector=%s", selector.inspect]
82
82
  fields << ["flags=%s", flags.inspect]
@@ -107,6 +107,10 @@ module Mongo
107
107
  2004
108
108
  end
109
109
 
110
+ def query_type
111
+ namespace.include?(Database::COMMAND) ? 'COMMAND' : 'QUERY'
112
+ end
113
+
110
114
  # Available flags for a Query message.
111
115
  FLAGS = [
112
116
  :reserved,
@@ -103,10 +103,7 @@ module Mongo
103
103
  def initialize(family)
104
104
  @family = family
105
105
  @socket = ::Socket.new(family, SOCK_STREAM, 0)
106
- encoded_timeout = [ timeout, 0 ].pack(TIMEOUT_PACK)
107
- socket.set_encoding(BSON::BINARY)
108
- socket.setsockopt(SOL_SOCKET, SO_RCVTIMEO, encoded_timeout)
109
- socket.setsockopt(SOL_SOCKET, SO_SNDTIMEO, encoded_timeout)
106
+ set_socket_options(@socket)
110
107
  end
111
108
 
112
109
  # Will read all data from the socket for the provided number of bytes.
@@ -164,6 +161,13 @@ module Mongo
164
161
  socket.read(length) || String.new
165
162
  end
166
163
 
164
+ def set_socket_options(sock)
165
+ encoded_timeout = [ timeout, 0 ].pack(TIMEOUT_PACK)
166
+ sock.set_encoding(BSON::BINARY)
167
+ sock.setsockopt(SOL_SOCKET, SO_RCVTIMEO, encoded_timeout)
168
+ sock.setsockopt(SOL_SOCKET, SO_SNDTIMEO, encoded_timeout)
169
+ end
170
+
167
171
  def handle_errors
168
172
  begin
169
173
  yield
@@ -78,10 +78,7 @@ module Mongo
78
78
  @family = family
79
79
  @tcp_socket = ::Socket.new(family, SOCK_STREAM, 0)
80
80
  @tcp_socket.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
81
- encoded_timeout = [ timeout, 0 ].pack(TIMEOUT_PACK)
82
- @tcp_socket.set_encoding(BSON::BINARY)
83
- @tcp_socket.setsockopt(SOL_SOCKET, SO_RCVTIMEO, encoded_timeout)
84
- @tcp_socket.setsockopt(SOL_SOCKET, SO_SNDTIMEO, encoded_timeout)
81
+ set_socket_options(@tcp_socket)
85
82
  end
86
83
 
87
84
  # Read a single byte from the socket.
@@ -17,5 +17,5 @@ module Mongo
17
17
  # The current version of the driver.
18
18
  #
19
19
  # @since 2.0.0
20
- VERSION = '2.0.1'.freeze
20
+ VERSION = '2.0.2'.freeze
21
21
  end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mongo::Socket::SSL do
4
+
5
+ describe '#connect!', if: running_ssl? do
6
+
7
+ let(:socket) do
8
+ described_class.new('localhost', 27017, 5, Socket::PF_INET, options)
9
+ end
10
+
11
+ context 'when a certificate is provided' do
12
+
13
+ let(:options) do
14
+ {
15
+ :ssl => true,
16
+ :ssl_cert => CLIENT_PEM,
17
+ :ssl_key => CLIENT_PEM
18
+ }
19
+ end
20
+
21
+ before do
22
+ socket.connect!
23
+ end
24
+
25
+ it 'connects to the server' do
26
+ expect(socket).to be_alive
27
+ end
28
+ end
29
+
30
+ context 'when a bad certificate is provided' do
31
+
32
+ let(:options) do
33
+ {
34
+ :ssl => true,
35
+ :ssl_cert => CLIENT_PEM,
36
+ :ssl_key => CRL_PEM
37
+ }
38
+ end
39
+
40
+ it 'raises an exception' do
41
+ expect {
42
+ socket.connect!
43
+ }.to raise_error
44
+ end
45
+ end
46
+ end
47
+ end
@@ -69,6 +69,12 @@ SERVER_SELECTION_RTT_TESTS = Dir.glob("#{CURRENT_PATH}/support/server_selection/
69
69
  SERVER_SELECTION_TESTS = Dir.glob("#{CURRENT_PATH}/support/server_selection/selection/**/*.yml")
70
70
  CRUD_TESTS = Dir.glob("#{CURRENT_PATH}/support/crud_tests/**/*.yml")
71
71
 
72
+ SSL_CERTS_DIR = "#{CURRENT_PATH}/support/certificates"
73
+ CLIENT_PEM = "#{SSL_CERTS_DIR}/client.pem"
74
+ CLIENT_PASSWORD_PEM = "#{SSL_CERTS_DIR}/password_protected.pem"
75
+ CA_PEM = "#{SSL_CERTS_DIR}/ca.pem"
76
+ CRL_PEM = "#{SSL_CERTS_DIR}/crl.pem"
77
+
72
78
  # Determine whether the test clients are connecting to a standlone.
73
79
  #
74
80
  # @since 2.0.0
@@ -111,6 +117,10 @@ def list_command_enabled?
111
117
  $list_command_enabled ||= $mongo_client.cluster.servers.first.features.list_indexes_enabled?
112
118
  end
113
119
 
120
+ def running_ssl?
121
+ !!ENV['SSL']
122
+ end
123
+
114
124
  alias :scram_sha_1_enabled? :list_command_enabled?
115
125
 
116
126
  # Depending on whether write commands are enabled, there are different documents that
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -32,7 +32,7 @@ cert_chain:
32
32
  o2UXDbWtz5PqoFd8EgNJAn3+BG1pwC9S9pVFG3WPucfAx/bE8iq/vvchHei5Y/Vo
33
33
  aAz5f/hY4zFeYWvGDBHYEXE1rTN2hhMSyJscPcFbmz0=
34
34
  -----END CERTIFICATE-----
35
- date: 2015-03-26 00:00:00.000000000 Z
35
+ date: 2015-03-31 00:00:00.000000000 Z
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bson
@@ -237,12 +237,6 @@ files:
237
237
  - lib/mongo/write_concern/normalizable.rb
238
238
  - lib/mongo/write_concern/unacknowledged.rb
239
239
  - mongo.gemspec
240
- - spec/certificates/ca.pem
241
- - spec/certificates/client.pem
242
- - spec/certificates/crl.pem
243
- - spec/certificates/crl_client_revoked.pem
244
- - spec/certificates/password_protected.pem
245
- - spec/certificates/server.pem
246
240
  - spec/mongo/address/ipv4_spec.rb
247
241
  - spec/mongo/address/ipv6_spec.rb
248
242
  - spec/mongo/address/unix_spec.rb
@@ -334,11 +328,18 @@ files:
334
328
  - spec/mongo/server_selector/secondary_spec.rb
335
329
  - spec/mongo/server_selector_spec.rb
336
330
  - spec/mongo/server_spec.rb
331
+ - spec/mongo/socket/ssl_spec.rb
337
332
  - spec/mongo/uri_spec.rb
338
333
  - spec/mongo/write_concern/acknowledged_spec.rb
339
334
  - spec/mongo/write_concern/unacknowledged_spec.rb
340
335
  - spec/spec_helper.rb
341
336
  - spec/support/authorization.rb
337
+ - spec/support/certificates/ca.pem
338
+ - spec/support/certificates/client.pem
339
+ - spec/support/certificates/crl.pem
340
+ - spec/support/certificates/crl_client_revoked.pem
341
+ - spec/support/certificates/password_protected.pem
342
+ - spec/support/certificates/server.pem
342
343
  - spec/support/crud.rb
343
344
  - spec/support/crud/read.rb
344
345
  - spec/support/crud/write.rb
@@ -453,17 +454,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
453
454
  version: '0'
454
455
  requirements: []
455
456
  rubyforge_project: mongo
456
- rubygems_version: 2.2.2
457
+ rubygems_version: 2.4.6
457
458
  signing_key:
458
459
  specification_version: 4
459
460
  summary: Ruby driver for MongoDB
460
461
  test_files:
461
- - spec/certificates/ca.pem
462
- - spec/certificates/client.pem
463
- - spec/certificates/crl.pem
464
- - spec/certificates/crl_client_revoked.pem
465
- - spec/certificates/password_protected.pem
466
- - spec/certificates/server.pem
467
462
  - spec/mongo/address/ipv4_spec.rb
468
463
  - spec/mongo/address/ipv6_spec.rb
469
464
  - spec/mongo/address/unix_spec.rb
@@ -555,11 +550,18 @@ test_files:
555
550
  - spec/mongo/server_selector/secondary_spec.rb
556
551
  - spec/mongo/server_selector_spec.rb
557
552
  - spec/mongo/server_spec.rb
553
+ - spec/mongo/socket/ssl_spec.rb
558
554
  - spec/mongo/uri_spec.rb
559
555
  - spec/mongo/write_concern/acknowledged_spec.rb
560
556
  - spec/mongo/write_concern/unacknowledged_spec.rb
561
557
  - spec/spec_helper.rb
562
558
  - spec/support/authorization.rb
559
+ - spec/support/certificates/ca.pem
560
+ - spec/support/certificates/client.pem
561
+ - spec/support/certificates/crl.pem
562
+ - spec/support/certificates/crl_client_revoked.pem
563
+ - spec/support/certificates/password_protected.pem
564
+ - spec/support/certificates/server.pem
563
565
  - spec/support/crud/read.rb
564
566
  - spec/support/crud/write.rb
565
567
  - spec/support/crud.rb
metadata.gz.sig CHANGED
Binary file