diff --git a/.rubocop.yml b/.rubocop.yml index 9cabf8a..fda2e20 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,6 +8,3 @@ AllCops: Style/FrozenStringLiteralComment: Enabled: false - -Style/EndOfLine: - EnforcedStyle: lf \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index edacb1c..a82d468 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,8 @@ version: "{build}" branches: only: - master +init: + - git config --global core.autocrlf true install: - set PATH=C:\Ruby22\bin;%PATH% - ruby --version diff --git a/lib/landrush/cap/host/windows/configure_visibility_on_host.rb b/lib/landrush/cap/host/windows/configure_visibility_on_host.rb index d56dace..5961eb5 100644 --- a/lib/landrush/cap/host/windows/configure_visibility_on_host.rb +++ b/lib/landrush/cap/host/windows/configure_visibility_on_host.rb @@ -145,8 +145,12 @@ def info(msg) @env.ui.info("[landrush] #{msg}") unless @env.nil? end + def wired_autoconfig_service_state + `sc query dot3svc` + end + def wired_autoconfig_service_running? - cmd_out = `sc query dot3svc` + cmd_out = wired_autoconfig_service_state cmd_out =~ /\s*STATE\s+:\s+4\s+RUNNING/m end diff --git a/test/landrush/cap/host/windows/configure_visibility_on_host_test.rb b/test/landrush/cap/host/windows/configure_visibility_on_host_test.rb index b3163ed..53ddfc0 100644 --- a/test/landrush/cap/host/windows/configure_visibility_on_host_test.rb +++ b/test/landrush/cap/host/windows/configure_visibility_on_host_test.rb @@ -6,6 +6,25 @@ module Windows describe ConfigureVisibilityOnHost do TEST_IP = '10.42.42.42'.freeze + DOT_3_SVC_RUNNING = 'SERVICE_NAME: dot3svc + TYPE : 30 WIN32 + STATE : 4 RUNNING + (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN) + WIN32_EXIT_CODE : 0 (0x0) + SERVICE_EXIT_CODE : 0 (0x0) + CHECKPOINT : 0x0 + WAIT_HINT : 0x0 +'.freeze + + DOT_3_SVC_STOPPED = 'SERVICE_NAME: dot3svc + TYPE : 30 WIN32 + STATE : 1 STOPPED + WIN32_EXIT_CODE : 0 (0x0) + SERVICE_EXIT_CODE : 0 (0x0) + CHECKPOINT : 0x0 + WAIT_HINT : 0x0 +'.freeze + before do @vboxmanage_found = !Vagrant::Util::Which.which('VBoxManage').nil? @has_admin_privileges = Landrush::Cap::Windows::ConfigureVisibilityOnHost.admin_mode? @@ -32,13 +51,25 @@ module Windows end end + describe '#wired_autoconfig_service_running?' do + it 'service running' do + Landrush::Cap::Windows::ConfigureVisibilityOnHost.expects(:wired_autoconfig_service_state).returns(DOT_3_SVC_RUNNING) + assert ConfigureVisibilityOnHost.send(:wired_autoconfig_service_running?) + end + + it 'service stopped' do + Landrush::Cap::Windows::ConfigureVisibilityOnHost.expects(:wired_autoconfig_service_state).returns(DOT_3_SVC_STOPPED) + refute ConfigureVisibilityOnHost.send(:wired_autoconfig_service_running?) + end + end + def network_state `netsh interface ip show config`.split(/\n/).reject(&:empty?) end def get_network_name(old_network_state, new_network_state) new_network_state.reject! { |line| old_network_state.include? line } - new_network_state[0].match(/.*\"(.*)\"$/).captures[0] + new_network_state[0].match(/.*"(.*)"$/).captures[0] end # Creates a test interface using VBoxMange and sets a known test IP