net-ping 1.4.1-x86-mingw32 → 1.5.3-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,200 @@
1
+ #################################################################################
2
+ # test_net_ping_http.rb
3
+ #
4
+ # Test case for the Net::PingHTTP class. This should be run via the 'test' or
5
+ # 'test:http' Rake task.
6
+ #################################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'test/unit'
11
+ require 'net/ping/ldap'
12
+ require 'fakeldap'
13
+
14
+ class TC_Net_Ping_LDAP < Test::Unit::TestCase
15
+ class << self
16
+ def startup
17
+ @@host = 'localhost'
18
+ @@port = 2389
19
+ @@uri = "ldap://#{@@host}:#{@@port}"
20
+ @@timeout = 30
21
+ @@cn = 'el.Daper'
22
+ @@password = 'ldappassword'
23
+
24
+ @@ldap_server = FakeLDAP::Server.new(:port => @@port)
25
+ @@ldap_server.run_tcpserver
26
+ @@ldap_server.add_user("cn=#{@@cn},ou=USERS,dc=example,dc=com", @@password)
27
+ end
28
+ def shutdown
29
+ @@ldap_server.stop
30
+ end
31
+ end
32
+ def setup
33
+ @ldap = Net::Ping::LDAP.new(@@uri, @@timeout)
34
+ @ldap.username = @@cn
35
+ @ldap.password = @@password
36
+ @bogus = 'ldap://blabfoobarurghxxxx.com' # One hopes so
37
+ @bad = Net::Ping::LDAP.new(@bogus)
38
+ end
39
+
40
+ def teardown
41
+ @ldap = nil
42
+ end
43
+
44
+ test 'ping basic functionality' do
45
+ assert_respond_to(@ldap, :ping)
46
+ assert_nothing_raised{ @ldap.ping }
47
+ end
48
+
49
+ test 'ping returns a boolean value' do
50
+ assert_boolean(@ldap.ping?)
51
+ assert_boolean(@bad.ping?)
52
+ end
53
+
54
+ test 'ping? is an alias for ping' do
55
+ assert_alias_method(@ldap, :ping?, :ping)
56
+ end
57
+
58
+ test 'pingecho is an alias for ping' do
59
+ assert_alias_method(@ldap, :pingecho, :ping)
60
+ end
61
+
62
+ test 'ping should succeed for a valid website' do
63
+ assert_true(@ldap.ping?)
64
+ end
65
+
66
+ test 'ping should fail for an invalid website' do
67
+ assert_false(@bad.ping?)
68
+ end
69
+
70
+ test 'duration basic functionality' do
71
+ assert_respond_to(@ldap, :duration)
72
+ assert_nothing_raised{ @ldap.ping }
73
+ end
74
+
75
+ test 'duration returns a float value on a successful ping' do
76
+ assert_true(@ldap.ping)
77
+ assert_kind_of(Float, @ldap.duration)
78
+ end
79
+
80
+ test 'duration is nil on an unsuccessful ping' do
81
+ assert_false(@bad.ping)
82
+ assert_nil(@ldap.duration)
83
+ end
84
+
85
+ test "duration is unset if a bad ping follows a good ping" do
86
+ assert_true{ @ldap.ping }
87
+ assert_not_nil(@ldap.duration)
88
+ assert_false(@ldap.ping?(@bogus))
89
+ assert_nil(@ldap.duration)
90
+ end
91
+
92
+ test 'host attribute basic functionality' do
93
+ assert_respond_to(@ldap, :host)
94
+ assert_respond_to(@ldap, :host=)
95
+ assert_equal(@@host, @ldap.host)
96
+ end
97
+
98
+ test 'port attribute basic functionality' do
99
+ assert_respond_to(@ldap, :port)
100
+ assert_respond_to(@ldap, :port=)
101
+ end
102
+
103
+ test 'port attribute expected value' do
104
+ assert_equal(@@port, @ldap.port)
105
+ end
106
+
107
+ test 'timeout attribute basic functionality' do
108
+ assert_respond_to(@ldap, :timeout)
109
+ assert_respond_to(@ldap, :timeout=)
110
+ end
111
+
112
+ test 'timeout attribute expected values' do
113
+ assert_equal(@@timeout, @ldap.timeout)
114
+ assert_equal(5, @bad.timeout)
115
+ end
116
+
117
+ test 'exception attribute basic functionality' do
118
+ assert_respond_to(@ldap, :exception)
119
+ assert_nil(@ldap.exception)
120
+ end
121
+
122
+ test 'exception attribute is nil if the ping is successful' do
123
+ assert_true(@ldap.ping)
124
+ assert_nil(@ldap.exception)
125
+ end
126
+
127
+ test 'exception attribute is not nil if the ping is unsuccessful' do
128
+ assert_false(@bad.ping)
129
+ assert_not_nil(@bad.exception)
130
+ end
131
+
132
+ test 'warning attribute basic functionality' do
133
+ assert_respond_to(@ldap, :warning)
134
+ assert_nil(@ldap.warning)
135
+ end
136
+
137
+ test 'uri attribute basic functionality' do
138
+ assert_respond_to(@ldap, :uri)
139
+ assert_respond_to(@ldap, :uri=)
140
+ end
141
+
142
+ test 'username attribute basic functionality' do
143
+ assert_respond_to(@ldap, :username)
144
+ assert_respond_to(@ldap, :username=)
145
+ end
146
+
147
+ test 'password attribute basic functionality' do
148
+ assert_respond_to(@ldap, :password)
149
+ assert_respond_to(@ldap, :password=)
150
+ end
151
+
152
+ test 'encryption attribute basic functionality' do
153
+ assert_respond_to(@ldap, :encryption)
154
+ assert_respond_to(@ldap, :encryption=)
155
+ end
156
+
157
+ test 'encryption defaults to nil for ldap' do
158
+ assert_nil(Net::Ping::LDAP.new('ldap://somehost.example.net').encryption)
159
+ end
160
+
161
+ test 'encryption defaults to simple_tls for ldaps' do
162
+ assert_equal(:simple_tls, Net::Ping::LDAP.new('ldaps://somehost.example.net').encryption)
163
+ end
164
+
165
+ test 'port defaults to 389 for ldap' do
166
+ assert_equal(389, Net::Ping::LDAP.new('ldap://somehost.example.net').port)
167
+ end
168
+
169
+ test 'port defaults to 636 for ldaps' do
170
+ assert_equal(636, Net::Ping::LDAP.new('ldaps://somehost.example.net').port)
171
+ end
172
+
173
+ test 'port extracted from uri if provided' do
174
+ assert_equal(12345, Net::Ping::LDAP.new('ldap://somehost.example.net:12345').port)
175
+ assert_equal(12345, Net::Ping::LDAP.new('ldaps://somehost.example.net:12345').port)
176
+ end
177
+
178
+ test 'encryption setting is forced to symbol' do
179
+ @ldap.encryption = 'simple_tls'
180
+ assert_true( @ldap.encryption.is_a? Symbol )
181
+ assert_true( @ldap.config[:encryption].is_a? Symbol )
182
+ end
183
+
184
+ test 'username/password set in config auth section' do
185
+ @ldap.username, @ldap.password = 'fred', 'derf'
186
+ assert_equal('fred', @ldap.config[:auth][:username] )
187
+ assert_equal('derf', @ldap.config[:auth][:password] )
188
+ end
189
+
190
+ test 'auth method defaults to simple if username/password set' do
191
+ @ldap.username, @ldap.password = 'fred', 'derf'
192
+ assert_equal(:simple, @ldap.config[:auth][:method] )
193
+ end
194
+
195
+ test 'if no username/password then defaults to auth anonymous' do
196
+ @ldap.username = @ldap.password = nil
197
+ assert_equal({:method => :anonymous}, @ldap.config[:auth] )
198
+ end
199
+
200
+ end
@@ -1,108 +1,108 @@
1
- #####################################################################
2
- # test_net_ping_tcp.rb
3
- #
4
- # Test case for the Net::PingTCP class. This test should be run via
5
- # the 'test' or 'test:tcp' Rake task.
6
- #####################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
- require 'test/unit'
11
- require 'net/ping/tcp'
12
- include Net
13
-
14
- class TC_PingTCP < Test::Unit::TestCase
15
- def setup
16
- @host = 'localhost'
17
- @port = 22
18
- @tcp = Ping::TCP.new(@host, @port)
19
- end
20
-
21
- def test_ping
22
- assert_respond_to(@tcp, :ping)
23
- assert_nothing_raised{ @tcp.ping }
24
- assert_nothing_raised{ @tcp.ping(@host) }
25
- end
26
-
27
- def test_ping_aliases
28
- assert_respond_to(@tcp, :ping?)
29
- assert_respond_to(@tcp, :pingecho)
30
- assert_nothing_raised{ @tcp.ping? }
31
- assert_nothing_raised{ @tcp.ping?(@host) }
32
- assert_nothing_raised{ @tcp.pingecho }
33
- assert_nothing_raised{ @tcp.pingecho(@host) }
34
- end
35
-
36
- def test_ping_service_check_false
37
- msg = "+this test may fail depending on your network environment+"
38
- Ping::TCP.service_check = false
39
- @tcp = Ping::TCP.new('localhost')
40
- assert_false(@tcp.ping?, msg)
41
- assert_false(@tcp.exception.nil?, "Bad exception data")
42
- end
43
-
44
- def test_ping_service_check_true
45
- msg = "+this test may fail depending on your network environment+"
46
- Ping::TCP.service_check = true
47
- assert_true(@tcp.ping?, msg)
48
- end
49
-
50
- def test_service_check
51
- assert_respond_to(Ping::TCP, :service_check)
52
- assert_respond_to(Ping::TCP, :service_check=)
53
- end
54
-
55
- # These will be removed eventually
56
- def test_service_check_aliases
57
- assert_respond_to(Ping::TCP, :econnrefused)
58
- assert_respond_to(Ping::TCP, :econnrefused=)
59
- assert_respond_to(Ping::TCP, :ecr)
60
- assert_respond_to(Ping::TCP, :ecr=)
61
- end
62
-
63
- def test_service_check_expected_errors
64
- assert_raises(ArgumentError){ Ping::TCP.service_check = "blah" }
65
- end
66
-
67
- # If the ping failed, the duration will be nil
68
- def test_duration
69
- assert_nothing_raised{ @tcp.ping }
70
- assert_respond_to(@tcp, :duration)
71
- omit_if(@tcp.duration.nil?, 'ping failed, skipping')
72
- assert_kind_of(Float, @tcp.duration)
73
- end
74
-
75
- def test_host
76
- assert_respond_to(@tcp, :host)
77
- assert_respond_to(@tcp, :host=)
78
- assert_equal(@host, @tcp.host)
79
- end
80
-
81
- def test_port
82
- assert_respond_to(@tcp, :port)
83
- assert_respond_to(@tcp, :port=)
84
- assert_equal(22, @tcp.port)
85
- end
86
-
87
- def test_timeout
88
- assert_respond_to(@tcp, :timeout)
89
- assert_respond_to(@tcp, :timeout=)
90
- assert_equal(5, @tcp.timeout)
91
- end
92
-
93
- def test_exception
94
- msg = "+this test may fail depending on your network environment+"
95
- assert_respond_to(@tcp, :exception)
96
- assert_nothing_raised{ @tcp.ping }
97
- assert_nil(@tcp.exception, msg)
98
- end
99
-
100
- def test_warning
101
- assert_respond_to(@tcp, :warning)
102
- end
103
-
104
- def teardown
105
- @host = nil
106
- @tcp = nil
107
- end
108
- end
1
+ #####################################################################
2
+ # test_net_ping_tcp.rb
3
+ #
4
+ # Test case for the Net::PingTCP class. This test should be run via
5
+ # the 'test' or 'test:tcp' Rake task.
6
+ #####################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'test/unit'
11
+ require 'net/ping/tcp'
12
+ include Net
13
+
14
+ class TC_PingTCP < Test::Unit::TestCase
15
+ def setup
16
+ @host = 'localhost'
17
+ @port = 22
18
+ @tcp = Ping::TCP.new(@host, @port)
19
+ end
20
+
21
+ def test_ping
22
+ assert_respond_to(@tcp, :ping)
23
+ assert_nothing_raised{ @tcp.ping }
24
+ assert_nothing_raised{ @tcp.ping(@host) }
25
+ end
26
+
27
+ def test_ping_aliases
28
+ assert_respond_to(@tcp, :ping?)
29
+ assert_respond_to(@tcp, :pingecho)
30
+ assert_nothing_raised{ @tcp.ping? }
31
+ assert_nothing_raised{ @tcp.ping?(@host) }
32
+ assert_nothing_raised{ @tcp.pingecho }
33
+ assert_nothing_raised{ @tcp.pingecho(@host) }
34
+ end
35
+
36
+ def test_ping_service_check_false
37
+ msg = "+this test may fail depending on your network environment+"
38
+ Ping::TCP.service_check = false
39
+ @tcp = Ping::TCP.new('localhost')
40
+ assert_false(@tcp.ping?, msg)
41
+ assert_false(@tcp.exception.nil?, "Bad exception data")
42
+ end
43
+
44
+ def test_ping_service_check_true
45
+ msg = "+this test may fail depending on your network environment+"
46
+ Ping::TCP.service_check = true
47
+ assert_true(@tcp.ping?, msg)
48
+ end
49
+
50
+ def test_service_check
51
+ assert_respond_to(Ping::TCP, :service_check)
52
+ assert_respond_to(Ping::TCP, :service_check=)
53
+ end
54
+
55
+ # These will be removed eventually
56
+ def test_service_check_aliases
57
+ assert_respond_to(Ping::TCP, :econnrefused)
58
+ assert_respond_to(Ping::TCP, :econnrefused=)
59
+ assert_respond_to(Ping::TCP, :ecr)
60
+ assert_respond_to(Ping::TCP, :ecr=)
61
+ end
62
+
63
+ def test_service_check_expected_errors
64
+ assert_raises(ArgumentError){ Ping::TCP.service_check = "blah" }
65
+ end
66
+
67
+ # If the ping failed, the duration will be nil
68
+ def test_duration
69
+ assert_nothing_raised{ @tcp.ping }
70
+ assert_respond_to(@tcp, :duration)
71
+ omit_if(@tcp.duration.nil?, 'ping failed, skipping')
72
+ assert_kind_of(Float, @tcp.duration)
73
+ end
74
+
75
+ def test_host
76
+ assert_respond_to(@tcp, :host)
77
+ assert_respond_to(@tcp, :host=)
78
+ assert_equal(@host, @tcp.host)
79
+ end
80
+
81
+ def test_port
82
+ assert_respond_to(@tcp, :port)
83
+ assert_respond_to(@tcp, :port=)
84
+ assert_equal(22, @tcp.port)
85
+ end
86
+
87
+ def test_timeout
88
+ assert_respond_to(@tcp, :timeout)
89
+ assert_respond_to(@tcp, :timeout=)
90
+ assert_equal(5, @tcp.timeout)
91
+ end
92
+
93
+ def test_exception
94
+ msg = "+this test may fail depending on your network environment+"
95
+ assert_respond_to(@tcp, :exception)
96
+ assert_nothing_raised{ @tcp.ping }
97
+ assert_nil(@tcp.exception, msg)
98
+ end
99
+
100
+ def test_warning
101
+ assert_respond_to(@tcp, :warning)
102
+ end
103
+
104
+ def teardown
105
+ @host = nil
106
+ @tcp = nil
107
+ end
108
+ end
@@ -1,122 +1,122 @@
1
- ########################################################################
2
- # test_net_ping_udp.rb
3
- #
4
- # Test case for the Net::Ping::UDP class. This should be run via the
5
- # 'test' or 'test:udp' Rake tasks.
6
- #
7
- # If someone could provide me a host where a udp ping actually
8
- # works (with a service check), I would appreciate it. :)
9
- ########################################################################
10
- require 'rubygems'
11
- gem 'test-unit'
12
-
13
- require 'test/unit'
14
- require 'net/ping/udp'
15
-
16
- class TC_Net_Ping_UDP < Test::Unit::TestCase
17
- def setup
18
- Net::Ping::UDP.service_check = false
19
- @host = '127.0.0.1'
20
- @udp = Net::Ping::UDP.new(@host)
21
- end
22
-
23
- test "ping basic functionality" do
24
- assert_respond_to(@udp, :ping)
25
- assert_nothing_raised{ @udp.ping }
26
- end
27
-
28
- test "ping accepts a host as an argument" do
29
- assert_nothing_raised{ @udp.ping(@host) }
30
- end
31
-
32
- test "ping? is an alias for ping" do
33
- assert_respond_to(@udp, :ping?)
34
- assert_alias_method(@udp, :ping?, :ping)
35
- end
36
-
37
- test "pingecho is an alias for ping" do
38
- assert_respond_to(@udp, :pingecho)
39
- assert_alias_method(@udp, :pingecho, :ping)
40
- end
41
-
42
- test "a successful udp ping returns true" do
43
- assert_true(@udp.ping?)
44
- end
45
-
46
- test "bind basic functionality" do
47
- assert_respond_to(@udp, :bind)
48
- assert_nothing_raised{ @udp.bind('127.0.0.1', 80) }
49
- end
50
-
51
- test "duration basic functionality" do
52
- assert_nothing_raised{ @udp.ping }
53
- assert_respond_to(@udp, :duration)
54
- assert_kind_of(Float, @udp.duration)
55
- end
56
-
57
- test "host basic functionality" do
58
- assert_respond_to(@udp, :host)
59
- assert_respond_to(@udp, :host=)
60
- assert_equal('127.0.0.1', @udp.host)
61
- end
62
-
63
- test "port basic functionality" do
64
- assert_respond_to(@udp, :port)
65
- assert_respond_to(@udp, :port=)
66
- assert_equal(7, @udp.port)
67
- end
68
-
69
- test "timeout basic functionality" do
70
- assert_respond_to(@udp, :timeout)
71
- assert_respond_to(@udp, :timeout=)
72
- end
73
-
74
- test "timeout default value is five" do
75
- assert_equal(5, @udp.timeout)
76
- end
77
-
78
- test "exception basic functionality" do
79
- assert_respond_to(@udp, :exception)
80
- end
81
-
82
- test "the exception attribute returns nil if the ping is successful" do
83
- assert_true(@udp.ping?)
84
- assert_nil(@udp.exception)
85
- end
86
-
87
- test "the exception attribute is not nil if the ping is unsuccessful" do
88
- assert_false(@udp.ping?('www.ruby-lang.org'))
89
- assert_not_nil(@udp.exception)
90
- end
91
-
92
- test "warning basic functionality" do
93
- assert_respond_to(@udp, :warning)
94
- end
95
-
96
- test "the warning attribute returns nil if the ping is successful" do
97
- assert_true(@udp.ping?)
98
- assert_nil(@udp.warning)
99
- end
100
-
101
- test "service_check basic functionality" do
102
- assert_respond_to(Net::Ping::UDP, :service_check)
103
- assert_respond_to(Net::Ping::UDP, :service_check=)
104
- end
105
-
106
- test "service_check attribute has been set to false" do
107
- assert_false(Net::Ping::UDP.service_check)
108
- end
109
-
110
- test "service_check getter method does not accept arguments" do
111
- assert_raise(ArgumentError){ Net::Ping::UDP.service_check(1) }
112
- end
113
-
114
- test "service_check setter method only accepts boolean arguments" do
115
- assert_raise(ArgumentError){ Net::Ping::UDP.service_check = 1 }
116
- end
117
-
118
- def teardown
119
- @host = nil
120
- @udp = nil
121
- end
122
- end
1
+ ########################################################################
2
+ # test_net_ping_udp.rb
3
+ #
4
+ # Test case for the Net::Ping::UDP class. This should be run via the
5
+ # 'test' or 'test:udp' Rake tasks.
6
+ #
7
+ # If someone could provide me a host where a udp ping actually
8
+ # works (with a service check), I would appreciate it. :)
9
+ ########################################################################
10
+ require 'rubygems'
11
+ gem 'test-unit'
12
+
13
+ require 'test/unit'
14
+ require 'net/ping/udp'
15
+
16
+ class TC_Net_Ping_UDP < Test::Unit::TestCase
17
+ def setup
18
+ Net::Ping::UDP.service_check = false
19
+ @host = '127.0.0.1'
20
+ @udp = Net::Ping::UDP.new(@host)
21
+ end
22
+
23
+ test "ping basic functionality" do
24
+ assert_respond_to(@udp, :ping)
25
+ assert_nothing_raised{ @udp.ping }
26
+ end
27
+
28
+ test "ping accepts a host as an argument" do
29
+ assert_nothing_raised{ @udp.ping(@host) }
30
+ end
31
+
32
+ test "ping? is an alias for ping" do
33
+ assert_respond_to(@udp, :ping?)
34
+ assert_alias_method(@udp, :ping?, :ping)
35
+ end
36
+
37
+ test "pingecho is an alias for ping" do
38
+ assert_respond_to(@udp, :pingecho)
39
+ assert_alias_method(@udp, :pingecho, :ping)
40
+ end
41
+
42
+ test "a successful udp ping returns true" do
43
+ assert_true(@udp.ping?)
44
+ end
45
+
46
+ test "bind basic functionality" do
47
+ assert_respond_to(@udp, :bind)
48
+ assert_nothing_raised{ @udp.bind('127.0.0.1', 80) }
49
+ end
50
+
51
+ test "duration basic functionality" do
52
+ assert_nothing_raised{ @udp.ping }
53
+ assert_respond_to(@udp, :duration)
54
+ assert_kind_of(Float, @udp.duration)
55
+ end
56
+
57
+ test "host basic functionality" do
58
+ assert_respond_to(@udp, :host)
59
+ assert_respond_to(@udp, :host=)
60
+ assert_equal('127.0.0.1', @udp.host)
61
+ end
62
+
63
+ test "port basic functionality" do
64
+ assert_respond_to(@udp, :port)
65
+ assert_respond_to(@udp, :port=)
66
+ assert_equal(7, @udp.port)
67
+ end
68
+
69
+ test "timeout basic functionality" do
70
+ assert_respond_to(@udp, :timeout)
71
+ assert_respond_to(@udp, :timeout=)
72
+ end
73
+
74
+ test "timeout default value is five" do
75
+ assert_equal(5, @udp.timeout)
76
+ end
77
+
78
+ test "exception basic functionality" do
79
+ assert_respond_to(@udp, :exception)
80
+ end
81
+
82
+ test "the exception attribute returns nil if the ping is successful" do
83
+ assert_true(@udp.ping?)
84
+ assert_nil(@udp.exception)
85
+ end
86
+
87
+ test "the exception attribute is not nil if the ping is unsuccessful" do
88
+ assert_false(@udp.ping?('www.ruby-lang.org'))
89
+ assert_not_nil(@udp.exception)
90
+ end
91
+
92
+ test "warning basic functionality" do
93
+ assert_respond_to(@udp, :warning)
94
+ end
95
+
96
+ test "the warning attribute returns nil if the ping is successful" do
97
+ assert_true(@udp.ping?)
98
+ assert_nil(@udp.warning)
99
+ end
100
+
101
+ test "service_check basic functionality" do
102
+ assert_respond_to(Net::Ping::UDP, :service_check)
103
+ assert_respond_to(Net::Ping::UDP, :service_check=)
104
+ end
105
+
106
+ test "service_check attribute has been set to false" do
107
+ assert_false(Net::Ping::UDP.service_check)
108
+ end
109
+
110
+ test "service_check getter method does not accept arguments" do
111
+ assert_raise(ArgumentError){ Net::Ping::UDP.service_check(1) }
112
+ end
113
+
114
+ test "service_check setter method only accepts boolean arguments" do
115
+ assert_raise(ArgumentError){ Net::Ping::UDP.service_check = 1 }
116
+ end
117
+
118
+ def teardown
119
+ @host = nil
120
+ @udp = nil
121
+ end
122
+ end