dalli 2.7.0 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of dalli might be problematic. Click here for more details.

@@ -1,128 +0,0 @@
1
- require 'helper'
2
-
3
- describe 'failover' do
4
-
5
- describe 'timeouts' do
6
- it 'not lead to corrupt sockets' do
7
- memcached(29125) do
8
- dc = Dalli::Client.new ['localhost:29125']
9
- begin
10
- Timeout.timeout 0.01 do
11
- 1_000.times do
12
- dc.set("test_123", {:test => "123"})
13
- end
14
- flunk("Did not timeout")
15
- end
16
- rescue Timeout::Error
17
- end
18
-
19
- assert_equal({:test => '123'}, dc.get("test_123"))
20
- end
21
- end
22
- end
23
-
24
-
25
- describe 'assuming some bad servers' do
26
-
27
- it 'silently reconnect if server hiccups' do
28
- memcached(29125) do
29
- dc = Dalli::Client.new ['localhost:29125']
30
- dc.set 'foo', 'bar'
31
- foo = dc.get 'foo'
32
- assert_equal foo, 'bar'
33
-
34
- memcached_kill(29125)
35
- memcached(29125) do
36
-
37
- foo = dc.get 'foo'
38
- assert_nil foo
39
-
40
- memcached_kill(29125)
41
- end
42
- end
43
- end
44
-
45
- it 'handle graceful failover' do
46
- memcached(29125) do
47
- memcached(29126) do
48
- dc = Dalli::Client.new ['localhost:29125', 'localhost:29126']
49
- dc.set 'foo', 'bar'
50
- foo = dc.get 'foo'
51
- assert_equal foo, 'bar'
52
-
53
- memcached_kill(29125)
54
-
55
- dc.set 'foo', 'bar'
56
- foo = dc.get 'foo'
57
- assert_equal foo, 'bar'
58
-
59
- memcached_kill(29126)
60
-
61
- assert_raises Dalli::RingError, :message => "No server available" do
62
- dc.set 'foo', 'bar'
63
- end
64
- end
65
- end
66
- end
67
-
68
- it 'handle them gracefully in get_multi' do
69
- memcached(29125) do
70
- memcached(29126) do
71
- dc = Dalli::Client.new ['localhost:29125', 'localhost:29126']
72
- dc.set 'a', 'a1'
73
- result = dc.get_multi ['a']
74
- assert_equal result, {'a' => 'a1'}
75
-
76
- memcached_kill(29125)
77
-
78
- result = dc.get_multi ['a']
79
- assert_equal result, {'a' => 'a1'}
80
- end
81
- end
82
- end
83
-
84
- it 'handle graceful failover in get_multi' do
85
- memcached(29125) do
86
- memcached(29126) do
87
- dc = Dalli::Client.new ['localhost:29125', 'localhost:29126']
88
- dc.set 'foo', 'foo1'
89
- dc.set 'bar', 'bar1'
90
- result = dc.get_multi ['foo', 'bar']
91
- assert_equal result, {'foo' => 'foo1', 'bar' => 'bar1'}
92
-
93
- memcached_kill(29125)
94
-
95
- dc.set 'foo', 'foo1'
96
- dc.set 'bar', 'bar1'
97
- result = dc.get_multi ['foo', 'bar']
98
- assert_equal result, {'foo' => 'foo1', 'bar' => 'bar1'}
99
-
100
- memcached_kill(29126)
101
-
102
- result = dc.get_multi ['foo', 'bar']
103
- assert_equal result, {}
104
- end
105
- end
106
- end
107
-
108
- it 'stats it still properly report' do
109
- memcached(29125) do
110
- memcached(29126) do
111
- dc = Dalli::Client.new ['localhost:29125', 'localhost:29126']
112
- result = dc.stats
113
- assert_instance_of Hash, result['localhost:29125']
114
- assert_instance_of Hash, result['localhost:29126']
115
-
116
- memcached_kill(29125)
117
-
118
- dc = Dalli::Client.new ['localhost:29125', 'localhost:29126']
119
- result = dc.stats
120
- assert_instance_of NilClass, result['localhost:29125']
121
- assert_instance_of Hash, result['localhost:29126']
122
-
123
- memcached_kill(29126)
124
- end
125
- end
126
- end
127
- end
128
- end
data/test/test_network.rb DELETED
@@ -1,54 +0,0 @@
1
- require 'helper'
2
-
3
- describe 'Network' do
4
-
5
- describe 'assuming a bad network' do
6
-
7
- it 'handle no server available' do
8
- assert_raises Dalli::RingError, :message => "No server available" do
9
- dc = Dalli::Client.new 'localhost:19333'
10
- dc.get 'foo'
11
- end
12
- end
13
-
14
- describe 'with a fake server' do
15
- it 'handle connection reset' do
16
- memcached_mock(lambda {|sock| sock.close }) do
17
- assert_raises Dalli::RingError, :message => "No server available" do
18
- dc = Dalli::Client.new('localhost:19123')
19
- dc.get('abc')
20
- end
21
- end
22
- end
23
-
24
- it 'handle malformed response' do
25
- memcached_mock(lambda {|sock| sock.write('123') }) do
26
- assert_raises Dalli::RingError, :message => "No server available" do
27
- dc = Dalli::Client.new('localhost:19123')
28
- dc.get('abc')
29
- end
30
- end
31
- end
32
-
33
- it 'handle connect timeouts' do
34
- memcached_mock(lambda {|sock| sleep(0.6); sock.close }, :delayed_start) do
35
- assert_raises Dalli::RingError, :message => "No server available" do
36
- dc = Dalli::Client.new('localhost:19123')
37
- dc.get('abc')
38
- end
39
- end
40
- end
41
-
42
- it 'handle read timeouts' do
43
- memcached_mock(lambda {|sock| sleep(0.6); sock.write('giraffe') }) do
44
- assert_raises Dalli::RingError, :message => "No server available" do
45
- dc = Dalli::Client.new('localhost:19123')
46
- dc.get('abc')
47
- end
48
- end
49
- end
50
-
51
- end
52
-
53
- end
54
- end
@@ -1,321 +0,0 @@
1
- require 'helper'
2
-
3
- require 'rack/session/dalli'
4
- require 'rack/lint'
5
- require 'rack/mock'
6
- require 'thread'
7
-
8
- describe Rack::Session::Dalli do
9
- Rack::Session::Dalli::DEFAULT_OPTIONS[:memcache_server] = 'localhost:19129'
10
-
11
- before do
12
- memcached(19129) do
13
- end
14
- end
15
-
16
- session_key = Rack::Session::Dalli::DEFAULT_OPTIONS[:key]
17
- session_match = /#{session_key}=([0-9a-fA-F]+);/
18
- incrementor = lambda do |env|
19
- env["rack.session"]["counter"] ||= 0
20
- env["rack.session"]["counter"] += 1
21
- Rack::Response.new(env["rack.session"].inspect).to_a
22
- end
23
- drop_session = Rack::Lint.new(proc do |env|
24
- env['rack.session.options'][:drop] = true
25
- incrementor.call(env)
26
- end)
27
- renew_session = Rack::Lint.new(proc do |env|
28
- env['rack.session.options'][:renew] = true
29
- incrementor.call(env)
30
- end)
31
- defer_session = Rack::Lint.new(proc do |env|
32
- env['rack.session.options'][:defer] = true
33
- incrementor.call(env)
34
- end)
35
- skip_session = Rack::Lint.new(proc do |env|
36
- env['rack.session.options'][:skip] = true
37
- incrementor.call(env)
38
- end)
39
- incrementor = Rack::Lint.new(incrementor)
40
-
41
- # test memcache connection
42
- Rack::Session::Dalli.new(incrementor)
43
-
44
- it "faults on no connection" do
45
- assert_raises Dalli::RingError do
46
- rsd = Rack::Session::Dalli.new(incrementor, :memcache_server => 'nosuchserver')
47
- rsd.pool.set('ping', '')
48
- end
49
- end
50
-
51
- it "connects to existing server" do
52
- assert_silent do
53
- rsd = Rack::Session::Dalli.new(incrementor, :namespace => 'test:rack:session')
54
- rsd.pool.set('ping', '')
55
- end
56
- end
57
-
58
- it "passes options to MemCache" do
59
- rsd = Rack::Session::Dalli.new(incrementor, :namespace => 'test:rack:session')
60
- assert_equal('test:rack:session', rsd.pool.instance_eval { @options[:namespace] })
61
- end
62
-
63
- it "creates a new cookie" do
64
- rsd = Rack::Session::Dalli.new(incrementor)
65
- res = Rack::MockRequest.new(rsd).get("/")
66
- assert res["Set-Cookie"].include?("#{session_key}=")
67
- assert_equal '{"counter"=>1}', res.body
68
- end
69
-
70
- it "determines session from a cookie" do
71
- rsd = Rack::Session::Dalli.new(incrementor)
72
- req = Rack::MockRequest.new(rsd)
73
- res = req.get("/")
74
- cookie = res["Set-Cookie"]
75
- assert_equal '{"counter"=>2}', req.get("/", "HTTP_COOKIE" => cookie).body
76
- assert_equal '{"counter"=>3}', req.get("/", "HTTP_COOKIE" => cookie).body
77
- end
78
-
79
- it "determines session only from a cookie by default" do
80
- rsd = Rack::Session::Dalli.new(incrementor)
81
- req = Rack::MockRequest.new(rsd)
82
- res = req.get("/")
83
- sid = res["Set-Cookie"][session_match, 1]
84
- assert_equal '{"counter"=>1}', req.get("/?rack.session=#{sid}").body
85
- assert_equal '{"counter"=>1}', req.get("/?rack.session=#{sid}").body
86
- end
87
-
88
- it "determines session from params" do
89
- rsd = Rack::Session::Dalli.new(incrementor, :cookie_only => false)
90
- req = Rack::MockRequest.new(rsd)
91
- res = req.get("/")
92
- sid = res["Set-Cookie"][session_match, 1]
93
- assert_equal '{"counter"=>2}', req.get("/?rack.session=#{sid}").body
94
- assert_equal '{"counter"=>3}', req.get("/?rack.session=#{sid}").body
95
- end
96
-
97
- it "survives nonexistant cookies" do
98
- bad_cookie = "rack.session=blarghfasel"
99
- rsd = Rack::Session::Dalli.new(incrementor)
100
- res = Rack::MockRequest.new(rsd).
101
- get("/", "HTTP_COOKIE" => bad_cookie)
102
- assert_equal '{"counter"=>1}', res.body
103
- cookie = res["Set-Cookie"][session_match]
104
- refute_match(/#{bad_cookie}/, cookie)
105
- end
106
-
107
- it "maintains freshness" do
108
- rsd = Rack::Session::Dalli.new(incrementor, :expire_after => 3)
109
- res = Rack::MockRequest.new(rsd).get('/')
110
- assert res.body.include?('"counter"=>1')
111
- cookie = res["Set-Cookie"]
112
- res = Rack::MockRequest.new(rsd).get('/', "HTTP_COOKIE" => cookie)
113
- assert_equal cookie, res["Set-Cookie"]
114
- assert res.body.include?('"counter"=>2')
115
- puts 'Sleeping to expire session' if $DEBUG
116
- sleep 4
117
- res = Rack::MockRequest.new(rsd).get('/', "HTTP_COOKIE" => cookie)
118
- refute_equal cookie, res["Set-Cookie"]
119
- assert res.body.include?('"counter"=>1')
120
- end
121
-
122
- it "does not send the same session id if it did not change" do
123
- rsd = Rack::Session::Dalli.new(incrementor)
124
- req = Rack::MockRequest.new(rsd)
125
-
126
- res0 = req.get("/")
127
- cookie = res0["Set-Cookie"][session_match]
128
- assert_equal '{"counter"=>1}', res0.body
129
-
130
- res1 = req.get("/", "HTTP_COOKIE" => cookie)
131
- assert_nil res1["Set-Cookie"]
132
- assert_equal '{"counter"=>2}', res1.body
133
-
134
- res2 = req.get("/", "HTTP_COOKIE" => cookie)
135
- assert_nil res2["Set-Cookie"]
136
- assert_equal '{"counter"=>3}', res2.body
137
- end
138
-
139
- it "deletes cookies with :drop option" do
140
- rsd = Rack::Session::Dalli.new(incrementor)
141
- req = Rack::MockRequest.new(rsd)
142
- drop = Rack::Utils::Context.new(rsd, drop_session)
143
- dreq = Rack::MockRequest.new(drop)
144
-
145
- res1 = req.get("/")
146
- session = (cookie = res1["Set-Cookie"])[session_match]
147
- assert_equal '{"counter"=>1}', res1.body
148
-
149
- res2 = dreq.get("/", "HTTP_COOKIE" => cookie)
150
- assert_nil res2["Set-Cookie"]
151
- assert_equal '{"counter"=>2}', res2.body
152
-
153
- res3 = req.get("/", "HTTP_COOKIE" => cookie)
154
- refute_equal session, res3["Set-Cookie"][session_match]
155
- assert_equal '{"counter"=>1}', res3.body
156
- end
157
-
158
- it "provides new session id with :renew option" do
159
- rsd = Rack::Session::Dalli.new(incrementor)
160
- req = Rack::MockRequest.new(rsd)
161
- renew = Rack::Utils::Context.new(rsd, renew_session)
162
- rreq = Rack::MockRequest.new(renew)
163
-
164
- res1 = req.get("/")
165
- session = (cookie = res1["Set-Cookie"])[session_match]
166
- assert_equal '{"counter"=>1}', res1.body
167
-
168
- res2 = rreq.get("/", "HTTP_COOKIE" => cookie)
169
- new_cookie = res2["Set-Cookie"]
170
- new_session = new_cookie[session_match]
171
- refute_equal session, new_session
172
- assert_equal '{"counter"=>2}', res2.body
173
-
174
- res3 = req.get("/", "HTTP_COOKIE" => new_cookie)
175
- assert_equal '{"counter"=>3}', res3.body
176
-
177
- # Old cookie was deleted
178
- res4 = req.get("/", "HTTP_COOKIE" => cookie)
179
- assert_equal '{"counter"=>1}', res4.body
180
- end
181
-
182
- it "omits cookie with :defer option but still updates the state" do
183
- rsd = Rack::Session::Dalli.new(incrementor)
184
- count = Rack::Utils::Context.new(rsd, incrementor)
185
- defer = Rack::Utils::Context.new(rsd, defer_session)
186
- dreq = Rack::MockRequest.new(defer)
187
- creq = Rack::MockRequest.new(count)
188
-
189
- res0 = dreq.get("/")
190
- assert_nil res0["Set-Cookie"]
191
- assert_equal '{"counter"=>1}', res0.body
192
-
193
- res0 = creq.get("/")
194
- res1 = dreq.get("/", "HTTP_COOKIE" => res0["Set-Cookie"])
195
- assert_equal '{"counter"=>2}', res1.body
196
- res2 = dreq.get("/", "HTTP_COOKIE" => res0["Set-Cookie"])
197
- assert_equal '{"counter"=>3}', res2.body
198
- end
199
-
200
- it "omits cookie and state update with :skip option" do
201
- rsd = Rack::Session::Dalli.new(incrementor)
202
- count = Rack::Utils::Context.new(rsd, incrementor)
203
- skip = Rack::Utils::Context.new(rsd, skip_session)
204
- sreq = Rack::MockRequest.new(skip)
205
- creq = Rack::MockRequest.new(count)
206
-
207
- res0 = sreq.get("/")
208
- assert_nil res0["Set-Cookie"]
209
- assert_equal '{"counter"=>1}', res0.body
210
-
211
- res0 = creq.get("/")
212
- res1 = sreq.get("/", "HTTP_COOKIE" => res0["Set-Cookie"])
213
- assert_equal '{"counter"=>2}', res1.body
214
- res2 = sreq.get("/", "HTTP_COOKIE" => res0["Set-Cookie"])
215
- assert_equal '{"counter"=>2}', res2.body
216
- end
217
-
218
- it "updates deep hashes correctly" do
219
- hash_check = proc do |env|
220
- session = env['rack.session']
221
- unless session.include? 'test'
222
- session.update :a => :b, :c => { :d => :e },
223
- :f => { :g => { :h => :i} }, 'test' => true
224
- else
225
- session[:f][:g][:h] = :j
226
- end
227
- [200, {}, [session.inspect]]
228
- end
229
- rsd = Rack::Session::Dalli.new(hash_check)
230
- req = Rack::MockRequest.new(rsd)
231
-
232
- res0 = req.get("/")
233
- session_id = (cookie = res0["Set-Cookie"])[session_match, 1]
234
- ses0 = rsd.pool.get(session_id, true)
235
-
236
- req.get("/", "HTTP_COOKIE" => cookie)
237
- ses1 = rsd.pool.get(session_id, true)
238
-
239
- refute_equal ses0, ses1
240
- end
241
-
242
- # anyone know how to do this better?
243
- it "cleanly merges sessions when multithreaded" do
244
- unless $DEBUG
245
- assert_equal 1, 1 # fake assertion to appease the mighty bacon
246
- next
247
- end
248
- warn 'Running multithread test for Session::Dalli'
249
- rsd = Rack::Session::Dalli.new(incrementor)
250
- req = Rack::MockRequest.new(rsd)
251
-
252
- res = req.get('/')
253
- assert_equal '{"counter"=>1}', res.body
254
- cookie = res["Set-Cookie"]
255
- session_id = cookie[session_match, 1]
256
-
257
- delta_incrementor = lambda do |env|
258
- # emulate disconjoinment of threading
259
- env['rack.session'] = env['rack.session'].dup
260
- Thread.stop
261
- env['rack.session'][(Time.now.usec*rand).to_i] = true
262
- incrementor.call(env)
263
- end
264
- tses = Rack::Utils::Context.new rsd, delta_incrementor
265
- treq = Rack::MockRequest.new(tses)
266
- tnum = rand(7).to_i+5
267
- r = Array.new(tnum) do
268
- Thread.new(treq) do |run|
269
- run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true)
270
- end
271
- end.reverse.map{|t| t.run.join.value }
272
- r.each do |request|
273
- assert_equal cookie, request['Set-Cookie']
274
- assert request.body.include?('"counter"=>2')
275
- end
276
-
277
- session = rsd.pool.get(session_id)
278
- assert_equal tnum+1, session.size # counter
279
- assert_equal 2, session['counter'] # meeeh
280
-
281
- tnum = rand(7).to_i+5
282
- r = Array.new(tnum) do |i|
283
- app = Rack::Utils::Context.new rsd, time_delta
284
- req = Rack::MockRequest.new app
285
- Thread.new(req) do |run|
286
- run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true)
287
- end
288
- end.reverse.map{|t| t.run.join.value }
289
- r.each do |request|
290
- assert_equal cookie, request['Set-Cookie']
291
- assert request.body.include?('"counter"=>3')
292
- end
293
-
294
- session = rsd.pool.get(session_id)
295
- assert_equal tnum+1, session.size
296
- assert_equal 3, session['counter']
297
-
298
- drop_counter = proc do |env|
299
- env['rack.session'].delete 'counter'
300
- env['rack.session']['foo'] = 'bar'
301
- [200, {'Content-Type'=>'text/plain'}, env['rack.session'].inspect]
302
- end
303
- tses = Rack::Utils::Context.new rsd, drop_counter
304
- treq = Rack::MockRequest.new(tses)
305
- tnum = rand(7).to_i+5
306
- r = Array.new(tnum) do
307
- Thread.new(treq) do |run|
308
- run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true)
309
- end
310
- end.reverse.map{|t| t.run.join.value }
311
- r.each do |request|
312
- assert_equal cookie, request['Set-Cookie']
313
- assert request.body.include?('"foo"=>"bar"')
314
- end
315
-
316
- session = rsd.pool.get(session_id)
317
- assert_equal r.size+1, session.size
318
- assert_nil session['counter']
319
- assert_equal 'bar', session['foo']
320
- end
321
- end
data/test/test_ring.rb DELETED
@@ -1,85 +0,0 @@
1
- require 'helper'
2
-
3
- describe 'Ring' do
4
-
5
- describe 'a ring of servers' do
6
-
7
- it "have the continuum sorted by value" do
8
- servers = [stub(:hostname => "localhost", :port => "11211", :weight => 1),
9
- stub(:hostname => "localhost", :port => "9500", :weight => 1)]
10
- ring = Dalli::Ring.new(servers, {})
11
- previous_value = 0
12
- ring.continuum.each do |entry|
13
- assert entry.value > previous_value
14
- previous_value = entry.value
15
- end
16
- end
17
-
18
- it 'raise when no servers are available/defined' do
19
- ring = Dalli::Ring.new([], {})
20
- assert_raises Dalli::RingError, :message => "No server available" do
21
- ring.server_for_key('test')
22
- end
23
- end
24
-
25
- describe 'containing only a single server' do
26
- it "raise correctly when it's not alive" do
27
- servers = [
28
- Dalli::Server.new("localhost:12345"),
29
- ]
30
- ring = Dalli::Ring.new(servers, {})
31
- assert_raises Dalli::RingError, :message => "No server available" do
32
- ring.server_for_key('test')
33
- end
34
- end
35
-
36
- it "return the server when it's alive" do
37
- servers = [
38
- Dalli::Server.new("localhost:19191"),
39
- ]
40
- ring = Dalli::Ring.new(servers, {})
41
- memcached(19191) do |mc|
42
- ring = mc.send(:ring)
43
- assert_equal ring.servers.first.port, ring.server_for_key('test').port
44
- end
45
- end
46
- end
47
-
48
- describe 'containing multiple servers' do
49
- it "raise correctly when no server is alive" do
50
- servers = [
51
- Dalli::Server.new("localhost:12345"),
52
- Dalli::Server.new("localhost:12346"),
53
- ]
54
- ring = Dalli::Ring.new(servers, {})
55
- assert_raises Dalli::RingError, :message => "No server available" do
56
- ring.server_for_key('test')
57
- end
58
- end
59
-
60
- it "return an alive server when at least one is alive" do
61
- servers = [
62
- Dalli::Server.new("localhost:12346"),
63
- Dalli::Server.new("localhost:19191"),
64
- ]
65
- ring = Dalli::Ring.new(servers, {})
66
- memcached(19191) do |mc|
67
- ring = mc.send(:ring)
68
- assert_equal ring.servers.first.port, ring.server_for_key('test').port
69
- end
70
- end
71
- end
72
-
73
- it 'detect when a dead server is up again' do
74
- memcached(19997) do
75
- down_retry_delay = 0.5
76
- dc = Dalli::Client.new(['localhost:19997', 'localhost:19998'], :down_retry_delay => down_retry_delay)
77
- assert_equal 1, dc.stats.values.compact.count
78
-
79
- memcached(19998) do
80
- assert_equal 2, dc.stats.values.compact.count
81
- end
82
- end
83
- end
84
- end
85
- end
data/test/test_sasl.rb DELETED
@@ -1,110 +0,0 @@
1
- require 'helper'
2
-
3
- describe 'Sasl' do
4
-
5
- # https://github.com/seattlerb/minitest/issues/298
6
- def self.xit(msg, &block)
7
- end
8
-
9
- describe 'a server requiring authentication' do
10
- before do
11
- @server = mock()
12
- @server.stubs(:request).returns(true)
13
- @server.stubs(:weight).returns(1)
14
- @server.stubs(:hostname).returns("localhost")
15
- @server.stubs(:port).returns("19124")
16
- end
17
-
18
- describe 'without authentication credentials' do
19
- before do
20
- ENV['MEMCACHE_USERNAME'] = 'foo'
21
- ENV['MEMCACHE_PASSWORD'] = 'wrongpwd'
22
- end
23
-
24
- after do
25
- ENV['MEMCACHE_USERNAME'] = nil
26
- ENV['MEMCACHE_PASSWORD'] = nil
27
- end
28
-
29
- it 'provide one test that passes' do
30
- assert true
31
- end
32
-
33
- it 'gracefully handle authentication failures' do
34
- memcached(19124, '-S') do |dc|
35
- assert_error Dalli::DalliError, /32/ do
36
- dc.set('abc', 123)
37
- end
38
- end
39
- end
40
- end
41
-
42
- it 'fail SASL authentication with wrong options' do
43
- memcached(19124, '-S') do |dc|
44
- dc = Dalli::Client.new('localhost:19124', :username => 'foo', :password => 'wrongpwd')
45
- assert_error Dalli::DalliError, /32/ do
46
- dc.set('abc', 123)
47
- end
48
- end
49
- end
50
-
51
- # OSX: Create a SASL user for the memcached application like so:
52
- #
53
- # saslpasswd2 -a memcached -c testuser
54
- #
55
- # with password 'testtest'
56
- describe 'in an authenticated environment' do
57
- before do
58
- ENV['MEMCACHE_USERNAME'] = 'testuser'
59
- ENV['MEMCACHE_PASSWORD'] = 'testtest'
60
- end
61
-
62
- after do
63
- ENV['MEMCACHE_USERNAME'] = nil
64
- ENV['MEMCACHE_PASSWORD'] = nil
65
- end
66
-
67
- xit 'pass SASL authentication' do
68
- memcached(19124, '-S') do |dc|
69
- # I get "Dalli::DalliError: Error authenticating: 32" in OSX
70
- # but SASL works on Heroku servers. YMMV.
71
- assert_equal true, dc.set('abc', 123)
72
- assert_equal 123, dc.get('abc')
73
- results = dc.stats
74
- assert_equal 1, results.size
75
- assert_equal 38, results.values.first.size
76
- end
77
- end
78
- end
79
-
80
- xit 'pass SASL authentication with options' do
81
- memcached(19124, '-S') do |dc|
82
- dc = Dalli::Client.new('localhost:19124', :username => 'testuser', :password => 'testtest')
83
- # I get "Dalli::DalliError: Error authenticating: 32" in OSX
84
- # but SASL works on Heroku servers. YMMV.
85
- assert_equal true, dc.set('abc', 123)
86
- assert_equal 123, dc.get('abc')
87
- results = dc.stats
88
- assert_equal 1, results.size
89
- assert_equal 38, results.values.first.size
90
- end
91
- end
92
-
93
- it 'pass SASL as URI' do
94
- Dalli::Server.expects(:new).with("localhost:19124",
95
- :username => "testuser", :password => "testtest").returns(@server)
96
- dc = Dalli::Client.new('memcached://testuser:testtest@localhost:19124')
97
- dc.flush_all
98
- end
99
-
100
- it 'pass SASL as ring of URIs' do
101
- Dalli::Server.expects(:new).with("localhost:19124",
102
- :username => "testuser", :password => "testtest").returns(@server)
103
- Dalli::Server.expects(:new).with("otherhost:19125",
104
- :username => "testuser2", :password => "testtest2").returns(@server)
105
- dc = Dalli::Client.new(['memcached://testuser:testtest@localhost:19124',
106
- 'memcached://testuser2:testtest2@otherhost:19125'])
107
- dc.flush_all
108
- end
109
- end
110
- end