ievms-ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05be8b5a8afb70d2e593f3b8a2d760ea8e25ebd9
4
- data.tar.gz: 6a8acce20fd1eeaeb9e141ab1285da86f4d1adf2
3
+ metadata.gz: d1b1ed064b1f9f0d07deb7d8a1599131c33cfd1c
4
+ data.tar.gz: 89adcd248ac8f761c206df6e11c5eb6a7616c7da
5
5
  SHA512:
6
- metadata.gz: 8a21fd4b8f5229eff45578a52ad4f1c281a0c9566e51f71cc30b42382b0ddf292b618a72cd4416f07194fe5fad9e875a3a7af0194ec84d439f5f860008dd02c8
7
- data.tar.gz: a845e9089277fb1d8a773702fbf46a781f7968e822397dbdf8cc659347d35854df38cbd39d468f8eb08dbabb8856bcbd7280a28938a70049e5eadf426db7a57e
6
+ metadata.gz: 71ad9eb8e5775cb37307cde8aa88ae8e9c7a850d63bb69f716db50cce3b6b726d448c19367ae439d54b89a02a5449bf228b5cd89f58b0d198ccb2c58fa2c8028
7
+ data.tar.gz: 1c498afdbe7b088c7c6d06ca7fc0b35a64b59b76df4363e3fe4985bf6b6e2b253b2dbf11238fa7eb3ef06c4350ccc390c7c067f8d494cf74f45392887b684276
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in ievms-ruby.gemspec
4
4
  gemspec
5
+
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
7
+
data/README.md CHANGED
@@ -2,61 +2,51 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/ievms-ruby.svg)](https://badge.fury.io/rb/ievms-ruby)
4
4
  [![Code Climate](https://codeclimate.com/github/mipmip/ievms-ruby/badges/gpa.svg)](https://codeclimate.com/github/mipmip/ievms-ruby)
5
+ [![Test Coverage](https://codeclimate.com/github/mipmip/ievms-ruby/badges/coverage.svg)](https://codeclimate.com/github/mipmip/ievms-ruby/coverage)
5
6
  [![Dependency Status](https://gemnasium.com/mipmip/ievms-ruby.svg)](https://gemnasium.com/mipmip/ievms-ruby)
6
-
7
+ [![Inline docs](http://inch-ci.org/github/mipmip/ievms-ruby.svg?branch=master)](http://inch-ci.org/github/mipmip/ievms-ruby)
7
8
 
8
9
  Ruby interface for boxes made by ievms.sh. Use this Library to provision your
9
10
  IE boxes from https://modern.ie.
10
11
 
11
- Next ievms.sh ievms-ruby also works great in combination with iectrl.
12
+ Next to [ievms.sh](https://github.com/xdissent/ievms), `ievms-ruby` also works great in combination with [iectrl](https://github.com/xdissent/iectrl).
12
13
 
13
- ## Requirements
14
+ ## WinBoxes supported
14
15
 
15
- * VirtualBox >= 5.0.4
16
- * VirtualBox Extension Pack and Guest Additions >= 5.0.4
17
- * Host Machine: OSX or Linux (only tested on OSX 10.9 & 10.10)
18
- * Virtual Machines created by .ievms (only tested with vanilla Win7 machines)
16
+ ![winxp](https://img.shields.io/badge/WinXP-failure-red.svg)
17
+ ![winvista](https://img.shields.io/badge/WinVista-failure-red.svg)
18
+ ![win7](https://img.shields.io/badge/Win7-success-brightgreen.svg)
19
+ ![win8](https://img.shields.io/badge/Win8-success-brightgreen.svg)
20
+ ![win10](https://img.shields.io/badge/Win10-unknown-lightgrey.svg)
19
21
 
20
22
  ## Features
21
23
 
22
- * Works with Windows 7
23
24
  * Upload files to guest machine
24
25
  * Download file from guest machine
25
- * Execute batch file on guest machine
26
- * Execute batch file as admin on guest machine
26
+ * Execute cmd.exe and powershell commands on guest machine
27
+ * Execute cmd.exe and powershell commands on guest machine as admin
27
28
  * Cat file guest machine from cli
28
29
 
29
- ## Installation
30
-
31
- Add this line to your application's Gemfile:
32
-
33
- ```ruby
34
- gem 'ievms-ruby'
35
- ```
36
- $ bundle
37
-
38
- Or install it yourself as:
30
+ ## Requirements
39
31
 
40
- $ gem install ievms-ruby
32
+ * [VirtualBox](https://www.virtualbox.org/wiki/Downloads) >= 5.0.6
33
+ * VirtualBox Extension Pack and Guest Additions >= 5.0.6
34
+ * Host Machine: OSX or Linux (only tested on OSX 10.9 & 10.10)
35
+ * Virtual Machines created by .ievms (only tested with vanilla Win7 machines)
41
36
 
42
37
  ## Usage
43
38
 
44
- ### From CLI
45
- After gem install you can call:
46
-
47
- ```bash
48
- ievmsrb help
49
- ```
39
+ ### As library
40
+ Use Ievms-ruby in provisioning scripts for windows E.g. for CI. Here's an example
41
+ provisioning script using the Gem. It installs [Chocolatey](https://chocolatey.org), Ruby, and [git-for-windows](https://git-for-windows.github.io) without user interaction needed.
50
42
 
51
- to cat a guest file:
43
+ Add this line to your application's Gemfile:
52
44
 
53
- ```bash
54
- ievmsrb cat "IE9 - Win7" 'C:\Windows\System32\Drivers\Etc\hosts'
45
+ ```ruby
46
+ gem 'ievms-ruby'
55
47
  ```
56
48
 
57
- ### As library
58
- Ievms-ruby very usable as provision tool for windows. E.g. for CI. Here's an example
59
- provisioning script using the Gem:
49
+ run `bundle install`
60
50
 
61
51
  ```ruby
62
52
  #!/usr/bin/env ruby
@@ -92,19 +82,62 @@ provision.install_chocolatey
92
82
  provision.install_ruby_and_git
93
83
  ```
94
84
 
95
- ## TODO 0.1.x first loud release
85
+ ### From CLI
86
+ Install the Gem on your system:
87
+
88
+ $ gem install ievms-ruby
89
+
90
+ After installation you can use the `ievmsrb` cli program.
91
+
92
+ #### ievmsrb commands
93
+
94
+ ```bash
95
+ $ ievmsrb help
96
+
97
+ Commands:
98
+ ievmsrb cat [vbox name] [file path] # cat file from path in Win vbox
99
+ ievmsrb cmd [vbox name] [command to execute] # Run command with cmd.exe in Win vbox
100
+ ievmsrb copy_from [vbox name] [path in vbox] [local file] # Copy file from Win vbox to local path
101
+ ievmsrb copy_to [vbox name] [local file] [path in vbox] # Copy local file to Win vbox
102
+ ievmsrb help [COMMAND] # Describe available commands or one specific command
103
+ ievmsrb ps [vbox name] # Show running tasks in Win vbox
104
+ ievmsrb reboot [vbox name] # Reboot Win box
105
+ ievmsrb shutdown [vbox name] # Shutdown Win vbox
106
+ ```
107
+
108
+ #### ievmsrb examples
109
+
110
+ Display the contents of a guest file.
111
+ ```bash
112
+ $ ievmsrb cat "IE9 - Win7" 'C:\Windows\System32\Drivers\Etc\hosts'
113
+ ```
114
+
115
+
116
+ Execute a cmd on the guestmachine and show the output
117
+ ```bash
118
+ $ ievmsrb cmd "IE9 - Win7" 'tasklist'
119
+ ```
120
+
96
121
 
97
- * Upload files as admin to guest machine
98
- * Test More Win platforms
99
- * Execution time out for exec
100
- * Rubocop refactoring
122
+ Copy a file from the Windows Guest to a local path
123
+ ```bash
124
+ $ ievmsrb copy_from "IE9 - Win7" 'C:\Windows\System32\Drivers\Etc\hosts' ~/Desktop/hosts.win9
125
+ ```
101
126
 
102
- ## Testing
127
+ Turn of the Filewall executing a command as Administator
128
+ ```bash
129
+ $ ievmsrb cmd_adm "IE9 - Win7" 'NetSh Advfirewall set allprofiles state off'
130
+ ```
131
+
132
+ ## Contributing
133
+ Please submit a new ticket if you want to report an issue.
134
+ Merge requests are welcome. See issues with `Help Wanted` label.
103
135
 
136
+ ### Testing
104
137
  To run the tests you need top fullfil the testing requirements first:
105
138
 
106
139
  * VirtualBox >= 5.0.4
107
- * "IE9 - Win7" installed by ievms.sh
140
+ * "IE9 - Win7" installed by ievms.sh
108
141
  * Create an new virtual machine called `standbymachine`. Keep the disk size as
109
142
  small as possible. It should be turned off.
110
143
 
@@ -112,14 +145,24 @@ To run the tests you need top fullfil the testing requirements first:
112
145
  git clone https://github.com/mipmip/ievms-ruby.git
113
146
  cd ievms-ruby
114
147
  bundle install
115
- rake
148
+ bundle exec rake
116
149
  ```
117
150
 
118
-
119
- ## Contributing
120
-
151
+ ### Merge Requests
121
152
  1. Fork it ( https://github.com/mipmip/ievms-ruby/fork )
122
153
  2. Create your feature branch (`git checkout -b my-new-feature`)
123
154
  3. Commit your changes (`git commit -am 'Add some feature'`)
124
155
  4. Push to the branch (`git push origin my-new-feature`)
125
156
  5. Create a new Pull Request
157
+
158
+ ## Troubleshooting
159
+ - If tests fail check if virtualbox guest additions 5.0.6 or higher are
160
+ installed
161
+
162
+ ## Acknowledgements
163
+ - ievms - Provider of a platform and methology
164
+ - modern.IE - Provider of IE VM images.
165
+ - virtualbox - Software for running Virtual Machines
166
+ - shields.io - Creates the beautiful Windows Badges
167
+
168
+
@@ -1,23 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'bundler/setup'
3
- require 'ievms/windows_guest'
4
3
  require 'thor'
4
+ require 'ievms/ievms_cli'
5
+ require 'ievms/windows_guest'
5
6
 
6
- class IevmsRb < Thor
7
-
8
- desc "cat [vbox name] [filename]", "cat file in VBox guest"
9
- def cat(vbox_name,guest_path)
10
- init vbox_name
11
-
12
- print @machine.download_string_from_file_to_guest guest_path, true
13
- print "\n"
14
- end
15
-
16
- private
17
-
18
- def init vbox_name
19
- @machine = Ievms::WindowsGuest.new vbox_name
20
- end
21
- end
22
7
 
23
8
  IevmsRb.start(ARGV)
@@ -0,0 +1,66 @@
1
+ class IevmsRb < Thor
2
+
3
+ desc "cat [vbox name] [file path]", "cat file from path in Win vbox"
4
+ def cat(vbox_name,guest_path)
5
+ init vbox_name
6
+ print @machine.download_string_from_file_to_guest guest_path, true
7
+ end
8
+
9
+ desc "ps [vbox name]", "Show running tasks in Win vbox"
10
+ def ps(vbox_name)
11
+ init vbox_name
12
+ print @machine.run_command "tasklist"
13
+ end
14
+
15
+ desc "shutdown [vbox name]", "Shutdown Win vbox"
16
+ def shutdown(vbox_name)
17
+ init vbox_name
18
+ print @machine.run_command "shutdown.exe /s /f /t 0"
19
+ end
20
+
21
+ desc "reboot [vbox name]", "Reboot Win box"
22
+ def reboot(vbox_name)
23
+ init vbox_name
24
+ print @machine.run_command "shutdown.exe /r /f /t 0"
25
+ end
26
+
27
+ desc "copy_to_as_adm [vbox name] [local file] [path in vbox]", "Copy local file to Win vbox as Administrator"
28
+ def copy_to_as_adm(vbox_name,local_path, guest_path)
29
+ init vbox_name
30
+ @machine.upload_file_to_guest_as_admin(local_path, guest_path, false)
31
+ end
32
+
33
+ desc "copy_to [vbox name] [local file] [path in vbox]", "Copy local file to Win vbox"
34
+ def copy_to(vbox_name,local_path, guest_path)
35
+ init vbox_name
36
+ @machine.upload_file_to_guest(local_path, guest_path, false)
37
+ end
38
+
39
+ desc "copy_from [vbox name] [path in vbox] [local file]", "Copy file from Win vbox to local path"
40
+ def copy_from(vbox_name, guest_path, local_path)
41
+ init vbox_name
42
+ @machine.download_file_from_guest(guest_path, local_path, false)
43
+ end
44
+
45
+ desc "cmd [vbox name] [command to execute]", "Run command with cmd.exe in Win vbox"
46
+ def cmd(vbox_name,command)
47
+ init vbox_name
48
+
49
+ print @machine.run_command command
50
+ print "\n"
51
+ end
52
+
53
+ desc "cmd_adm [vbox name] [command to execute]", "Run command as Administrator with cmd.exe in Win vbox"
54
+ def cmd_as_adm(vbox_name,command)
55
+ init vbox_name
56
+
57
+ print @machine.run_command_as_admin command
58
+ end
59
+
60
+ private
61
+
62
+ def init vbox_name
63
+ @machine = Ievms::WindowsGuest.new vbox_name
64
+ end
65
+ end
66
+
@@ -1,3 +1,3 @@
1
1
  module Ievms
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -24,22 +24,11 @@ module Ievms
24
24
  is_vm vbox_name
25
25
  end
26
26
 
27
- # Copy a file to the virtual machine from the ievms home folder.
28
- def copy_to_vm(src ,dest, quiet=false)
29
- print "Copying #{src} to #{dest}\n" unless quiet
30
- guestcontrol_exec "cmd.exe", "cmd.exe /c copy \"E:\\#{src}\" \"#{dest}\""
31
- end
32
-
33
- # Copy a file to the virtual machine from the ievms home folder.
34
- def copy_from_vm(src ,dest, quiet=false)
35
- print "Copying #{src} to #{dest}\n" unless quiet
36
- guestcontrol_exec "cmd.exe", "cmd.exe /c copy \"#{src}\" \"E:\\#{dest}\""
37
- end
38
-
39
27
  def download_file_from_guest(guest_path, local_path, quiet=false)
40
28
 
29
+ log_stdout "Copying #{guest_path} to #{local_path}", quiet
41
30
  # 1 run cp command in machine
42
- copy_from_vm guest_path, File.basename(local_path), quiet
31
+ guestcontrol_exec "cmd.exe", "cmd.exe /c copy \"#{guest_path}\" \"E:\\#{File.basename(local_path)}\""
43
32
 
44
33
  # 2 copy to tmp location in .ievms
45
34
  FileUtils.cp File.join(IEVMS_HOME,File.basename(local_path)), local_path
@@ -55,14 +44,17 @@ module Ievms
55
44
  FileUtils.cp local_path, File.join(IEVMS_HOME,File.basename(local_path))
56
45
 
57
46
  # 2 run cp command in machine
58
- copy_to_vm File.basename(local_path), guest_path, quiet
47
+ log_stdout "Copying #{local_path} to #{guest_path}", quiet
48
+ guestcontrol_exec "cmd.exe", "cmd.exe /c copy \"E:\\#{File.basename(local_path)}\" \"#{guest_path}\""
59
49
 
60
50
  # 3 remove tmp file in .ievms
61
51
  FileUtils.rm File.join(IEVMS_HOME,File.basename(local_path))
62
52
  end
63
53
 
64
54
  def download_string_from_file_to_guest( guest_path, quiet=false)
65
- copy_from_vm guest_path, 'tmpfile.txt', quiet
55
+ log_stdout "Copying #{guest_path} to tempfile.txt", quiet
56
+ guestcontrol_exec "cmd.exe", "cmd.exe /c copy \"#{guest_path}\" \"E:\\tmpfile.txt\""
57
+
66
58
  string = IO.read(File.join(IEVMS_HOME,'tmpfile.txt'))
67
59
  FileUtils.rm File.join(IEVMS_HOME,'tmpfile.txt')
68
60
  string
@@ -80,9 +72,19 @@ module Ievms
80
72
  FileUtils.rm path
81
73
  end
82
74
 
75
+ # Upload a local file to the windows guest as Administator
76
+ def upload_file_to_guest_as_admin(local_path, guest_path, quiet=false)
77
+
78
+ log_stdout "Copying #{local_path} to #{guest_path} as Administrator", quiet
79
+
80
+ upload_file_to_guest(local_path, 'C:\Users\IEUser\.tempadminfile',true)
81
+ run_command_as_admin('copy C:\Users\IEUser\.tempadminfile '+ guest_path,true)
82
+ run_command 'del C:\Users\IEUser\.tempadminfile', true
83
+ end
84
+
83
85
  # execute existibg batch file in Windows guest as Administrator
84
86
  def run_command_as_admin(command,quiet=false)
85
- print "Executing command as administrator: #{command}\n" unless quiet
87
+ log_stdout "Executing command as administrator: #{command}", quiet
86
88
 
87
89
  run_command 'if exist C:\Users\IEUser\ievms.bat del C:\Users\IEUser\ievms.bat && Exit', true
88
90
 
@@ -90,16 +92,20 @@ module Ievms
90
92
 
91
93
  guestcontrol_exec "schtasks.exe", "schtasks.exe /run /tn ievms"
92
94
 
93
- while schtasks_query_ievms.include? 'Running'
94
- print "."
95
- sleep 2
95
+ unless quiet
96
+ print "..."
97
+ while schtasks_query_ievms.include? 'Running'
98
+ print "."
99
+ sleep 2
100
+ end
101
+ print "\n"
96
102
  end
97
- print "\n"
103
+
98
104
  end
99
105
 
100
106
  # execute existing batch file in Windows guest
101
107
  def run_command(command, quiet=false)
102
- print "Executing command: #{command}\n" unless quiet
108
+ log_stdout "Executing command: #{command}", quiet
103
109
  out, _, _ = guestcontrol_exec "cmd.exe", "cmd.exe /c \"#{command}\""
104
110
  out
105
111
  end
@@ -111,6 +117,10 @@ module Ievms
111
117
 
112
118
  private
113
119
 
120
+ def log_stdout(msg, quiet=true)
121
+ print "[#{@vbox_name}] #{msg}\n" unless quiet
122
+ end
123
+
114
124
  # execute final guest control shell cmd
115
125
  # returns [stdout,stderr,status] from capture3
116
126
  def guestcontrol_exec(image, cmd)
@@ -1,5 +1,6 @@
1
1
  require 'simplecov'
2
2
 
3
+
3
4
  SimpleCov.start do
4
5
  add_filter '/test/'
5
6
  add_filter '/vendor/'
@@ -9,8 +10,6 @@ require 'minitest'
9
10
  require 'minitest/unit'
10
11
  require 'minitest/autorun'
11
12
  require 'minitest/pride'
12
- #require 'base64'
13
-
14
- #tempdir = File.join(File.dirname(__FILE__), 'tmpout')
15
- #FileUtils.rm_rf(Dir.glob(tempdir+'/*'))
16
13
 
14
+ require "codeclimate-test-reporter"
15
+ CodeClimate::TestReporter.start
@@ -0,0 +1,105 @@
1
+ require 'test_helper'
2
+ require 'thor'
3
+ require 'ievms/ievms_cli'
4
+ require 'ievms/windows_guest'
5
+ require 'timeout'
6
+
7
+ class TestWin7 < Minitest::Test
8
+ def setup
9
+ iectrl = `iectrl status "IE9 - Win7"`
10
+ if not iectrl.include?('RUNNING')
11
+ iectrl = `iectrl start "IE9 - Win7"`
12
+ sleep 5
13
+ IevmsRb.start(['ps', "IE9 - Win7"])
14
+ end
15
+ end
16
+
17
+ def test_non_existing_guest
18
+ end
19
+
20
+ def test_ps
21
+ assert_equal true, run_capture(["ps", "IE9 - Win7"]).include?('winlogon.exe')
22
+ end
23
+
24
+ def test_help
25
+ assert_equal true, run_capture([]).include?('[vbox name]')
26
+ assert_equal true, run_capture(['help']).include?('[file path]')
27
+ end
28
+
29
+ def test_copy_from
30
+ FileUtils.rm '/tmp/testdlfile2.txt' if File.exists? '/tmp/testdlfile2.txt'
31
+ out = run_capture ['copy_from',"IE9 - Win7",'C:\ievms.xml', '/tmp/testdlfile2.txt']
32
+
33
+ assert_equal out, "[IE9 - Win7] Copying C:\\ievms.xml to /tmp/testdlfile2.txt\n"
34
+ assert_equal true, File.exists?('/tmp/testdlfile2.txt')
35
+ end
36
+
37
+ def test_copy_to
38
+ IevmsRb.start ['cmd', "IE9 - Win7", 'if exist C:\Users\IEUser\ievms_test_upload3.txt del C:\Users\IEUsers\ievms_test_upload3.txt && Exit']
39
+ FileUtils.rm '/tmp/ievms_test_upload3.txt' if File.exists? '/tmp/ievms_test_upload3.txt'
40
+ `echo "uploadasadmin_yes" > /tmp/ievms_test_upload3.txt`
41
+ out = run_capture ['copy_to',"IE9 - Win7", '/tmp/ievms_test_upload3.txt', 'C:\Users\IEUser\ievms_test_upload3.txt']
42
+ out2 = run_capture ['cat',"IE9 - Win7", 'C:\Users\IEUser\ievms_test_upload3.txt']
43
+ assert_equal "[IE9 - Win7] Copying /tmp/ievms_test_upload3.txt to C:\\Users\\IEUser\\ievms_test_upload3.txt\n", out
44
+ assert_match(/uploadasadmin_yes/, out2)
45
+
46
+ end
47
+
48
+ def test_copy_to_as_adm
49
+ IevmsRb.start ['cmd_as_adm', "IE9 - Win7", 'if exist C:\ievms_test_upload2.txt del C:\ievms_test_upload2.txt && Exit']
50
+ FileUtils.rm '/tmp/ievms_test_upload2.txt' if File.exists? '/tmp/ievms_test_upload2.txt'
51
+ `echo "uploadasadmin_yes" > /tmp/ievms_test_upload2.txt`
52
+
53
+ out = run_capture ['copy_to_as_adm',"IE9 - Win7", '/tmp/ievms_test_upload2.txt', 'C:\ievms_test_upload2.txt']
54
+ out2 = run_capture ['cat',"IE9 - Win7", 'C:\ievms_test_upload2.txt']
55
+ assert_equal "[IE9 - Win7] Copying /tmp/ievms_test_upload2.txt to C:\\ievms_test_upload2.txt as Administrator\n", out
56
+ assert_match(/uploadasadmin_yes/, out2)
57
+
58
+ end
59
+
60
+ def test_reboot
61
+ sysinfo = run_capture(['cmd', "IE9 - Win7", 'systeminfo'])
62
+ boottime1 = sysinfo.lines.find { |line| line.include?("Boot") }
63
+ IevmsRb.start(['reboot', "IE9 - Win7"])
64
+ sleep 5
65
+ IevmsRb.start(['ps', "IE9 - Win7"])
66
+
67
+ sysinfo2 = run_capture(['cmd', "IE9 - Win7", 'systeminfo'])
68
+ boottime2 = sysinfo2.lines.find { |line| line.include?("Boot") }
69
+ refute_equal boottime1, boottime2
70
+ end
71
+
72
+ def test_shutdown
73
+ iectrl1 = `iectrl status "IE9 - Win7"`
74
+ assert_match(/RUNNING/, iectrl1)
75
+
76
+ IevmsRb.start(['shutdown', "IE9 - Win7"])
77
+ sleep 5
78
+
79
+ iectrl2 = `iectrl status "IE9 - Win7"`
80
+ refute_match(/RUNNING/, iectrl2)
81
+ end
82
+
83
+ def test_cat
84
+ out = run_capture(['cat', "IE9 - Win7", 'C:\Windows\System32\Drivers\Etc\hosts'])
85
+ assert_match(/rhino\.acme\.com/, out)
86
+ end
87
+
88
+ def test_cmd
89
+ out = run_capture(['cmd', "IE9 - Win7", 'tasklist'])
90
+ assert_match(/winlogon\.exe/, out)
91
+ end
92
+
93
+ def test_cmd_adm
94
+ out = run_capture(['cmd', "IE9 - Win7", 'tasklist'])
95
+ assert_match(/winlogon\.exe/, out)
96
+ end
97
+
98
+ private
99
+ def run_capture(args)
100
+ out, _ = capture_io do
101
+ IevmsRb.start(args)
102
+ end
103
+ out
104
+ end
105
+ end
@@ -4,6 +4,14 @@ require 'timeout'
4
4
 
5
5
  class TestWin7 < Minitest::Test
6
6
  def setup
7
+
8
+ iectrl = `iectrl status "IE9 - Win7"`
9
+ if not iectrl.include?('RUNNING')
10
+ iectrl = `iectrl start "IE9 - Win7"`
11
+ sleep 5
12
+ IevmsRb.start(['ps', "IE9 - Win7"])
13
+ end
14
+
7
15
  @machine = Ievms::WindowsGuest.new 'IE9 - Win7'
8
16
  end
9
17
 
@@ -54,7 +62,6 @@ eos
54
62
 
55
63
  @machine.upload_file_to_guest(File.join(File.dirname(__FILE__), '_test.bat'), 'C:\Users\IEUser\test.bat')
56
64
  @machine.run_command('C:\Users\IEUser\test.bat')
57
- #@machine.run_bat('C:\Users\IEUser\test.bat')
58
65
  output_file_exists = @machine.run_command 'if exist C:\Users\IEUser\EmptyFile.txt echo EmptyFileExist && Exit'
59
66
 
60
67
  assert_equal true, output_file_exists.include?('EmptyFileExist')
@@ -72,9 +79,21 @@ eos
72
79
 
73
80
  @machine.upload_file_to_guest(File.join(File.dirname(__FILE__), '_test_as_admin.bat'), 'C:\Users\IEUser\test_as_admin.bat')
74
81
  @machine.run_command_as_admin('C:\Users\IEUser\test_as_admin.bat')
75
- # @machine.run_bat_as_admin('C:\Users\IEUser\test_as_admin.bat')
76
82
  output_file_exists = @machine.run_command 'if exist C:\EmptyFile2.txt echo EmptyFile2Exist && Exit'
77
83
 
78
84
  assert_equal true, output_file_exists.include?('EmptyFile2Exist')
79
85
  end
86
+
87
+ def test_upload_file_as_admin
88
+ @machine.run_command_as_admin 'if exist C:\ievms_test_upload.txt del C:\ievms_test_upload.txt && Exit'
89
+ FileUtils.rm '/tmp/ievms_test_upload.txt' if File.exists? '/tmp/ievms_test_upload.txt'
90
+
91
+ `echo "uploadasadmin_yes" > /tmp/ievms_test_upload.txt`
92
+
93
+ @machine.upload_file_to_guest_as_admin '/tmp/ievms_test_upload.txt', 'C:\ievms_test_upload.txt'
94
+ output_file_exists = @machine.run_command 'type c:\ievms_test_upload.txt'
95
+
96
+ assert_equal true, output_file_exists.include?('uploadasadmin_yes')
97
+ end
98
+
80
99
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ievms-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pim Snel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-07 00:00:00.000000000 Z
11
+ date: 2015-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,11 +95,13 @@ files:
95
95
  - Rakefile
96
96
  - bin/ievmsrb
97
97
  - ievms-ruby.gemspec
98
+ - lib/ievms/ievms_cli.rb
98
99
  - lib/ievms/version.rb
99
100
  - lib/ievms/windows_guest.rb
100
101
  - test/_test.bat
101
102
  - test/_test_as_admin.bat
102
103
  - test/test_helper.rb
104
+ - test/test_ievms_cli.rb
103
105
  - test/test_ievms_win7.rb
104
106
  homepage: https://github.com/mipmip/ievms-ruby
105
107
  licenses:
@@ -129,4 +131,5 @@ test_files:
129
131
  - test/_test.bat
130
132
  - test/_test_as_admin.bat
131
133
  - test/test_helper.rb
134
+ - test/test_ievms_cli.rb
132
135
  - test/test_ievms_win7.rb