net-ping 1.5.3-x86-mingw32 → 1.6.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/CHANGES +21 -0
- data/Gemfile +2 -0
- data/Rakefile +6 -12
- data/lib/net/ping.rb +1 -2
- data/lib/net/ping/helper.rb +31 -0
- data/lib/net/ping/http.rb +24 -14
- data/lib/net/ping/icmp.rb +2 -3
- data/lib/net/ping/ping.rb +1 -1
- data/net-ping.gemspec +5 -6
- data/test/test_net_ping.rb +2 -4
- data/test/test_net_ping_external.rb +5 -4
- data/test/test_net_ping_http.rb +32 -4
- data/test/test_net_ping_icmp.rb +1 -4
- data/test/test_net_ping_tcp.rb +1 -4
- data/test/test_net_ping_udp.rb +1 -4
- data/test/test_net_ping_wmi.rb +6 -9
- metadata +86 -146
- data/examples/example_pingldap.rb +0 -22
- data/lib/net/ping/ldap.rb +0 -107
- data/test/test_net_ping_ldap.rb +0 -200
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NmEyMGYyYjAyZjY0Zjc4ZGUxMTEyZGY5MWVjMzkzODYxNTMyNjY4ZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MTdkNzBmZGJjYjFiYjA5ZWM1NDE4ODg4YTc5NjlmYTU0MGE4ZDc4Nw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YTU5NjA4NGVlMWFkYzMxYTUwMjYxNTk0NmI3NTQzNWI5OTgzZDlkZTM5MDk4
|
10
|
+
NDA5OGI3MzUxOTkyZGFiZWI4OTllY2RlM2Q4ODY3ZTc5ZmRjYTQ3MWYyMmRl
|
11
|
+
ODg0N2M1YjA1YjlmMmVlMTQ1MWM3OTAyMmZiNmFlN2Q0MDk2MmQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZDU5YWZmMzE3NzA4MDZhOGI0YmNkMWFjZDNjNTY2ZTdkZjFlODVjMzg2YmQy
|
14
|
+
YWM0MjY1ZDk4YzhmMTc2OTIyNmVkMTFjMjJhMzIzNGEwODc4ZmYxZTNkZGUw
|
15
|
+
OWJiZWYwYzRmNDMzNTQyZjdiOGU5NGY3YzM2ZTJjZTBlYTU2ZTM=
|
data/CHANGES
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
== 1.6.1 - 17-Jul-2013
|
2
|
+
* Automatically set the scheme to "http" if not present when performing
|
3
|
+
HTTP pings. See https://bugs.ruby-lang.org/issues/8645 for an issue
|
4
|
+
with the uri library that led to this change. Thanks go to Preston Lee
|
5
|
+
for the spot.
|
6
|
+
* Removed the windows/system_info dependency, since it added other
|
7
|
+
dependencies just to check the Windows version. Instead, I added a
|
8
|
+
helper file that adds some needed Windows functions using FFI.
|
9
|
+
* Added Rake as a development dependency and updated the Gemfile
|
10
|
+
source because Bundler. Thanks to Jean-Philippe Doyle for the patches.
|
11
|
+
* Added some warning text to the Net::Ping::External tests for users
|
12
|
+
who are using OpenDNS. In short, you will probably get test failures
|
13
|
+
and surprising true results for bad hosts.
|
14
|
+
|
15
|
+
== 1.6.0 - 19-Mar-2013
|
16
|
+
* Split out the ldap portion of the code into its own branch.
|
17
|
+
* Don't require resolv-replace on Ruby 1.9.3 or later.
|
18
|
+
* Now gets proxy information from the http_proxy, https_proxy, and
|
19
|
+
no_proxy environment variables and uses that when making requests.
|
20
|
+
Thanks go to Kevin Olbrich for the patch.
|
21
|
+
|
1
22
|
== 1.5.3 - 29-Feb-2012
|
2
23
|
* Removed the Windows::Console dependency and replaced it with FFI since there
|
3
24
|
were only two functions needed. This had the nice side effect of making it
|
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -9,7 +9,12 @@ namespace 'gem' do
|
|
9
9
|
desc 'Create the net-ping gem'
|
10
10
|
task :create => [:clean] do
|
11
11
|
spec = eval(IO.read('net-ping.gemspec'))
|
12
|
-
Gem::
|
12
|
+
if Gem::VERSION.to_f < 2.0
|
13
|
+
Gem::Builder.new(spec).build
|
14
|
+
else
|
15
|
+
require 'rubygems/package'
|
16
|
+
Gem::Package.build(spec)
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
desc 'Install the net-ping gem'
|
@@ -39,11 +44,6 @@ namespace 'example' do
|
|
39
44
|
task :udp do
|
40
45
|
ruby '-Ilib examples/example_pingudp.rb'
|
41
46
|
end
|
42
|
-
|
43
|
-
desc 'Run the ldap ping example program'
|
44
|
-
task :ldap do
|
45
|
-
ruby '-Ilib examples/example_pingldap.rb'
|
46
|
-
end
|
47
47
|
end
|
48
48
|
|
49
49
|
Rake::TestTask.new do |t|
|
@@ -89,12 +89,6 @@ namespace 'test' do
|
|
89
89
|
t.verbose = true
|
90
90
|
t.test_files = FileList['test/test_net_ping_wmi.rb']
|
91
91
|
end
|
92
|
-
|
93
|
-
Rake::TestTask.new('ldap') do |t|
|
94
|
-
t.warning = true
|
95
|
-
t.verbose = true
|
96
|
-
t.test_files = FileList['test/test_net_ping_ldap.rb']
|
97
|
-
end
|
98
92
|
end
|
99
93
|
|
100
94
|
task :default => :test
|
data/lib/net/ping.rb
CHANGED
@@ -9,10 +9,9 @@ require File.join(File.dirname(__FILE__), 'ping/udp')
|
|
9
9
|
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
|
-
require File.join(File.dirname(__FILE__), 'ping/ldap')
|
13
12
|
|
14
13
|
RbConfig = Config unless Object.const_defined?(:RbConfig)
|
15
14
|
|
16
|
-
if
|
15
|
+
if File::ALT_SEPARATOR
|
17
16
|
require File.join(File.dirname(__FILE__), 'ping/wmi')
|
18
17
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
extend FFI::Library
|
5
|
+
ffi_lib :kernel32
|
6
|
+
|
7
|
+
attach_function :GetVersion, [], :ulong
|
8
|
+
|
9
|
+
def version
|
10
|
+
version = GetVersion()
|
11
|
+
major = LOBYTE(LOWORD(version))
|
12
|
+
minor = HIBYTE(LOWORD(version))
|
13
|
+
eval("Float(#{major}.#{minor})")
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def LOWORD(l)
|
19
|
+
l & 0xffff
|
20
|
+
end
|
21
|
+
|
22
|
+
def LOBYTE(w)
|
23
|
+
w & 0xff
|
24
|
+
end
|
25
|
+
|
26
|
+
def HIBYTE(w)
|
27
|
+
w >> 8
|
28
|
+
end
|
29
|
+
|
30
|
+
module_function :version
|
31
|
+
end
|
data/lib/net/ping/http.rb
CHANGED
@@ -2,10 +2,11 @@ require File.join(File.dirname(__FILE__), 'ping')
|
|
2
2
|
require 'net/http'
|
3
3
|
require 'net/https'
|
4
4
|
require 'uri'
|
5
|
+
require 'open-uri'
|
5
6
|
|
6
7
|
# Force non-blocking Socket.getaddrinfo on Unix systems. Do not use on
|
7
8
|
# Windows because it (ironically) causes blocking problems.
|
8
|
-
unless File::ALT_SEPARATOR
|
9
|
+
unless File::ALT_SEPARATOR or RUBY_VERSION >= "1.9.3"
|
9
10
|
require 'resolv-replace'
|
10
11
|
end
|
11
12
|
|
@@ -33,6 +34,9 @@ module Net
|
|
33
34
|
# Use GET request instead HEAD. The default is false.
|
34
35
|
attr_accessor :get_request
|
35
36
|
|
37
|
+
# was this ping proxied?
|
38
|
+
attr_accessor :proxied
|
39
|
+
|
36
40
|
# Creates and returns a new Ping::HTTP object. The default port is the
|
37
41
|
# port associated with the URI. The default timeout is 5 seconds.
|
38
42
|
#
|
@@ -40,7 +44,7 @@ module Net
|
|
40
44
|
@follow_redirect = true
|
41
45
|
@redirect_limit = 5
|
42
46
|
@ssl_verify_mode = OpenSSL::SSL::VERIFY_NONE
|
43
|
-
@get_request
|
47
|
+
@get_request = false
|
44
48
|
|
45
49
|
port ||= URI.parse(uri).port if uri
|
46
50
|
|
@@ -60,10 +64,15 @@ module Net
|
|
60
64
|
# response is considered a failed ping.
|
61
65
|
#
|
62
66
|
# If no file or path is specified in the URI, then '/' is assumed.
|
67
|
+
# If no scheme is present in the URI, then 'http' is assumed.
|
63
68
|
#
|
64
69
|
def ping(host = @host)
|
65
70
|
super(host)
|
66
71
|
bool = false
|
72
|
+
|
73
|
+
# See https://bugs.ruby-lang.org/issues/8645
|
74
|
+
host = "http://#{host}" unless host.include?("http")
|
75
|
+
|
67
76
|
uri = URI.parse(host)
|
68
77
|
|
69
78
|
start_time = Time.now
|
@@ -75,7 +84,7 @@ module Net
|
|
75
84
|
elsif redirect?(response) # Check code, HTTPRedirection does not always work
|
76
85
|
if @follow_redirect
|
77
86
|
@warning = response.message
|
78
|
-
rlimit
|
87
|
+
rlimit = 0
|
79
88
|
|
80
89
|
while redirect?(response)
|
81
90
|
if rlimit >= redirect_limit
|
@@ -85,13 +94,13 @@ module Net
|
|
85
94
|
redirect = URI.parse(response['location'])
|
86
95
|
redirect = uri + redirect if redirect.relative?
|
87
96
|
response = do_ping(redirect)
|
88
|
-
rlimit
|
97
|
+
rlimit += 1
|
89
98
|
end
|
90
99
|
|
91
100
|
if response.is_a?(Net::HTTPSuccess)
|
92
101
|
bool = true
|
93
102
|
else
|
94
|
-
@warning
|
103
|
+
@warning = nil
|
95
104
|
@exception ||= response.message
|
96
105
|
end
|
97
106
|
|
@@ -120,25 +129,26 @@ module Net
|
|
120
129
|
|
121
130
|
def do_ping(uri)
|
122
131
|
response = nil
|
132
|
+
proxy = uri.find_proxy || URI.parse("")
|
123
133
|
begin
|
124
134
|
uri_path = uri.path.empty? ? '/' : uri.path
|
125
|
-
headers
|
135
|
+
headers = { }
|
126
136
|
headers["User-Agent"] = user_agent unless user_agent.nil?
|
127
137
|
Timeout.timeout(@timeout) do
|
128
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
129
|
-
|
130
|
-
if uri.scheme == 'https'
|
131
|
-
http.use_ssl = true
|
132
|
-
http.verify_mode = @ssl_verify_mode
|
133
|
-
end
|
134
|
-
|
138
|
+
http = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password).new(uri.host, uri.port)
|
139
|
+
@proxied = http.proxy?
|
135
140
|
if @get_request == true
|
136
141
|
request = Net::HTTP::Get.new(uri_path)
|
137
142
|
else
|
138
143
|
request = Net::HTTP::Head.new(uri_path)
|
139
144
|
end
|
140
145
|
|
141
|
-
|
146
|
+
if uri.scheme == 'https'
|
147
|
+
http.use_ssl = true
|
148
|
+
http.verify_mode = @ssl_verify_mode
|
149
|
+
end
|
150
|
+
|
151
|
+
response = http.start { |h| h.request(request) }
|
142
152
|
end
|
143
153
|
rescue Exception => err
|
144
154
|
@exception = err.message
|
data/lib/net/ping/icmp.rb
CHANGED
@@ -2,8 +2,7 @@ require File.join(File.dirname(__FILE__), 'ping')
|
|
2
2
|
|
3
3
|
if File::ALT_SEPARATOR
|
4
4
|
require 'win32/security'
|
5
|
-
require '
|
6
|
-
include Windows::SystemInfo
|
5
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
7
6
|
end
|
8
7
|
|
9
8
|
# The Net module serves as a namespace only.
|
@@ -32,7 +31,7 @@ module Net
|
|
32
31
|
def initialize(host=nil, port=nil, timeout=5)
|
33
32
|
raise 'requires root privileges' if Process.euid > 0
|
34
33
|
|
35
|
-
if File::ALT_SEPARATOR &&
|
34
|
+
if File::ALT_SEPARATOR && Windows.version >= 6
|
36
35
|
unless Win32::Security.elevated_security?
|
37
36
|
raise 'requires elevated security'
|
38
37
|
end
|
data/lib/net/ping/ping.rb
CHANGED
data/net-ping.gemspec
CHANGED
@@ -3,11 +3,11 @@ require 'rbconfig'
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'net-ping'
|
6
|
-
spec.version = '1.
|
6
|
+
spec.version = '1.6.1'
|
7
7
|
spec.license = 'Artistic 2.0'
|
8
8
|
spec.author = 'Daniel J. Berger'
|
9
9
|
spec.email = 'djberg96@gmail.com'
|
10
|
-
spec.homepage = '
|
10
|
+
spec.homepage = 'https://github.com/djberg96/net-ping'
|
11
11
|
spec.summary = 'A ping interface for Ruby.'
|
12
12
|
spec.test_file = 'test/test_net_ping.rb'
|
13
13
|
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
@@ -15,12 +15,11 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.rubyforge_project = 'shards'
|
16
16
|
spec.extra_rdoc_files = ['README', 'CHANGES', 'doc/ping.txt']
|
17
17
|
|
18
|
-
spec.add_dependency('net-ldap', '~> 0.2.2')
|
19
18
|
spec.add_dependency('ffi', '>= 1.0.0')
|
20
19
|
|
21
|
-
spec.add_development_dependency('test-unit', '>= 2.
|
20
|
+
spec.add_development_dependency('test-unit', '>= 2.5.0')
|
22
21
|
spec.add_development_dependency('fakeweb', '>= 1.3.0')
|
23
|
-
spec.add_development_dependency('
|
22
|
+
spec.add_development_dependency('rake')
|
24
23
|
|
25
24
|
if File::ALT_SEPARATOR && RUBY_PLATFORM != 'java'
|
26
25
|
spec.platform = Gem::Platform::CURRENT
|
@@ -28,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
28
27
|
spec.platform.version = nil
|
29
28
|
|
30
29
|
# Used primarily for icmp pings.
|
31
|
-
spec.add_development_dependency('win32-security', '>=
|
30
|
+
spec.add_development_dependency('win32-security', '>= 0.2.0')
|
32
31
|
|
33
32
|
if RUBY_VERSION.to_f < 1.9
|
34
33
|
spec.add_dependency('win32-open3', '>= 0.3.1')
|
data/test/test_net_ping.rb
CHANGED
@@ -12,10 +12,8 @@ require 'fakeweb'
|
|
12
12
|
|
13
13
|
if File::ALT_SEPARATOR
|
14
14
|
require 'win32/security'
|
15
|
-
require 'windows/system_info'
|
16
|
-
include Windows::SystemInfo
|
17
15
|
|
18
|
-
if
|
16
|
+
if Win32::Security.elevated_security?
|
19
17
|
require 'test_net_ping_icmp'
|
20
18
|
end
|
21
19
|
else
|
@@ -30,7 +28,7 @@ end
|
|
30
28
|
|
31
29
|
class TC_Net_Ping < Test::Unit::TestCase
|
32
30
|
def test_net_ping_version
|
33
|
-
assert_equal('1.
|
31
|
+
assert_equal('1.6.1', Net::Ping::VERSION)
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
@@ -3,11 +3,12 @@
|
|
3
3
|
#
|
4
4
|
# Test case for the Net::PingExternal class. Run this via the 'test' or
|
5
5
|
# 'test:external' rake task.
|
6
|
+
#
|
7
|
+
# WARNING: I've noticed that test failures will occur if you're using
|
8
|
+
# OpenDNS. This is apparently caused by them messing with upstream
|
9
|
+
# replies for advertising purposes.
|
6
10
|
#########################################################################
|
7
|
-
require '
|
8
|
-
gem 'test-unit'
|
9
|
-
|
10
|
-
require 'test/unit'
|
11
|
+
require 'test-unit'
|
11
12
|
require 'net/ping/external'
|
12
13
|
|
13
14
|
class TC_Net_Ping_External < Test::Unit::TestCase
|
data/test/test_net_ping_http.rb
CHANGED
@@ -4,25 +4,29 @@
|
|
4
4
|
# Test case for the Net::PingHTTP class. This should be run via the 'test' or
|
5
5
|
# 'test:http' Rake task.
|
6
6
|
#################################################################################
|
7
|
-
require '
|
8
|
-
|
9
|
-
|
10
|
-
require 'test/unit'
|
7
|
+
require 'test-unit'
|
8
|
+
require 'fakeweb'
|
11
9
|
require 'net/ping/http'
|
12
10
|
|
13
11
|
class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
14
12
|
def setup
|
13
|
+
ENV['http_proxy'] = ENV['https_proxy'] = ENV['no_proxy'] = nil
|
15
14
|
@uri = 'http://www.google.com/index.html'
|
16
15
|
@uri_https = 'https://encrypted.google.com'
|
16
|
+
@proxy = 'http://username:password@proxymoxie:3128'
|
17
|
+
FakeWeb.allow_net_connect = false
|
17
18
|
|
18
19
|
FakeWeb.register_uri(:get, @uri, :body => "PONG")
|
19
20
|
FakeWeb.register_uri(:head, @uri, :body => "PONG")
|
20
21
|
FakeWeb.register_uri(:head, @uri_https, :body => "PONG")
|
22
|
+
FakeWeb.register_uri(:get, @uri_https, :body => "PONG")
|
21
23
|
FakeWeb.register_uri(:head, "http://jigsaw.w3.org/HTTP/300/302.html",
|
22
24
|
:body => "PONG",
|
23
25
|
:location => "#{@uri}",
|
24
26
|
:status => ["302", "Found"])
|
25
27
|
|
28
|
+
FakeWeb.register_uri(:any, 'http://www.blabfoobarurghxxxx.com', :exception => SocketError)
|
29
|
+
|
26
30
|
@http = Net::Ping::HTTP.new(@uri, 80, 30)
|
27
31
|
@bad = Net::Ping::HTTP.new('http://www.blabfoobarurghxxxx.com') # One hopes not
|
28
32
|
end
|
@@ -175,6 +179,30 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
175
179
|
assert_true(@http.ping)
|
176
180
|
end
|
177
181
|
|
182
|
+
test 'ping with http proxy' do
|
183
|
+
ENV['http_proxy'] = "http://proxymoxie:3128"
|
184
|
+
@http = Net::Ping::HTTP.new(@uri)
|
185
|
+
@http.get_request = true
|
186
|
+
assert_true(@http.ping)
|
187
|
+
assert_true(@http.proxied)
|
188
|
+
end
|
189
|
+
|
190
|
+
test 'ping with https proxy' do
|
191
|
+
ENV['https_proxy'] = "http://proxymoxie:3128"
|
192
|
+
@http = Net::Ping::HTTP.new(@uri_https)
|
193
|
+
@http.get_request = true
|
194
|
+
assert_true(@http.ping)
|
195
|
+
assert_true(@http.proxied)
|
196
|
+
end
|
197
|
+
|
198
|
+
test 'ping with no_proxy' do
|
199
|
+
ENV['no_proxy'] = "google.com"
|
200
|
+
@http = Net::Ping::HTTP.new(@uri)
|
201
|
+
@http.get_request = true
|
202
|
+
assert_true(@http.ping)
|
203
|
+
assert_false(@http.proxied)
|
204
|
+
end
|
205
|
+
|
178
206
|
def teardown
|
179
207
|
@uri = nil
|
180
208
|
@http = nil
|
data/test/test_net_ping_icmp.rb
CHANGED
@@ -5,10 +5,7 @@
|
|
5
5
|
# with root privileges on UNIX systems. This should be run via the
|
6
6
|
# 'test' or 'test:icmp' Rake task.
|
7
7
|
#######################################################################
|
8
|
-
require '
|
9
|
-
gem 'test-unit'
|
10
|
-
|
11
|
-
require 'test/unit'
|
8
|
+
require 'test-unit'
|
12
9
|
require 'net/ping/icmp'
|
13
10
|
include Net
|
14
11
|
|
data/test/test_net_ping_tcp.rb
CHANGED
@@ -4,10 +4,7 @@
|
|
4
4
|
# Test case for the Net::PingTCP class. This test should be run via
|
5
5
|
# the 'test' or 'test:tcp' Rake task.
|
6
6
|
#####################################################################
|
7
|
-
require '
|
8
|
-
gem 'test-unit'
|
9
|
-
|
10
|
-
require 'test/unit'
|
7
|
+
require 'test-unit'
|
11
8
|
require 'net/ping/tcp'
|
12
9
|
include Net
|
13
10
|
|
data/test/test_net_ping_udp.rb
CHANGED
@@ -7,10 +7,7 @@
|
|
7
7
|
# If someone could provide me a host where a udp ping actually
|
8
8
|
# works (with a service check), I would appreciate it. :)
|
9
9
|
########################################################################
|
10
|
-
require '
|
11
|
-
gem 'test-unit'
|
12
|
-
|
13
|
-
require 'test/unit'
|
10
|
+
require 'test-unit'
|
14
11
|
require 'net/ping/udp'
|
15
12
|
|
16
13
|
class TC_Net_Ping_UDP < Test::Unit::TestCase
|
data/test/test_net_ping_wmi.rb
CHANGED
@@ -5,18 +5,15 @@
|
|
5
5
|
# run MS Windows. You should run this test via the 'test' or
|
6
6
|
# 'test:wmi' Rake task.
|
7
7
|
#######################################################################
|
8
|
-
require '
|
9
|
-
gem 'test-unit'
|
10
|
-
|
11
|
-
require 'test/unit'
|
8
|
+
require 'test-unit'
|
12
9
|
require 'net/ping/wmi'
|
13
10
|
include Net
|
14
11
|
|
15
12
|
class TC_Ping_WMI < Test::Unit::TestCase
|
16
13
|
def self.startup
|
17
|
-
@@windows =
|
14
|
+
@@windows = File::ALT_SEPARATOR
|
18
15
|
end
|
19
|
-
|
16
|
+
|
20
17
|
def setup
|
21
18
|
@host = "www.ruby-lang.org"
|
22
19
|
@wmi = Ping::WMI.new(@host) if @@windows
|
@@ -55,11 +52,11 @@ class TC_Ping_WMI < Test::Unit::TestCase
|
|
55
52
|
assert_boolean(@wmi.ping?)
|
56
53
|
assert_boolean(@wmi.ping?(@host))
|
57
54
|
end
|
58
|
-
|
55
|
+
|
59
56
|
def test_ping_expected_failure
|
60
57
|
omit_unless(@@windows, 'skipped on Unix platforms')
|
61
58
|
assert_false(Ping::WMI.new('bogus').ping?)
|
62
|
-
assert_false(Ping::WMI.new('http://www.asdfhjklasdfhlkj.com').ping?)
|
59
|
+
assert_false(Ping::WMI.new('http://www.asdfhjklasdfhlkj.com').ping?)
|
63
60
|
end
|
64
61
|
|
65
62
|
def test_exception
|
@@ -77,7 +74,7 @@ class TC_Ping_WMI < Test::Unit::TestCase
|
|
77
74
|
@host = nil
|
78
75
|
@wmi = nil
|
79
76
|
end
|
80
|
-
|
77
|
+
|
81
78
|
def self.shutdown
|
82
79
|
@@windows = nil
|
83
80
|
end
|
metadata
CHANGED
@@ -1,156 +1,106 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ping
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 5
|
9
|
-
- 3
|
10
|
-
version: 1.5.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.6.1
|
11
5
|
platform: x86-mingw32
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Daniel J. Berger
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
name: net-ldap
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 19
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 2
|
32
|
-
- 2
|
33
|
-
version: 0.2.2
|
34
|
-
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-07-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
37
14
|
name: ffi
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 23
|
45
|
-
segments:
|
46
|
-
- 1
|
47
|
-
- 0
|
48
|
-
- 0
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
49
19
|
version: 1.0.0
|
50
20
|
type: :runtime
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: test-unit
|
54
21
|
prerelease: false
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-unit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.5.0
|
66
34
|
type: :development
|
67
|
-
version_requirements: *id003
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
|
-
name: fakeweb
|
70
35
|
prerelease: false
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.5.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fakeweb
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
81
47
|
version: 1.3.0
|
82
48
|
type: :development
|
83
|
-
version_requirements: *id004
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: fakeldap
|
86
49
|
prerelease: false
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
98
62
|
type: :development
|
99
|
-
version_requirements: *id005
|
100
|
-
- !ruby/object:Gem::Dependency
|
101
|
-
name: win32-security
|
102
63
|
prerelease: false
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: win32-security
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.2.0
|
114
76
|
type: :development
|
115
|
-
version_requirements: *id006
|
116
|
-
- !ruby/object:Gem::Dependency
|
117
|
-
name: win32-open3
|
118
77
|
prerelease: false
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
- 0
|
127
|
-
- 3
|
128
|
-
- 1
|
129
|
-
version: 0.3.1
|
130
|
-
type: :runtime
|
131
|
-
version_requirements: *id007
|
132
|
-
description: " The net-ping library provides a ping interface for Ruby. It includes\n separate TCP, HTTP, LDAP, ICMP, UDP, WMI (for Windows) and external ping\n classes.\n"
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.2.0
|
83
|
+
description: ! " The net-ping library provides a ping interface for Ruby. It includes\n
|
84
|
+
\ separate TCP, HTTP, LDAP, ICMP, UDP, WMI (for Windows) and external ping\n classes.\n"
|
133
85
|
email: djberg96@gmail.com
|
134
86
|
executables: []
|
135
|
-
|
136
87
|
extensions: []
|
137
|
-
|
138
|
-
extra_rdoc_files:
|
88
|
+
extra_rdoc_files:
|
139
89
|
- README
|
140
90
|
- CHANGES
|
141
91
|
- doc/ping.txt
|
142
|
-
files:
|
92
|
+
files:
|
143
93
|
- CHANGES
|
144
94
|
- doc/ping.txt
|
145
95
|
- examples/example_pingexternal.rb
|
146
96
|
- examples/example_pinghttp.rb
|
147
|
-
- examples/example_pingldap.rb
|
148
97
|
- examples/example_pingtcp.rb
|
149
98
|
- examples/example_pingudp.rb
|
99
|
+
- Gemfile
|
150
100
|
- lib/net/ping/external.rb
|
101
|
+
- lib/net/ping/helper.rb
|
151
102
|
- lib/net/ping/http.rb
|
152
103
|
- lib/net/ping/icmp.rb
|
153
|
-
- lib/net/ping/ldap.rb
|
154
104
|
- lib/net/ping/ping.rb
|
155
105
|
- lib/net/ping/tcp.rb
|
156
106
|
- lib/net/ping/udp.rb
|
@@ -164,42 +114,32 @@ files:
|
|
164
114
|
- test/test_net_ping_external.rb
|
165
115
|
- test/test_net_ping_http.rb
|
166
116
|
- test/test_net_ping_icmp.rb
|
167
|
-
- test/test_net_ping_ldap.rb
|
168
117
|
- test/test_net_ping_tcp.rb
|
169
118
|
- test/test_net_ping_udp.rb
|
170
119
|
- test/test_net_ping_wmi.rb
|
171
|
-
homepage:
|
172
|
-
licenses:
|
120
|
+
homepage: https://github.com/djberg96/net-ping
|
121
|
+
licenses:
|
173
122
|
- Artistic 2.0
|
123
|
+
metadata: {}
|
174
124
|
post_install_message:
|
175
125
|
rdoc_options: []
|
176
|
-
|
177
|
-
require_paths:
|
126
|
+
require_paths:
|
178
127
|
- lib
|
179
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
none: false
|
190
|
-
requirements:
|
191
|
-
- - ">="
|
192
|
-
- !ruby/object:Gem::Version
|
193
|
-
hash: 3
|
194
|
-
segments:
|
195
|
-
- 0
|
196
|
-
version: "0"
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ! '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
197
138
|
requirements: []
|
198
|
-
|
199
139
|
rubyforge_project: shards
|
200
|
-
rubygems_version:
|
140
|
+
rubygems_version: 2.0.3
|
201
141
|
signing_key:
|
202
|
-
specification_version:
|
142
|
+
specification_version: 4
|
203
143
|
summary: A ping interface for Ruby.
|
204
|
-
test_files:
|
144
|
+
test_files:
|
205
145
|
- test/test_net_ping.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
########################################################################
|
2
|
-
# example_pingldap.rb
|
3
|
-
#
|
4
|
-
# A short sample program demonstrating an ldap ping. You can run
|
5
|
-
# this program via the example:ldap task. Modify as you see fit.
|
6
|
-
########################################################################
|
7
|
-
require 'net/ping/ldap'
|
8
|
-
|
9
|
-
good = 'ldap://localhost'
|
10
|
-
bad = 'ldap://example.com'
|
11
|
-
|
12
|
-
puts "== Good ping (if you have an ldap server at #{good})"
|
13
|
-
|
14
|
-
p1 = Net::Ping::LDAP.new(good)
|
15
|
-
p p1.ping?
|
16
|
-
|
17
|
-
puts "== Bad ping"
|
18
|
-
|
19
|
-
p2 = Net::Ping::LDAP.new(bad)
|
20
|
-
p p2.ping?
|
21
|
-
p p2.warning
|
22
|
-
p p2.exception
|
data/lib/net/ping/ldap.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'ping')
|
2
|
-
require 'net/ldap'
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
|
6
|
-
# The Net module serves as a namespace only.
|
7
|
-
module Net
|
8
|
-
|
9
|
-
# The Ping::LDAP class encapsulates methods for LDAP pings.
|
10
|
-
class Ping::LDAP < Ping
|
11
|
-
|
12
|
-
# uri contains the URI object for the request
|
13
|
-
#
|
14
|
-
attr_accessor :uri
|
15
|
-
|
16
|
-
# username and password may be set for ping using
|
17
|
-
# an authenticated LDAP bind
|
18
|
-
#
|
19
|
-
attr_accessor :username
|
20
|
-
attr_accessor :password
|
21
|
-
|
22
|
-
# set/get the encryption method. By default nil,
|
23
|
-
# but may be set to :simple_tls
|
24
|
-
#
|
25
|
-
attr_accessor :encryption
|
26
|
-
def encryption=(value)
|
27
|
-
@encryption = (value.is_a? Symbol) ? value : value.to_sym
|
28
|
-
end
|
29
|
-
|
30
|
-
# Creates and returns a new Ping::LDAP object.
|
31
|
-
# The default +timeout+ is 5 seconds.
|
32
|
-
#
|
33
|
-
# +uri+ string is expected to be a full URI with scheme (ldap/ldaps)
|
34
|
-
# and optionally the port (else default port is assumed) e.g.
|
35
|
-
# ldap://my.ldap.host.com
|
36
|
-
# ldap://my.ldap.host.com:1389
|
37
|
-
# ldaps://my.ldap.host.com
|
38
|
-
# ldaps://my.ldap.host.com:6636
|
39
|
-
#
|
40
|
-
# If a plain hostname is provided as the +uri+, a default port of 389 is assumed
|
41
|
-
#
|
42
|
-
def initialize(uri=nil, timeout=5)
|
43
|
-
host, port = decode_uri(uri)
|
44
|
-
super(host, port, timeout)
|
45
|
-
end
|
46
|
-
|
47
|
-
# method used to decode uri string
|
48
|
-
#
|
49
|
-
def decode_uri(value)
|
50
|
-
@uri = URI.parse(value)
|
51
|
-
if uri.scheme =~ /ldap/
|
52
|
-
p = @port = uri.port
|
53
|
-
h = @host = uri.host
|
54
|
-
@encryption = uri.scheme=='ldaps' ? :simple_tls : nil
|
55
|
-
else
|
56
|
-
h = value
|
57
|
-
p = 389
|
58
|
-
end
|
59
|
-
[h, p]
|
60
|
-
end
|
61
|
-
|
62
|
-
# constructs the LDAP configuration structure
|
63
|
-
#
|
64
|
-
def config
|
65
|
-
{
|
66
|
-
:host => uri.host,
|
67
|
-
:port => uri.port,
|
68
|
-
:encryption => encryption
|
69
|
-
}.merge(
|
70
|
-
(username && password) ?
|
71
|
-
{ :auth => {:method => :simple, :username => username, :password => password} } :
|
72
|
-
{ :auth => {:method => :anonymous} }
|
73
|
-
)
|
74
|
-
end
|
75
|
-
|
76
|
-
# perform ping, optionally providing the ping destination uri
|
77
|
-
#
|
78
|
-
def ping(host = nil)
|
79
|
-
decode_uri(host) if host
|
80
|
-
super(@host)
|
81
|
-
|
82
|
-
bool = false
|
83
|
-
|
84
|
-
start_time = Time.now
|
85
|
-
|
86
|
-
begin
|
87
|
-
Timeout.timeout(@timeout) do
|
88
|
-
Net::LDAP.new( config ).bind
|
89
|
-
end
|
90
|
-
rescue Net::LDAP::LdapError => e
|
91
|
-
@exception = e.message
|
92
|
-
rescue Exception => e
|
93
|
-
@exception = e.message
|
94
|
-
else
|
95
|
-
bool = true
|
96
|
-
end
|
97
|
-
|
98
|
-
# There is no duration if the ping failed
|
99
|
-
@duration = Time.now - start_time if bool
|
100
|
-
|
101
|
-
bool
|
102
|
-
end
|
103
|
-
|
104
|
-
alias ping? ping
|
105
|
-
alias pingecho ping
|
106
|
-
end
|
107
|
-
end
|
data/test/test_net_ping_ldap.rb
DELETED
@@ -1,200 +0,0 @@
|
|
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
|