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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d31f07ae3a474d9a5e399e15ce9bffa3cce616651a999437094d1aece8c617d2
4
- data.tar.gz: 6e91547880229bdd51b4df747d8dde2fc9d48b167ff0a7acf3e83a56a0df1ce3
3
+ metadata.gz: 53b5666e9dffc5e0dfdc9992ecf961380f115ad40d2286cdfee46fcb00dac52b
4
+ data.tar.gz: bac8ef15e393c51e6833aa0797e83d18b4807cab8174c1f3c9c39c8f0a66d03b
5
5
  SHA512:
6
- metadata.gz: c6c01e67c9d8f55d8f0f4d9a42e959e4005840fce1d6f2d86f6060973a0313158beaa1bdfadec68ba7ef8da18da56824ebee27482a2498688f2f6b21f4bf00c3
7
- data.tar.gz: dbf7d7cbc7ba989a89408468c567b1036ebaefa634422f93aeba540783fcf0b9851d450300de2dcbcf3b5e8366cbfac4f10a6c7e657363469af23bde19f6a1f8
6
+ metadata.gz: d145a063094fbf0cafd6f3a18e771d0308d738f634e76dc06f3c473a7d15971a3d288444f1ef938db71df902a57952a049561a64e12a55589ecdd8e5ca1985f0
7
+ data.tar.gz: 5b8fb77e369b300ec7bb18982085d363fb5d7c4b8ed643e50fe8663dc66759200358034b79b6ac8c017a65651453fad845b2026ed0ada06619c178b2834174c5
@@ -8,3 +8,11 @@ AllCops:
8
8
 
9
9
  Style/FrozenStringLiteralComment:
10
10
  Enabled: false
11
+
12
+ Metrics/BlockLength:
13
+ Max: 50
14
+ ExcludedMethods: ['describe', 'context']
15
+
16
+ Metrics/ModuleLength:
17
+ Exclude:
18
+ - !ruby/regexp /^test\//
@@ -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:
@@ -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
@@ -83,10 +83,6 @@ $ git push origin master
83
83
 
84
84
  == Maintainers
85
85
 
86
- * Brian Exelbierd (@bexelbie)
87
- * Eric Sorenson (@ahpook)
88
- * Florian Holzhauer (@fh)
86
+ * Davi Koscianski Vidal (@davividal)
89
87
  * Hardy Ferentschik (@hferentschik)
90
- * Josef Strzibny (@strzibny)
91
- * Paul Hinze (@phinze)
92
- * Reto Kaiser (@njam)
88
+
data/Gemfile CHANGED
@@ -19,5 +19,5 @@ group :development do
19
19
  gem 'rubocop', '~> 0.59.0'
20
20
  gem 'vagrant',
21
21
  git: 'https://github.com/mitchellh/vagrant.git',
22
- ref: 'v2.1.2'
22
+ ref: 'v2.2.4'
23
23
  end
@@ -2,7 +2,7 @@
2
2
  :toc:
3
3
  :toc-placement!:
4
4
 
5
- https://travis-ci.org/vagrant-landrush/landrush[image:https://travis-ci.org/vagrant-landrush/landrush.png[Build Status]]
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
 
@@ -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 carlos https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials
130
+ curl -u <user> https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials
131
131
  ----
132
132
  ====
133
133
 
@@ -36,4 +36,4 @@ Feature: DNS resolution
36
36
  | box | provider |
37
37
  | debian/jessie64 | virtualbox |
38
38
  | ubuntu/xenial64 | virtualbox |
39
- | ubuntu/bionic64 | virtualbox |
39
+ # | ubuntu/bionic64 | virtualbox |
@@ -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
- run("bundle exec vagrant ssh -c \"dig +short '#{host}' A\"")
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
- run(cmd)
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
- run('bundle exec vagrant landrush list')
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
- run('bundle exec vagrant landrush status')
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
- (`reg query HKU\\S-1-5-19 2>&1` =~ /ERROR/).nil?
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 name, if any. Uses netsh which generates output like this:
27
- #
28
- # ...
29
- # \n\n
30
- # Configuration for interface "Ethernet 2"
31
- # DHCP enabled: Yes
32
- # IP Address: 10.10.10.1
33
- # Subnet Prefix: 10.10.10.0/24 (mask 255.255.255.0)
34
- # InterfaceMetric: 10
35
- # DNS servers configured through DHCP: None
36
- # Register with which suffix: Primary only
37
- # WINS servers configured through DHCP: None
38
- # \n\n
39
- # ...
40
- def get_network_name(ip)
41
- cmd_out = `netsh interface ip show config`
42
- network_details = cmd_out.split(/^$/).reject(&:empty?).select do |settings|
43
- begin
44
- lines = settings.split(/\n/).reject(&:empty?)
45
- subnet = lines[3]
46
- next false unless subnet =~ /Subnet Prefix/
47
-
48
- mask = IPAddr.new(subnet.match(%r{.* (\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}/\d{1,3}).*}).captures[0])
49
- address = IPAddr.new(ip)
50
-
51
- mask.include?(address)
52
- rescue StandardError
53
- false
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
- return nil if network_details[0].nil? || network_details[0].empty?
62
+ end
57
63
 
58
- network_details[0].split(/\n/).reject(&:empty?)[0].match(/Configuration for interface "(.*)"/).captures[0].strip
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
- private
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
- network_name = get_network_name(ip)
96
- if network_name.nil?
97
- info("unable to determine network interface for #{ip}. DNS on host cannot be configured. Try manual configuration.")
98
- return
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 + "\\{#{network_guid}}"
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
@@ -1,3 +1,3 @@
1
1
  module Landrush
2
- VERSION = '1.3.1'.freeze
2
+ VERSION = '1.3.2'.freeze
3
3
  end
@@ -21,49 +21,7 @@ DOT_3_SVC_STOPPED = 'SERVICE_NAME: dot3svc
21
21
  WAIT_HINT : 0x0
22
22
  '.freeze
23
23
 
24
- NETSH_EXAMPLE = '
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 '#get_network_name' do
111
- it 'returns network name for matching IP' do
112
- ConfigureVisibilityOnHost.expects(:`).with('netsh interface ip show config').returns(NETSH_EXAMPLE)
113
- expect(ConfigureVisibilityOnHost.get_network_name('192.168.1.193')).must_equal('Ethernet')
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(:`).with('netsh interface ip show config').returns(NETSH_EXAMPLE)
118
- expect(ConfigureVisibilityOnHost.get_network_name('42.42.42.42')).must_be_nil
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.expects(:`).with('netsh interface ip show config').returns(NETSH_EXAMPLE)
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.expects(:`).with('netsh interface ip show config').returns(NETSH_EXAMPLE)
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 name for single interface' do
133
- ConfigureVisibilityOnHost.expects(:`).with('netsh interface ip show config').returns(NETSH_EXAMPLE_SINGLE_INTERFACE)
134
- expect(ConfigureVisibilityOnHost.get_network_name('192.168.1.193')).must_equal('Ethernet')
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.1
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: 2018-12-04 00:00:00.000000000 Z
11
+ date: 2019-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: filelock