dalli 2.7.2 → 3.0.0

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.

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
@@ -1,30 +0,0 @@
1
- # encoding: utf-8
2
- require 'helper'
3
- require 'json'
4
- require 'memcached_mock'
5
-
6
- describe 'Serializer' do
7
-
8
- it 'default to Marshal' do
9
- memcached_kill(29198) do |dc|
10
- memcache = Dalli::Client.new('127.0.0.1:29198')
11
- memcache.set 1,2
12
- assert_equal Marshal, memcache.instance_variable_get('@ring').servers.first.serializer
13
- end
14
- end
15
-
16
- it 'support a custom serializer' do
17
- memcached_kill(29198) do |dc|
18
- memcache = Dalli::Client.new('127.0.0.1:29198', :serializer => JSON)
19
- memcache.set 1,2
20
- begin
21
- assert_equal JSON, memcache.instance_variable_get('@ring').servers.first.serializer
22
-
23
- memcached(19128) do |newdc|
24
- assert newdc.set("json_test", {"foo" => "bar"})
25
- assert_equal({"foo" => "bar"}, newdc.get("json_test"))
26
- end
27
- end
28
- end
29
- end
30
- end
data/test/test_server.rb DELETED
@@ -1,80 +0,0 @@
1
- require 'helper'
2
-
3
- describe Dalli::Server do
4
- describe 'hostname parsing' do
5
- it 'handles no port or weight' do
6
- s = Dalli::Server.new('localhost')
7
- assert_equal 'localhost', s.hostname
8
- assert_equal 11211, s.port
9
- assert_equal 1, s.weight
10
- end
11
-
12
- it 'handles a port, but no weight' do
13
- s = Dalli::Server.new('localhost:11212')
14
- assert_equal 'localhost', s.hostname
15
- assert_equal 11212, s.port
16
- assert_equal 1, s.weight
17
- end
18
-
19
- it 'handles a port and a weight' do
20
- s = Dalli::Server.new('localhost:11212:2')
21
- assert_equal 'localhost', s.hostname
22
- assert_equal 11212, s.port
23
- assert_equal 2, s.weight
24
- end
25
-
26
- it 'handles ipv4 addresses' do
27
- s = Dalli::Server.new('127.0.0.1')
28
- assert_equal '127.0.0.1', s.hostname
29
- assert_equal 11211, s.port
30
- assert_equal 1, s.weight
31
- end
32
-
33
- it 'handles ipv6 addresses' do
34
- s = Dalli::Server.new('[::1]')
35
- assert_equal '::1', s.hostname
36
- assert_equal 11211, s.port
37
- assert_equal 1, s.weight
38
- end
39
-
40
- it 'handles ipv6 addresses with port' do
41
- s = Dalli::Server.new('[::1]:11212')
42
- assert_equal '::1', s.hostname
43
- assert_equal 11212, s.port
44
- assert_equal 1, s.weight
45
- end
46
-
47
- it 'handles ipv6 addresses with port and weight' do
48
- s = Dalli::Server.new('[::1]:11212:2')
49
- assert_equal '::1', s.hostname
50
- assert_equal 11212, s.port
51
- assert_equal 2, s.weight
52
- end
53
-
54
- it 'handles a FQDN' do
55
- s = Dalli::Server.new('my.fqdn.com')
56
- assert_equal 'my.fqdn.com', s.hostname
57
- assert_equal 11211, s.port
58
- assert_equal 1, s.weight
59
- end
60
-
61
- it 'handles a FQDN with port and weight' do
62
- s = Dalli::Server.new('my.fqdn.com:11212:2')
63
- assert_equal 'my.fqdn.com', s.hostname
64
- assert_equal 11212, s.port
65
- assert_equal 2, s.weight
66
- end
67
- end
68
-
69
- describe 'ttl translation' do
70
- it 'does not translate ttls under 30 days' do
71
- s = Dalli::Server.new('localhost')
72
- assert_equal s.send(:sanitize_ttl, 30*24*60*60), 30*24*60*60
73
- end
74
-
75
- it 'translates ttls over 30 days into timestamps' do
76
- s = Dalli::Server.new('localhost')
77
- assert_equal s.send(:sanitize_ttl, 30*24*60*60 + 1), Time.now.to_i + 30*24*60*60+1
78
- end
79
- end
80
- end