net-ping 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +13 -3
- data/lib/net/ping.rb +1 -3
- data/lib/net/ping/ping.rb +1 -1
- data/net-ping.gemspec +5 -5
- data/test/test_net_ping.rb +17 -6
- data/test/test_net_ping_http.rb +12 -3
- data/test/test_net_ping_icmp.rb +98 -108
- data/test/test_net_ping_tcp.rb +3 -3
- metadata +20 -4
data/CHANGES
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
== 1.4.1 - 17-Mar-2011
|
2
|
+
* Incorporated changes from Lukas Zapletal that alters the icmp tests to use
|
3
|
+
your localhost instead of going outside the network.
|
4
|
+
* The http tests were similarly modified courtesy of fakeweb, which is now a
|
5
|
+
development dependency. Again, change from Lukas Zapletal.
|
6
|
+
* The icmp tests were reworked for Windows Vista and later. This required the
|
7
|
+
addition of the win32-security library as a development dependency.
|
8
|
+
* The Net::Ping::WMI class is no longer skipped on require or in tests since
|
9
|
+
JRuby now supports win32ole.
|
10
|
+
|
1
11
|
== 1.4.0 - 14-Feb-2011
|
2
12
|
* Added the redirect_limit accessor for the Net::Ping::HTTP class. This caps
|
3
13
|
the number of redirects that are allowed before a ping is considered a
|
@@ -45,7 +55,7 @@
|
|
45
55
|
== 1.3.2 - 21-Sep-2009
|
46
56
|
* Doing a 'require "net/ping"' was not automatically loading the
|
47
57
|
Net::Ping::WMI class on MS Windows. This has been fixed. Thanks go to
|
48
|
-
Joseph M. for the spot.
|
58
|
+
Joseph M. for the spot.
|
49
59
|
* Removed all $LOAD_PATH mangling for both the library and tests.
|
50
60
|
* Fixed a bug in the Net::Ping::HTTP class where a failed redirect did
|
51
61
|
not set the @exception and @warning instance variables properly.
|
@@ -116,7 +126,7 @@
|
|
116
126
|
|
117
127
|
== 1.2.0 - 5-Dec-2006
|
118
128
|
* Internal reorganization - each class now lives in its own file.
|
119
|
-
* Added the Ping::ICMP class. Thanks go to Jos Backus for contributing a
|
129
|
+
* Added the Ping::ICMP class. Thanks go to Jos Backus for contributing a
|
120
130
|
large part of the code.
|
121
131
|
* The host argument is now optional in the constructor. You can now specify
|
122
132
|
it in the ping method instead. Note that it must be specified in one place
|
@@ -199,7 +209,7 @@
|
|
199
209
|
* Doc updates
|
200
210
|
|
201
211
|
== 0.2.0 - 14-Feb-2003
|
202
|
-
* The default behavior of PingTCP with regards to ECONNREFUSED is now
|
212
|
+
* The default behavior of PingTCP with regards to ECONNREFUSED is now
|
203
213
|
configurable
|
204
214
|
* Added a VERSION constant and method (to the base class)
|
205
215
|
* Added a test suite (for those with testunit installed)
|
data/lib/net/ping.rb
CHANGED
@@ -10,8 +10,6 @@ require File.join(File.dirname(__FILE__), 'ping/icmp')
|
|
10
10
|
require File.join(File.dirname(__FILE__), 'ping/external')
|
11
11
|
require File.join(File.dirname(__FILE__), 'ping/http')
|
12
12
|
|
13
|
-
if Config::CONFIG['host_os'] =~ /msdos|mswin|cygwin|mingw|win32|windows/i
|
14
|
-
RUBY_PLATFORM != 'java'
|
15
|
-
then
|
13
|
+
if Config::CONFIG['host_os'] =~ /msdos|mswin|cygwin|mingw|win32|windows/i
|
16
14
|
require File.join(File.dirname(__FILE__), 'ping/wmi')
|
17
15
|
end
|
data/lib/net/ping/ping.rb
CHANGED
data/net-ping.gemspec
CHANGED
@@ -3,7 +3,7 @@ require 'rbconfig'
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = 'net-ping'
|
6
|
-
gem.version = '1.4.
|
6
|
+
gem.version = '1.4.1'
|
7
7
|
gem.license = 'Artistic 2.0'
|
8
8
|
gem.author = 'Daniel J. Berger'
|
9
9
|
gem.email = 'djberg96@gmail.com'
|
@@ -17,16 +17,16 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.extra_rdoc_files = ['README', 'CHANGES', 'doc/ping.txt']
|
18
18
|
|
19
19
|
gem.add_development_dependency('test-unit', '>= 2.1.2')
|
20
|
+
gem.add_development_dependency('fakeweb', '>= 1.3.0')
|
20
21
|
|
21
22
|
# These dependencies are for Net::Ping::External
|
22
|
-
if
|
23
|
-
RUBY_PLATFORM != 'java'
|
24
|
-
then
|
23
|
+
if File::ALT_SEPARATOR && RUBY_PLATFORM != 'java'
|
25
24
|
gem.platform = Gem::Platform::CURRENT
|
26
25
|
gem.add_dependency('windows-pr', '>= 1.0.8')
|
26
|
+
gem.add_development_dependency('win32-security', '>= 1.0.8')
|
27
27
|
|
28
28
|
if RUBY_VERSION.to_f < 1.9
|
29
|
-
gem.add_dependency('win32-open3', '>= 0.3.1')
|
29
|
+
gem.add_dependency('win32-open3', '>= 0.3.1')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
data/test/test_net_ping.rb
CHANGED
@@ -8,19 +8,30 @@ require 'test_net_ping_external'
|
|
8
8
|
require 'test_net_ping_http'
|
9
9
|
require 'test_net_ping_tcp'
|
10
10
|
require 'test_net_ping_udp'
|
11
|
+
require 'fakeweb'
|
11
12
|
|
12
|
-
if
|
13
|
-
require '
|
13
|
+
if File::ALT_SEPARATOR
|
14
|
+
require 'win32/security'
|
15
|
+
require 'windows/system_info'
|
16
|
+
include Windows::SystemInfo
|
17
|
+
|
18
|
+
if windows_version >= 6 && Win32::Security.elevated_security?
|
19
|
+
require 'test_net_ping_icmp'
|
20
|
+
end
|
21
|
+
else
|
22
|
+
if Process.euid == 0
|
23
|
+
require 'test_net_ping_icmp'
|
24
|
+
end
|
14
25
|
end
|
15
26
|
|
16
|
-
if
|
17
|
-
RUBY_PLATFORM != 'java'
|
18
|
-
then
|
27
|
+
if File::ALT_SEPARATOR
|
19
28
|
require 'test_net_ping_wmi'
|
20
29
|
end
|
21
30
|
|
22
31
|
class TC_Net_Ping < Test::Unit::TestCase
|
23
32
|
def test_net_ping_version
|
24
|
-
assert_equal('1.4.
|
33
|
+
assert_equal('1.4.1', Net::Ping::VERSION)
|
25
34
|
end
|
26
35
|
end
|
36
|
+
|
37
|
+
FakeWeb.allow_net_connect = false
|
data/test/test_net_ping_http.rb
CHANGED
@@ -12,7 +12,16 @@ require 'net/ping/http'
|
|
12
12
|
|
13
13
|
class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
14
14
|
def setup
|
15
|
-
@uri
|
15
|
+
@uri = 'http://www.google.com/index.html'
|
16
|
+
@uri_https = 'https://encrypted.google.com'
|
17
|
+
|
18
|
+
FakeWeb.register_uri(:get, @uri, :body => "PONG")
|
19
|
+
FakeWeb.register_uri(:get, @uri_https, :body => "PONG")
|
20
|
+
FakeWeb.register_uri(:get, "http://jigsaw.w3.org/HTTP/300/302.html",
|
21
|
+
:body => "PONG",
|
22
|
+
:location => "#{@uri}",
|
23
|
+
:status => ["302", "Found"])
|
24
|
+
|
16
25
|
@http = Net::Ping::HTTP.new(@uri, 80, 30)
|
17
26
|
@bad = Net::Ping::HTTP.new('http://www.blabfoobarurghxxxx.com') # One hopes not
|
18
27
|
end
|
@@ -150,13 +159,13 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
150
159
|
end
|
151
160
|
|
152
161
|
test 'ping against https site defaults to port 443' do
|
153
|
-
@http = Net::Ping::HTTP.new(
|
162
|
+
@http = Net::Ping::HTTP.new(@uri_https)
|
154
163
|
assert_equal(443, @http.port)
|
155
164
|
end
|
156
165
|
|
157
166
|
# This will generate a warning. Nothing I can do about it.
|
158
167
|
test 'ping against https site works as expected' do
|
159
|
-
@http = Net::Ping::HTTP.new(
|
168
|
+
@http = Net::Ping::HTTP.new(@uri_https)
|
160
169
|
assert_true(@http.ping)
|
161
170
|
end
|
162
171
|
|
data/test/test_net_ping_icmp.rb
CHANGED
@@ -12,115 +12,105 @@ require 'test/unit'
|
|
12
12
|
require 'net/ping/icmp'
|
13
13
|
include Net
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
if File::ALT_SEPARATOR
|
16
|
+
require 'win32/security'
|
17
|
+
require 'windows/system_info'
|
18
|
+
include Windows::SystemInfo
|
19
|
+
|
20
|
+
if windows_version >= 6 && !Win32::Security.elevated_security?
|
21
|
+
raise "The test:icmp task must be run with elevated security rights"
|
22
|
+
end
|
23
|
+
else
|
24
|
+
unless Process.euid == 0
|
25
|
+
raise "The test:icmp task must be run with root privileges"
|
26
|
+
end
|
17
27
|
end
|
18
28
|
|
19
29
|
class TC_PingICMP < Test::Unit::TestCase
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
def test_data_size_set
|
108
|
-
assert_respond_to(@icmp, :data_size=)
|
109
|
-
assert_nothing_raised{ @icmp.data_size = 22 }
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_odd_data_size_ok
|
113
|
-
assert_nothing_raised{ @icmp.data_size = 57 }
|
114
|
-
omit_if(@@one_click, 'Unreliable socket library')
|
115
|
-
assert_boolean(@icmp.ping)
|
116
|
-
end
|
117
|
-
|
118
|
-
def teardown
|
119
|
-
@host = nil
|
120
|
-
@icmp = nil
|
121
|
-
end
|
122
|
-
|
123
|
-
def self.shutdown
|
124
|
-
@@one_click = nil
|
125
|
-
end
|
30
|
+
def setup
|
31
|
+
@host = 'localhost'
|
32
|
+
@icmp = Ping::ICMP.new(@host)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_ping
|
36
|
+
assert_respond_to(@icmp, :ping)
|
37
|
+
assert_nothing_raised{ @icmp.ping }
|
38
|
+
assert_nothing_raised{ @icmp.ping(@host) }
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_ping_aliases_basic
|
42
|
+
assert_respond_to(@icmp, :ping?)
|
43
|
+
assert_respond_to(@icmp, :pingecho)
|
44
|
+
assert_nothing_raised{ @icmp.ping? }
|
45
|
+
assert_nothing_raised{ @icmp.ping?(@host) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_ping_returns_boolean
|
49
|
+
assert_boolean(@icmp.pingecho)
|
50
|
+
assert_boolean(@icmp.pingecho(@host))
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_ping_expected_failure
|
54
|
+
assert_false(Ping::ICMP.new('bogus').ping?)
|
55
|
+
assert_false(Ping::ICMP.new('http://www.asdfhjklasdfhlkj.com').ping?)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_bind
|
59
|
+
assert_respond_to(@icmp, :bind)
|
60
|
+
assert_nothing_raised{ @icmp.bind(Socket.gethostname) }
|
61
|
+
assert_nothing_raised{ @icmp.bind(Socket.gethostname, 80) }
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_duration
|
65
|
+
assert_nothing_raised{ @icmp.ping }
|
66
|
+
assert_respond_to(@icmp, :duration)
|
67
|
+
assert_kind_of(Float, @icmp.duration)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_host
|
71
|
+
assert_respond_to(@icmp, :host)
|
72
|
+
assert_respond_to(@icmp, :host=)
|
73
|
+
assert_equal('localhost', @icmp.host)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_port
|
77
|
+
assert_respond_to(@icmp, :port)
|
78
|
+
assert_equal(nil, @icmp.port)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_timeout
|
82
|
+
assert_respond_to(@icmp, :timeout)
|
83
|
+
assert_respond_to(@icmp, :timeout=)
|
84
|
+
assert_equal(5, @icmp.timeout)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_exception
|
88
|
+
assert_respond_to(@icmp, :exception)
|
89
|
+
assert_nothing_raised{ @icmp.ping }
|
90
|
+
assert_nil(@icmp.exception)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_warning
|
94
|
+
assert_respond_to(@icmp, :warning)
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_data_size_get
|
98
|
+
assert_respond_to(@icmp, :data_size)
|
99
|
+
assert_equal(56, @icmp.data_size)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_data_size_set
|
103
|
+
assert_respond_to(@icmp, :data_size=)
|
104
|
+
assert_nothing_raised{ @icmp.data_size = 22 }
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_odd_data_size_ok
|
108
|
+
assert_nothing_raised{ @icmp.data_size = 57 }
|
109
|
+
assert_boolean(@icmp.ping)
|
110
|
+
end
|
111
|
+
|
112
|
+
def teardown
|
113
|
+
@host = nil
|
114
|
+
@icmp = nil
|
115
|
+
end
|
126
116
|
end
|
data/test/test_net_ping_tcp.rb
CHANGED
@@ -13,8 +13,8 @@ include Net
|
|
13
13
|
|
14
14
|
class TC_PingTCP < Test::Unit::TestCase
|
15
15
|
def setup
|
16
|
-
@host = '
|
17
|
-
@port =
|
16
|
+
@host = 'localhost'
|
17
|
+
@port = 22
|
18
18
|
@tcp = Ping::TCP.new(@host, @port)
|
19
19
|
end
|
20
20
|
|
@@ -81,7 +81,7 @@ class TC_PingTCP < Test::Unit::TestCase
|
|
81
81
|
def test_port
|
82
82
|
assert_respond_to(@tcp, :port)
|
83
83
|
assert_respond_to(@tcp, :port=)
|
84
|
-
assert_equal(
|
84
|
+
assert_equal(22, @tcp.port)
|
85
85
|
end
|
86
86
|
|
87
87
|
def test_timeout
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 1
|
10
|
+
version: 1.4.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel J. Berger
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-17 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -34,6 +34,22 @@ dependencies:
|
|
34
34
|
version: 2.1.2
|
35
35
|
type: :development
|
36
36
|
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: fakeweb
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 27
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 3
|
49
|
+
- 0
|
50
|
+
version: 1.3.0
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
37
53
|
description: " The net-ping library provides a ping interface for Ruby. It includes\n separate TCP, HTTP, ICMP, UDP, WMI (for Windows) and external ping\n classes.\n"
|
38
54
|
email: djberg96@gmail.com
|
39
55
|
executables: []
|