landrush 1.3.1 → 1.3.2
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +0 -6
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.adoc +2 -6
- data/Gemfile +1 -1
- data/README.adoc +1 -1
- data/doc/Development.adoc +1 -1
- data/features/dns_resolution.feature +1 -1
- data/features/step_definitions/landrush_custom_steps.rb +4 -4
- data/lib/landrush/cap/host/windows/configure_visibility_on_host.rb +93 -41
- data/lib/landrush/version.rb +1 -1
- data/test/landrush/cap/host/windows/configure_visibility_on_host_test.rb +102 -56
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53b5666e9dffc5e0dfdc9992ecf961380f115ad40d2286cdfee46fcb00dac52b
|
4
|
+
data.tar.gz: bac8ef15e393c51e6833aa0797e83d18b4807cab8174c1f3c9c39c8f0a66d03b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d145a063094fbf0cafd6f3a18e771d0308d738f634e76dc06f3c473a7d15971a3d288444f1ef938db71df902a57952a049561a64e12a55589ecdd8e5ca1985f0
|
7
|
+
data.tar.gz: 5b8fb77e369b300ec7bb18982085d363fb5d7c4b8ed643e50fe8663dc66759200358034b79b6ac8c017a65651453fad845b2026ed0ada06619c178b2834174c5
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -10,12 +10,6 @@
|
|
10
10
|
Metrics/AbcSize:
|
11
11
|
Max: 47
|
12
12
|
|
13
|
-
# Offense count: 13
|
14
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
-
# ExcludedMethods: refine
|
16
|
-
Metrics/BlockLength:
|
17
|
-
Max: 89
|
18
|
-
|
19
13
|
# Offense count: 3
|
20
14
|
# Configuration parameters: CountComments.
|
21
15
|
Metrics/ClassLength:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## [1.3.2] - 2019-05-06
|
2
|
+
|
3
|
+
- Issue [#339](https://github.com/vagrant-landrush/landrush/issues/339) - Update link to TravisCI badge in README
|
4
|
+
- Issue [#344](https://github.com/vagrant-landrush/landrush/issues/344) - Unable to determine network interface on non-English Windows
|
5
|
+
- Issue [#346](https://github.com/vagrant-landrush/landrush/issues/346) - Upgrade Vagrant development version
|
6
|
+
|
1
7
|
## [1.3.1] - 2018-12-04
|
2
8
|
|
3
9
|
- Issue [#11](https://github.com/vagrant-landrush/landrush/issues/11) - Landrush prevents the machine from reaching internet
|
data/CONTRIBUTING.adoc
CHANGED
@@ -83,10 +83,6 @@ $ git push origin master
|
|
83
83
|
|
84
84
|
== Maintainers
|
85
85
|
|
86
|
-
*
|
87
|
-
* Eric Sorenson (@ahpook)
|
88
|
-
* Florian Holzhauer (@fh)
|
86
|
+
* Davi Koscianski Vidal (@davividal)
|
89
87
|
* Hardy Ferentschik (@hferentschik)
|
90
|
-
|
91
|
-
* Paul Hinze (@phinze)
|
92
|
-
* Reto Kaiser (@njam)
|
88
|
+
|
data/Gemfile
CHANGED
data/README.adoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
:toc:
|
3
3
|
:toc-placement!:
|
4
4
|
|
5
|
-
https://travis-ci.org/vagrant-landrush/landrush[
|
5
|
+
image:https://travis-ci.org/vagrant-landrush/landrush.svg?branch=master["Build Status", link="https://travis-ci.org/vagrant-landrush/landrush"]
|
6
6
|
https://ci.appveyor.com/project/hferentschik/landrush-3agrx/branch/master[image:https://ci.appveyor.com/api/projects/status/3iv8sv5v73s15mt6/branch/master?svg=true[Build Status]]
|
7
7
|
image:https://badge.fury.io/rb/landrush.svg["Gem Version", link="https://badge.fury.io/rb/landrush"]
|
8
8
|
|
data/doc/Development.adoc
CHANGED
@@ -127,7 +127,7 @@ If you have an account you can setup the API key using:
|
|
127
127
|
|
128
128
|
[source,bash]
|
129
129
|
----
|
130
|
-
curl -u
|
130
|
+
curl -u <user> https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials
|
131
131
|
----
|
132
132
|
====
|
133
133
|
|
@@ -14,24 +14,24 @@ Then(/^the hostname "([^"]+)" should resolve to "([^"]+)" on the host$/) do |hos
|
|
14
14
|
end
|
15
15
|
|
16
16
|
Then(/^the hostname "([^"]+)" should resolve to "([^"]+)" on the guest/) do |host, ip|
|
17
|
-
|
17
|
+
run_command("bundle exec vagrant ssh -c \"dig +short '#{host}' A\"")
|
18
18
|
expect(last_command_started).to have_output(/^#{ip}$/)
|
19
19
|
end
|
20
20
|
|
21
21
|
Then(/^the host visible IP address of the guest is the IP of interface "([^"]+)"/) do |interface|
|
22
22
|
cmd = "bundle exec vagrant ssh -c \"ip addr list #{interface} | grep 'inet ' | cut -d' ' -f6| cut -d/ -f1\""
|
23
|
-
|
23
|
+
run_command(cmd)
|
24
24
|
expect(last_command_started).to have_output(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
|
25
25
|
|
26
26
|
ip = last_command_started.output.split("\n").last
|
27
27
|
|
28
|
-
|
28
|
+
run_command('bundle exec vagrant landrush list')
|
29
29
|
|
30
30
|
expect(last_command_started).to have_output(/#{ip}$/)
|
31
31
|
end
|
32
32
|
|
33
33
|
Then(/^Landrush is( not)? running$/) do |negated|
|
34
|
-
|
34
|
+
run_command('bundle exec vagrant landrush status')
|
35
35
|
if negated
|
36
36
|
expect(last_command_started).to have_output(/Daemon status: stopped/)
|
37
37
|
else
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# This file needs to be able to execute out of the Vagrant context. Do not require any non core or non relative files
|
2
2
|
require 'ipaddr'
|
3
|
+
require 'English'
|
3
4
|
require_relative '../../../util/retry'
|
4
5
|
|
5
6
|
module Landrush
|
@@ -19,46 +20,101 @@ module Landrush
|
|
19
20
|
|
20
21
|
# If this registry query succeeds we assume we have Admin rights
|
21
22
|
# http://stackoverflow.com/questions/8268154/run-ruby-script-in-elevated-mode/27954953
|
23
|
+
# https://stackoverflow.com/a/2400/1040571
|
24
|
+
# "[...] $?, which is the same as $CHILD_STATUS,
|
25
|
+
# accesses the status of the last system executed command if you use
|
26
|
+
# the backticks, system() or %x{} [...]"
|
22
27
|
def admin_mode?
|
23
|
-
|
28
|
+
`reg query HKU\\S-1-5-19 2>&1`
|
29
|
+
$CHILD_STATUS.exitstatus.zero?
|
24
30
|
end
|
25
31
|
|
26
|
-
# Given an IP determines the network
|
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
|
-
|
32
|
+
# Given an IP determines the network adapter guid, if any.
|
33
|
+
# We can't use netsh due to its output being locale dependant.
|
34
|
+
# Using Windows registry we achieve the same result of netsh in
|
35
|
+
# whatever language Windows is.
|
36
|
+
def get_network_guid(address)
|
37
|
+
address = IPAddr.new(address.to_s)
|
38
|
+
|
39
|
+
interfaces do |interface_guid|
|
40
|
+
interface = open_interface("#{INTERFACES}\\#{interface_guid}")
|
41
|
+
if_ip, if_mask = interface_address(interface)
|
42
|
+
|
43
|
+
next if if_ip.nil?
|
44
|
+
|
45
|
+
if_net = IPAddr.new("#{if_ip}/#{if_mask}")
|
46
|
+
return interface_guid if if_net.include?(address)
|
47
|
+
end
|
48
|
+
rescue StandardError
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
# Fetch interfaces from registry
|
55
|
+
# This is a separate method to make testing easier
|
56
|
+
def interfaces
|
57
|
+
Win32::Registry::HKEY_LOCAL_MACHINE.open(INTERFACES) do |interfaces|
|
58
|
+
interfaces.each_key do |guid, _|
|
59
|
+
yield guid
|
54
60
|
end
|
55
61
|
end
|
56
|
-
|
62
|
+
end
|
57
63
|
|
58
|
-
|
64
|
+
# Opens an interface key from registry
|
65
|
+
# This is a separate method to make testing easier
|
66
|
+
def open_interface(guid_path)
|
67
|
+
Win32::Registry::HKEY_LOCAL_MACHINE.open(guid_path)
|
59
68
|
end
|
60
69
|
|
61
|
-
|
70
|
+
# Fetches IP/mask info from registry from a given registry entry
|
71
|
+
# This is a separate method to make testing easier
|
72
|
+
#
|
73
|
+
# The registry may look like this:
|
74
|
+
# {46666082-84ff-4888-8d75-31079e325934}:
|
75
|
+
# EnableDHCP => 1
|
76
|
+
# DhcpIPAddress => 172.29.5.24
|
77
|
+
# DhcpSubnetMask => 255.255.254.0
|
78
|
+
# {61e509a1-cffa-4b7f-8e7f-5a6991deba2b}:
|
79
|
+
# EnableDHCP => 0
|
80
|
+
# IPAddress => ["192.168.56.1"]
|
81
|
+
# SubnetMask => ["255.255.255.0"]
|
82
|
+
# {6c902ac7-4845-46d4-843e-2707e2270b0d}:
|
83
|
+
# EnableDHCP => 0
|
84
|
+
# IPAddress => ["0.0.0.0"]
|
85
|
+
# SubnetMask => ["0.0.0.0"]
|
86
|
+
# {6d2f3579-bc95-4a18-bed5-fb8b87b8673b}:
|
87
|
+
# EnableDHCP => 0
|
88
|
+
#
|
89
|
+
# If a given interface does not have an address, win32/registry
|
90
|
+
# will trow an Win32::Registry::Error (which inherits directly from StandardError).
|
91
|
+
def interface_address(interface)
|
92
|
+
dhcp_enabled = interface.read('EnableDHCP')[1]
|
93
|
+
|
94
|
+
if dhcp_enabled
|
95
|
+
if_ip = interface.read('DhcpIPAddress')[1]
|
96
|
+
if_mask = interface.read('DhcpSubnetMask')[1]
|
97
|
+
else
|
98
|
+
if_ip = interface.read('IPAddress')[1]
|
99
|
+
if_mask = interface.read('SubnetMask')[1]
|
100
|
+
end
|
101
|
+
|
102
|
+
if if_ip.is_a? Array
|
103
|
+
if_ip = if_ip[0]
|
104
|
+
end
|
105
|
+
|
106
|
+
if if_mask.is_a? Array
|
107
|
+
if_mask = if_mask[0]
|
108
|
+
end
|
109
|
+
|
110
|
+
if if_ip == '0.0.0.0'
|
111
|
+
if_ip, if_mask = nil
|
112
|
+
end
|
113
|
+
|
114
|
+
[if_ip, if_mask]
|
115
|
+
rescue StandardError
|
116
|
+
[nil, nil]
|
117
|
+
end
|
62
118
|
|
63
119
|
# Checks that all required tools are on the PATH and that the Wired AutoConfig service is started
|
64
120
|
def ensure_prerequisites
|
@@ -92,19 +148,15 @@ module Landrush
|
|
92
148
|
# Need to defer loading to ensure cross OS compatibility
|
93
149
|
require 'win32/registry'
|
94
150
|
if admin_mode?
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
else
|
100
|
-
info("adding Landrush'es DNS server to network '#{network_name}' using DNS IP '#{ip}'' and search domain '#{tld}'")
|
101
|
-
end
|
102
|
-
network_guid = get_guid(network_name)
|
151
|
+
address = IPAddr.new(ip)
|
152
|
+
|
153
|
+
network_guid = get_network_guid(address)
|
154
|
+
|
103
155
|
if network_guid.nil?
|
104
156
|
info("unable to determine network GUID for #{ip}. DNS on host cannot be configured. Try manual configuration.")
|
105
157
|
return
|
106
158
|
end
|
107
|
-
interface_path = INTERFACES + "
|
159
|
+
interface_path = INTERFACES + "\\#{network_guid}"
|
108
160
|
Win32::Registry::HKEY_LOCAL_MACHINE.open(interface_path, Win32::Registry::KEY_ALL_ACCESS) do |reg|
|
109
161
|
reg['NameServer'] = '127.0.0.1'
|
110
162
|
reg['Domain'] = tld
|
data/lib/landrush/version.rb
CHANGED
@@ -21,49 +21,7 @@ DOT_3_SVC_STOPPED = 'SERVICE_NAME: dot3svc
|
|
21
21
|
WAIT_HINT : 0x0
|
22
22
|
'.freeze
|
23
23
|
|
24
|
-
|
25
|
-
Configuration for interface "VirtualBox Host-Only Network #1"
|
26
|
-
DHCP enabled: No
|
27
|
-
IP Address: 192.168.99.1
|
28
|
-
Subnet Prefix: 192.168.99.0/24 (mask 255.255.255.0)
|
29
|
-
InterfaceMetric: 25
|
30
|
-
Statically Configured DNS Servers: None
|
31
|
-
Register with which suffix: Primary only
|
32
|
-
Statically Configured WINS Servers: None
|
33
|
-
|
34
|
-
Configuration for interface "Ethernet"
|
35
|
-
DHCP enabled: Yes
|
36
|
-
IP Address: 192.168.1.193
|
37
|
-
Subnet Prefix: 192.168.1.0/24 (mask 255.255.255.0)
|
38
|
-
Default Gateway: 192.168.1.1
|
39
|
-
Gateway Metric: 0
|
40
|
-
InterfaceMetric: 35
|
41
|
-
DNS servers configured through DHCP: 192.168.1.1
|
42
|
-
Register with which suffix: Primary only
|
43
|
-
WINS servers configured through DHCP: None
|
44
|
-
|
45
|
-
Configuration for interface "Loopback Pseudo-Interface 1"
|
46
|
-
DHCP enabled: No
|
47
|
-
IP Address: 127.0.0.1
|
48
|
-
Subnet Prefix: 127.0.0.0/8 (mask 255.0.0.0)
|
49
|
-
InterfaceMetric: 75
|
50
|
-
Statically Configured DNS Servers: None
|
51
|
-
Register with which suffix: Primary only
|
52
|
-
Statically Configured WINS Servers: None
|
53
|
-
'.freeze
|
54
|
-
|
55
|
-
NETSH_EXAMPLE_SINGLE_INTERFACE = '
|
56
|
-
Configuration for interface "Ethernet"
|
57
|
-
DHCP enabled: Yes
|
58
|
-
IP Address: 192.168.1.193
|
59
|
-
Subnet Prefix: 192.168.1.0/24 (mask 255.255.255.0)
|
60
|
-
Default Gateway: 192.168.1.1
|
61
|
-
Gateway Metric: 0
|
62
|
-
InterfaceMetric: 35
|
63
|
-
DNS servers configured through DHCP: 192.168.1.1
|
64
|
-
Register with which suffix: Primary only
|
65
|
-
WINS servers configured through DHCP: None
|
66
|
-
'.freeze
|
24
|
+
NETWORK_GUIDS = %w[{1abb8efe-c0d5-4ddf-8e29-eae8499e92ba} {34d34575-bc0d-4ca7-8571-97bccc35b437} {46666082-84ff-4888-8d75-31079e325934}].freeze
|
67
25
|
|
68
26
|
module Landrush
|
69
27
|
module Cap
|
@@ -107,31 +65,119 @@ module Landrush
|
|
107
65
|
end
|
108
66
|
end
|
109
67
|
|
110
|
-
describe '#
|
111
|
-
it '
|
112
|
-
ConfigureVisibilityOnHost.expects(
|
113
|
-
|
68
|
+
describe '#get_network_guid' do
|
69
|
+
it 'should not be nil for IPAddr' do
|
70
|
+
ConfigureVisibilityOnHost.expects(:interfaces).multiple_yields(*NETWORK_GUIDS)
|
71
|
+
|
72
|
+
interface = MiniTest::Mock.new
|
73
|
+
interface.expect(:read, [0, false], ['EnableDHCP'])
|
74
|
+
interface.expect(:read, [0, '172.16.1.193'], ['IPAddress'])
|
75
|
+
interface.expect(:read, [0, '255.0.0.0'], ['SubnetMask'])
|
76
|
+
ConfigureVisibilityOnHost.expects(:open_interface).returns(interface)
|
77
|
+
|
78
|
+
address = IPAddr.new('172.28.128.3/32')
|
79
|
+
expect(ConfigureVisibilityOnHost.get_network_guid(address)).wont_be_nil
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should take into account that registry sometimes stores multiple IPs' do
|
83
|
+
ConfigureVisibilityOnHost.expects(:interfaces).yields(NETWORK_GUIDS[0])
|
84
|
+
|
85
|
+
interface = MiniTest::Mock.new
|
86
|
+
interface.expect(:read, [0, false], ['EnableDHCP'])
|
87
|
+
interface.expect(:read, [0, ['192.168.1.193']], ['IPAddress'])
|
88
|
+
interface.expect(:read, [0, ['255.255.255.0']], ['SubnetMask'])
|
89
|
+
ConfigureVisibilityOnHost.expects(:open_interface).returns(interface)
|
90
|
+
expect(ConfigureVisibilityOnHost.get_network_guid('192.168.1.193')).must_equal('{1abb8efe-c0d5-4ddf-8e29-eae8499e92ba}')
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should ignore 0.0.0.0 interfaces' do
|
94
|
+
ConfigureVisibilityOnHost.expects(:interfaces).multiple_yields(*NETWORK_GUIDS)
|
95
|
+
|
96
|
+
interface1 = MiniTest::Mock.new
|
97
|
+
interface1.expect(:read, [0, false], ['EnableDHCP'])
|
98
|
+
interface1.expect(:read, [0, '0.0.0.0'], ['IPAddress'])
|
99
|
+
interface1.expect(:read, [0, '0.0.0.0'], ['SubnetMask'])
|
100
|
+
interface2 = MiniTest::Mock.new
|
101
|
+
interface2.expect(:read, [0, false], ['EnableDHCP'])
|
102
|
+
interface2.expect(:read, [0, '192.168.1.193'], ['IPAddress'])
|
103
|
+
interface2.expect(:read, [0, '255.255.255.0'], ['SubnetMask'])
|
104
|
+
ConfigureVisibilityOnHost.expects(:open_interface).returns(interface1, interface2, interface1).at_most(3)
|
105
|
+
|
106
|
+
expect(ConfigureVisibilityOnHost.get_network_guid('192.168.1.193')).must_equal('{34d34575-bc0d-4ca7-8571-97bccc35b437}')
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'returns the interface guid for matching static IP' do
|
110
|
+
ConfigureVisibilityOnHost.expects(:interfaces).multiple_yields(*NETWORK_GUIDS)
|
111
|
+
|
112
|
+
interface1 = MiniTest::Mock.new
|
113
|
+
interface1.expect(:read, [0, false], ['EnableDHCP'])
|
114
|
+
interface1.expect(:read, [0, '10.42.42.42'], ['IPAddress'])
|
115
|
+
interface1.expect(:read, [0, '255.0.0.0'], ['SubnetMask'])
|
116
|
+
interface2 = MiniTest::Mock.new
|
117
|
+
interface2.expect(:read, [0, false], ['EnableDHCP'])
|
118
|
+
interface2.expect(:read, [0, '192.168.1.193'], ['IPAddress'])
|
119
|
+
interface2.expect(:read, [0, '255.255.255.0'], ['SubnetMask'])
|
120
|
+
ConfigureVisibilityOnHost.expects(:open_interface).returns(interface1, interface2).at_most(2)
|
121
|
+
|
122
|
+
expect(ConfigureVisibilityOnHost.get_network_guid('192.168.1.193')).must_equal('{34d34575-bc0d-4ca7-8571-97bccc35b437}')
|
114
123
|
end
|
115
124
|
|
116
125
|
it 'returns nil for non matching IP' do
|
117
|
-
ConfigureVisibilityOnHost.expects(
|
118
|
-
|
126
|
+
ConfigureVisibilityOnHost.expects(:interfaces).multiple_yields(*NETWORK_GUIDS)
|
127
|
+
|
128
|
+
interface1 = MiniTest::Mock.new
|
129
|
+
interface1.expect(:read, [0, false], ['EnableDHCP'])
|
130
|
+
interface1.expect(:read, [0, '10.42.42.42'], ['IPAddress'])
|
131
|
+
interface1.expect(:read, [0, '255.0.0.0'], ['SubnetMask'])
|
132
|
+
interface2 = MiniTest::Mock.new
|
133
|
+
interface2.expect(:read, [0, false], ['EnableDHCP'])
|
134
|
+
interface2.expect(:read, [0, '192.168.1.193'], ['IPAddress'])
|
135
|
+
interface2.expect(:read, [0, '255.255.255.0'], ['SubnetMask'])
|
136
|
+
interface3 = MiniTest::Mock.new
|
137
|
+
interface3.expect(:read, [0, false], ['EnableDHCP'])
|
138
|
+
interface3.expect(:read, [0, '172.16.1.193'], ['IPAddress'])
|
139
|
+
interface3.expect(:read, [0, '255.255.0.0'], ['SubnetMask'])
|
140
|
+
ConfigureVisibilityOnHost.expects(:open_interface).returns(interface1, interface2, interface3).at_most(3)
|
141
|
+
expect(ConfigureVisibilityOnHost.get_network_guid('42.42.42.42')).must_be_nil
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'should work for DHCP set interfaces' do
|
145
|
+
ConfigureVisibilityOnHost.expects(:interfaces).multiple_yields(*NETWORK_GUIDS)
|
146
|
+
|
147
|
+
interface1 = MiniTest::Mock.new
|
148
|
+
interface1.expect(:read, [0, false], ['EnableDHCP'])
|
149
|
+
interface1.expect(:read, [0, '10.42.42.42'], ['IPAddress'])
|
150
|
+
interface1.expect(:read, [0, '255.0.0.0'], ['SubnetMask'])
|
151
|
+
interface2 = MiniTest::Mock.new
|
152
|
+
interface2.expect(:read, [0, true], ['EnableDHCP'])
|
153
|
+
interface2.expect(:read, [0, '192.168.1.193'], ['DhcpIPAddress'])
|
154
|
+
interface2.expect(:read, [0, '255.255.255.0'], ['DhcpSubnetMask'])
|
155
|
+
interface3 = MiniTest::Mock.new
|
156
|
+
interface3.expect(:read, [0, false], ['EnableDHCP'])
|
157
|
+
interface3.expect(:read, [0, '172.16.1.193'], ['IPAddress'])
|
158
|
+
interface3.expect(:read, [0, '255.255.0.0'], ['SubnetMask'])
|
159
|
+
ConfigureVisibilityOnHost.expects(:open_interface).returns(interface1, interface2, interface3).at_most(3)
|
160
|
+
expect(ConfigureVisibilityOnHost.get_network_guid('42.42.42.42')).must_be_nil
|
119
161
|
end
|
120
162
|
|
121
163
|
it 'returns nil for nil input' do
|
122
|
-
ConfigureVisibilityOnHost.
|
123
|
-
expect(ConfigureVisibilityOnHost.get_network_name(nil)).must_be_nil
|
164
|
+
expect(ConfigureVisibilityOnHost.get_network_guid(nil)).must_be_nil
|
124
165
|
end
|
125
166
|
|
126
167
|
it 'returns nil for empty input' do
|
127
|
-
ConfigureVisibilityOnHost.
|
128
|
-
expect(ConfigureVisibilityOnHost.get_network_name('')).must_be_nil
|
168
|
+
expect(ConfigureVisibilityOnHost.get_network_guid('')).must_be_nil
|
129
169
|
end
|
130
170
|
|
131
171
|
describe '#get_network_name' do
|
132
|
-
it 'returns network
|
133
|
-
ConfigureVisibilityOnHost.expects(
|
134
|
-
|
172
|
+
it 'returns network guid for single interface' do
|
173
|
+
ConfigureVisibilityOnHost.expects(:interfaces).yields(NETWORK_GUIDS[0])
|
174
|
+
|
175
|
+
interface = MiniTest::Mock.new
|
176
|
+
interface.expect(:read, [0, false], ['EnableDHCP'])
|
177
|
+
interface.expect(:read, [0, '192.168.1.193'], ['IPAddress'])
|
178
|
+
interface.expect(:read, [0, '255.255.255.0'], ['SubnetMask'])
|
179
|
+
ConfigureVisibilityOnHost.expects(:open_interface).returns(interface)
|
180
|
+
expect(ConfigureVisibilityOnHost.get_network_guid('192.168.1.193')).must_equal('{1abb8efe-c0d5-4ddf-8e29-eae8499e92ba}')
|
135
181
|
end
|
136
182
|
end
|
137
183
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: landrush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Hinze
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filelock
|