em-synchrony-moped 0.9.4 → 1.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
data/spec/moped_spec.rb DELETED
@@ -1,124 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require 'moped'
4
- require 'em-synchrony/moped'
5
-
6
- describe "em-synchrony/moped" do
7
-
8
- def new_node(options={})
9
- options.merge!(:timeout => 1)
10
- host = options.delete(:host) || 'localhost'
11
- Moped::Node.new("#{host}:#{FakeMongodHelper::BASE_PORT}", options)
12
- end
13
-
14
- context "without ssl" do
15
-
16
- it "should connect" do
17
- EventMachine.synchrony do
18
- start_mongod
19
-
20
- node = new_node
21
- node.refresh
22
- node.should be_primary
23
- EM.stop
24
- end
25
- end
26
-
27
-
28
- it "should raise a connection error on timeout" do
29
- lambda {
30
- EventMachine.synchrony do
31
- start_mongod
32
-
33
- # google.com seems timeout for my tests...
34
- node = new_node(:host => "google.com")
35
- node.refresh
36
-
37
- EM.stop
38
- end
39
- }.should raise_exception(Moped::Errors::ConnectionFailure, /ETIMEDOUT/)
40
- end
41
-
42
- it "should raise a connection error on connection refused" do
43
- lambda {
44
- EventMachine.synchrony do
45
- new_node.refresh
46
- EM.stop
47
- end
48
- }.should raise_exception(Moped::Errors::ConnectionFailure, /ECONNREFUSED/)
49
- end
50
- end
51
-
52
- context "without ssl" do
53
- it "should connect and not verify peer" do
54
- EventMachine.synchrony do
55
- start_mongod(
56
- :ssl => {
57
- :private_key_file => "#{SSL_DIR}/server.key",
58
- :cert_chain_file => "#{SSL_DIR}/server.crt",
59
- :verify_peer => false
60
- }
61
- )
62
-
63
- node = new_node(:ssl => {:verify_peer => false})
64
- node.refresh
65
- node.should be_primary
66
-
67
- EM.stop
68
- end
69
- end
70
-
71
- it "should connect and verify peer" do
72
- EventMachine.synchrony do
73
- start_mongod(
74
- :ssl => {
75
- :private_key_file => "#{SSL_DIR}/server.key",
76
- :cert_chain_file => "#{SSL_DIR}/server.crt",
77
- :verify_peer => false
78
- }
79
- )
80
-
81
- node = new_node(:ssl => {
82
- :verify_peer => true,
83
- :verify_cert => "#{SSL_DIR}/ca_cert.pem",
84
- :verify_host => "localhost"
85
- })
86
- node.refresh
87
- node.should be_primary
88
-
89
- EM.stop
90
- end
91
- end
92
-
93
-
94
- it "should connect and fail to verify peer" do
95
- lambda {
96
-
97
- EventMachine.synchrony do
98
- start_mongod(
99
- :ssl => {
100
- :private_key_file => "#{SSL_DIR}/untrusted.key",
101
- :cert_chain_file => "#{SSL_DIR}/untrusted.crt",
102
- :verify_peer => false
103
- }
104
- )
105
-
106
- node = new_node(:ssl => {
107
- :verify_peer => true,
108
- :verify_cert => "#{SSL_DIR}/ca_cert.pem",
109
- :verify_host => "localhost"
110
- })
111
-
112
- node.refresh
113
- node.should be_primary
114
-
115
- EM.stop
116
- end
117
- }.should raise_exception(Moped::Errors::ConnectionFailure, /Failed to verify SSL certificate of peer/)
118
- end
119
-
120
-
121
- end
122
-
123
-
124
- end