beaker 4.40.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +26 -13
- data/.rubocop.yml +23 -10
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +17 -28
- data/Gemfile +12 -7
- data/Rakefile +99 -111
- data/acceptance/config/acceptance-options.rb +1 -1
- data/acceptance/config/base/acceptance-options.rb +2 -2
- data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
- data/acceptance/config/subcommands/acceptance-options.rb +2 -2
- data/acceptance/fixtures/module/Rakefile +1 -1
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +6 -5
- data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +5 -11
- data/acceptance/tests/base/host/file_test.rb +2 -2
- data/acceptance/tests/base/host/group_test.rb +0 -1
- data/acceptance/tests/base/host/host_test.rb +66 -63
- data/acceptance/tests/base/host/packages.rb +1 -2
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +0 -1
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
- data/acceptance/tests/base/test_suite/export.rb +6 -9
- data/acceptance/tests/install/from_file.rb +2 -4
- data/acceptance/tests/load_path_bootstrap.rb +1 -1
- data/acceptance/tests/subcommands/destroy.rb +19 -21
- data/acceptance/tests/subcommands/exec.rb +0 -1
- data/acceptance/tests/subcommands/init.rb +2 -3
- data/acceptance/tests/subcommands/provision.rb +0 -1
- data/beaker.gemspec +4 -7
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/how_to/debug_beaker_tests.md +12 -12
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +59 -68
- data/lib/beaker/command.rb +20 -28
- data/lib/beaker/command_factory.rb +3 -2
- data/lib/beaker/dsl/assertions.rb +6 -18
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
- data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +13 -15
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +17 -20
- data/lib/beaker/dsl/structure.rb +53 -65
- data/lib/beaker/dsl/test_tagging.rb +7 -10
- data/lib/beaker/dsl/wrappers.rb +15 -16
- data/lib/beaker/dsl.rb +2 -3
- data/lib/beaker/host/aix/exec.rb +1 -1
- data/lib/beaker/host/aix/file.rb +0 -1
- data/lib/beaker/host/aix/group.rb +1 -1
- data/lib/beaker/host/aix/user.rb +1 -1
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +27 -39
- data/lib/beaker/host/eos.rb +4 -30
- data/lib/beaker/host/freebsd/exec.rb +1 -1
- data/lib/beaker/host/freebsd/pkg.rb +3 -3
- data/lib/beaker/host/freebsd.rb +9 -12
- data/lib/beaker/host/mac/exec.rb +4 -4
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +3 -106
- data/lib/beaker/host/mac/user.rb +2 -2
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +66 -70
- data/lib/beaker/host/pswindows/file.rb +3 -5
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +12 -12
- data/lib/beaker/host/pswindows/user.rb +3 -3
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +80 -82
- data/lib/beaker/host/unix/file.rb +38 -43
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +154 -417
- data/lib/beaker/host/unix/user.rb +2 -2
- data/lib/beaker/host/unix.rb +8 -11
- data/lib/beaker/host/windows/exec.rb +17 -17
- data/lib/beaker/host/windows/file.rb +3 -3
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +3 -54
- data/lib/beaker/host/windows/user.rb +3 -3
- data/lib/beaker/host/windows.rb +12 -12
- data/lib/beaker/host.rb +76 -133
- data/lib/beaker/host_prebuilt_steps.rb +93 -198
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +44 -61
- data/lib/beaker/local_connection.rb +2 -4
- data/lib/beaker/logger.rb +68 -76
- data/lib/beaker/logger_junit.rb +21 -25
- data/lib/beaker/network_manager.rb +39 -42
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +16 -24
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +2 -7
- data/lib/beaker/options/parser.rb +86 -102
- data/lib/beaker/options/presets.rb +114 -123
- data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
- data/lib/beaker/options/validator.rb +26 -31
- data/lib/beaker/perf.rb +22 -27
- data/lib/beaker/platform.rb +38 -46
- data/lib/beaker/result.rb +7 -6
- data/lib/beaker/shared/error_handler.rb +8 -10
- data/lib/beaker/shared/fog_credentials.rb +5 -9
- data/lib/beaker/shared/host_manager.rb +36 -41
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +2 -4
- data/lib/beaker/shared/semvar.rb +37 -41
- data/lib/beaker/shared/timed.rb +0 -3
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +38 -47
- data/lib/beaker/subcommand.rb +17 -24
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +4 -9
- data/lib/beaker/tasks/rake_task.rb +25 -27
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +16 -28
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +45 -47
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +6 -7
- data/spec/beaker/cli_spec.rb +121 -142
- data/spec/beaker/command_spec.rb +55 -59
- data/spec/beaker/dsl/assertions_spec.rb +36 -36
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
- data/spec/beaker/dsl/outcomes_spec.rb +14 -14
- data/spec/beaker/dsl/roles_spec.rb +125 -130
- data/spec/beaker/dsl/structure_spec.rb +172 -161
- data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
- data/spec/beaker/dsl/wrappers_spec.rb +32 -33
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +84 -94
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
- data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
- data/spec/beaker/host/mac/exec_spec.rb +2 -3
- data/spec/beaker/host/mac/group_spec.rb +48 -57
- data/spec/beaker/host/mac/user_spec.rb +54 -63
- data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
- data/spec/beaker/host/pswindows/file_spec.rb +16 -16
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +13 -13
- data/spec/beaker/host/unix/exec_spec.rb +75 -80
- data/spec/beaker/host/unix/file_spec.rb +66 -73
- data/spec/beaker/host/unix/pkg_spec.rb +155 -401
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +30 -32
- data/spec/beaker/host/windows/file_spec.rb +18 -19
- data/spec/beaker/host/windows/group_spec.rb +10 -12
- data/spec/beaker/host/windows/pkg_spec.rb +6 -9
- data/spec/beaker/host/windows/user_spec.rb +17 -23
- data/spec/beaker/host/windows_spec.rb +39 -39
- data/spec/beaker/host_prebuilt_steps_spec.rb +172 -326
- data/spec/beaker/host_spec.rb +204 -284
- data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
- data/spec/beaker/localhost_connection_spec.rb +10 -11
- data/spec/beaker/logger_junit_spec.rb +19 -30
- data/spec/beaker/logger_spec.rb +153 -136
- data/spec/beaker/network_manager_spec.rb +23 -23
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +4 -6
- data/spec/beaker/options/parser_spec.rb +167 -167
- data/spec/beaker/options/presets_spec.rb +7 -9
- data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
- data/spec/beaker/options/validator_spec.rb +10 -11
- data/spec/beaker/perf_spec.rb +18 -21
- data/spec/beaker/platform_spec.rb +25 -36
- data/spec/beaker/shared/error_handler_spec.rb +7 -16
- data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
- data/spec/beaker/shared/host_manager_spec.rb +50 -84
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +17 -24
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +76 -83
- data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
- data/spec/beaker/subcommand_spec.rb +75 -77
- data/spec/beaker/test_case_spec.rb +25 -50
- data/spec/beaker/test_suite_spec.rb +147 -154
- data/spec/helpers.rb +48 -53
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +7 -24
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
@@ -11,11 +11,11 @@ module PSWindows::Exec
|
|
11
11
|
ABS_CMD = 'c:\\\\windows\\\\system32\\\\cmd.exe'
|
12
12
|
CMD = 'cmd.exe'
|
13
13
|
|
14
|
-
def echo(msg, abs=true)
|
14
|
+
def echo(msg, abs = true)
|
15
15
|
(abs ? ABS_CMD : CMD) + " /c echo #{msg}"
|
16
16
|
end
|
17
17
|
|
18
|
-
def touch(file, abs=true)
|
18
|
+
def touch(file, abs = true)
|
19
19
|
(abs ? ABS_CMD : CMD) + " /c echo. 2> #{file}"
|
20
20
|
end
|
21
21
|
|
@@ -29,10 +29,10 @@ module PSWindows::Exec
|
|
29
29
|
# @param [String] orig The origin path
|
30
30
|
# @param [String] dest the destination path
|
31
31
|
# @param [Boolean] rm Remove the destination prior to move
|
32
|
-
def mv(orig, dest, rm=true)
|
32
|
+
def mv(orig, dest, rm = true)
|
33
33
|
# ensure that we have the right slashes for windows
|
34
|
-
orig = orig.tr('/','\\')
|
35
|
-
dest = dest.tr('/','\\')
|
34
|
+
orig = orig.tr('/', '\\')
|
35
|
+
dest = dest.tr('/', '\\')
|
36
36
|
rm_rf dest unless !rm
|
37
37
|
execute("move /y #{orig} #{dest}")
|
38
38
|
end
|
@@ -46,17 +46,14 @@ module PSWindows::Exec
|
|
46
46
|
|
47
47
|
result = execute("powershell Test-Path #{file} -PathType Leaf")
|
48
48
|
|
49
|
-
if result.include? 'False'
|
50
|
-
execute("powershell New-Item -ItemType file #{file}")
|
51
|
-
end
|
49
|
+
execute("powershell New-Item -ItemType file #{file}") if result.include? 'False'
|
52
50
|
execute("powershell (gci #{file}).LastWriteTime = Get-Date " \
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
)
|
51
|
+
"-Year '#{time.year}'" \
|
52
|
+
"-Month '#{time.month}'" \
|
53
|
+
"-Day '#{time.day}'" \
|
54
|
+
"-Hour '#{time.hour}'" \
|
55
|
+
"-Minute '#{time.minute}'" \
|
56
|
+
"-Second '#{time.second}'")
|
60
57
|
end
|
61
58
|
|
62
59
|
def path
|
@@ -75,8 +72,10 @@ module PSWindows::Exec
|
|
75
72
|
ips.each_line do |line|
|
76
73
|
matches = line.split('=')
|
77
74
|
next if matches.length <= 1
|
75
|
+
|
78
76
|
matches = matches[1].match(/^{"(.*?)"/)
|
79
77
|
next if matches.nil? || matches.captures.nil? || matches.captures.empty?
|
78
|
+
|
80
79
|
ip = matches.captures[0] if matches && matches.captures
|
81
80
|
break if ip != ''
|
82
81
|
end
|
@@ -88,14 +87,13 @@ module PSWindows::Exec
|
|
88
87
|
# @param [String] target The hostname to ping
|
89
88
|
# @param [Integer] attempts Amount of times to attempt ping before giving up
|
90
89
|
# @return [Boolean] true of ping successful, overwise false
|
91
|
-
def ping target, attempts=5
|
90
|
+
def ping target, attempts = 5
|
92
91
|
try = 0
|
93
|
-
while try < attempts
|
92
|
+
while try < attempts
|
94
93
|
result = exec(Beaker::Command.new("ping -n 1 #{target}"), :accept_all_exit_codes => true)
|
95
|
-
if result.exit_code == 0
|
96
|
-
|
97
|
-
|
98
|
-
try+=1
|
94
|
+
return true if result.exit_code == 0
|
95
|
+
|
96
|
+
try += 1
|
99
97
|
end
|
100
98
|
result.exit_code == 0
|
101
99
|
end
|
@@ -104,85 +102,84 @@ module PSWindows::Exec
|
|
104
102
|
# @param [String] dir The directory structure to create on the host
|
105
103
|
# @return [Boolean] True, if directory construction succeeded, otherwise False
|
106
104
|
def mkdir_p dir
|
107
|
-
normalized_path = dir.tr('/','\\')
|
105
|
+
normalized_path = dir.tr('/', '\\')
|
108
106
|
result = exec(powershell("New-Item -Path '#{normalized_path}' -ItemType 'directory'"),
|
109
107
|
:acceptable_exit_codes => [0, 1])
|
110
108
|
result.exit_code == 0
|
111
109
|
end
|
112
110
|
|
113
|
-
#Add the provided key/val to the current ssh environment
|
114
|
-
|
115
|
-
|
116
|
-
|
111
|
+
# Add the provided key/val to the current ssh environment
|
112
|
+
# @param [String] key The key to add the value to
|
113
|
+
# @param [String] val The value for the key
|
114
|
+
# @example
|
117
115
|
# host.add_env_var('PATH', '/usr/bin:PATH')
|
118
116
|
def add_env_var key, val
|
119
117
|
key = key.to_s.upcase
|
120
|
-
#see if the key/value pair already exists
|
118
|
+
# see if the key/value pair already exists
|
121
119
|
cur_val = get_env_var(key, true)
|
122
120
|
subbed_val = cur_val.gsub(/#{Regexp.escape(val.gsub(/'|"/, ''))}/, '')
|
123
121
|
if cur_val.empty?
|
124
122
|
exec(powershell("[Environment]::SetEnvironmentVariable('#{key}', '#{val}', 'Machine')"))
|
125
|
-
self.close #refresh the state
|
126
|
-
elsif subbed_val == cur_val #not present, add it
|
123
|
+
self.close # refresh the state
|
124
|
+
elsif subbed_val == cur_val # not present, add it
|
127
125
|
exec(powershell("[Environment]::SetEnvironmentVariable('#{key}', '#{val};#{cur_val}', 'Machine')"))
|
128
|
-
self.close #refresh the state
|
126
|
+
self.close # refresh the state
|
129
127
|
end
|
130
128
|
end
|
131
129
|
|
132
|
-
#Delete the provided key/val from the current ssh environment
|
133
|
-
|
134
|
-
|
135
|
-
|
130
|
+
# Delete the provided key/val from the current ssh environment
|
131
|
+
# @param [String] key The key to delete the value from
|
132
|
+
# @param [String] val The value to delete for the key
|
133
|
+
# @example
|
136
134
|
# host.delete_env_var('PATH', '/usr/bin:PATH')
|
137
135
|
def delete_env_var key, val
|
138
136
|
key = key.to_s.upcase
|
139
|
-
#get the current value of the key
|
137
|
+
# get the current value of the key
|
140
138
|
cur_val = get_env_var(key, true)
|
141
139
|
subbed_val = (cur_val.split(';') - [val.gsub(/'|"/, '')]).join(';')
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
140
|
+
return unless subbed_val != cur_val
|
141
|
+
|
142
|
+
# remove the current key value
|
143
|
+
self.clear_env_var(key)
|
144
|
+
# set to the truncated value
|
145
|
+
self.add_env_var(key, subbed_val)
|
148
146
|
end
|
149
147
|
|
150
|
-
#Return the value of a specific env var
|
151
|
-
|
152
|
-
|
153
|
-
|
148
|
+
# Return the value of a specific env var
|
149
|
+
# @param [String] key The key to look for
|
150
|
+
# @param [Boolean] clean Remove the 'KEY=' and only return the value of the env var
|
151
|
+
# @example
|
154
152
|
# host.get_env_var('path')
|
155
153
|
def get_env_var key, clean = false
|
156
|
-
self.close #refresh the state
|
154
|
+
self.close # refresh the state
|
157
155
|
key = key.to_s.upcase
|
158
156
|
val = exec(Beaker::Command.new("set #{key}"), :accept_all_exit_codes => true).stdout.chomp
|
159
|
-
if val.empty?
|
160
|
-
|
157
|
+
return '' if val.empty?
|
158
|
+
|
159
|
+
val = val.split("\n")[0] # only take the first result
|
160
|
+
if clean
|
161
|
+
val.gsub(/#{key}=/i, '')
|
161
162
|
else
|
162
|
-
val
|
163
|
-
if clean
|
164
|
-
val.gsub(/#{key}=/i,'')
|
165
|
-
else
|
166
|
-
val
|
167
|
-
end
|
163
|
+
val
|
168
164
|
end
|
169
165
|
end
|
170
166
|
|
171
|
-
#Delete the environment variable from the current ssh environment
|
172
|
-
|
173
|
-
|
167
|
+
# Delete the environment variable from the current ssh environment
|
168
|
+
# @param [String] key The key to delete
|
169
|
+
# @example
|
174
170
|
# host.clear_env_var('PATH')
|
175
171
|
def clear_env_var key
|
176
172
|
key = key.to_s.upcase
|
177
173
|
exec(powershell("[Environment]::SetEnvironmentVariable('#{key}', $null, 'Machine')"))
|
178
174
|
exec(powershell("[Environment]::SetEnvironmentVariable('#{key}', $null, 'User')"))
|
179
175
|
exec(powershell("[Environment]::SetEnvironmentVariable('#{key}', $null, 'Process')"))
|
180
|
-
self.close #refresh the state
|
176
|
+
self.close # refresh the state
|
181
177
|
end
|
182
178
|
|
183
179
|
def environment_string env
|
184
180
|
return '' if env.empty?
|
185
|
-
|
181
|
+
|
182
|
+
env_array = self.environment_variable_string_pair_array(env)
|
186
183
|
|
187
184
|
environment_string = ''
|
188
185
|
env_array.each do |env|
|
@@ -195,11 +192,11 @@ module PSWindows::Exec
|
|
195
192
|
env_array = []
|
196
193
|
env.each_key do |key|
|
197
194
|
val = env[key]
|
198
|
-
if val.is_a?(Array)
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
195
|
+
val = if val.is_a?(Array)
|
196
|
+
val.join(':')
|
197
|
+
else
|
198
|
+
val.to_s
|
199
|
+
end
|
203
200
|
# doing this for the key itself & the upcase'd version allows us to remain
|
204
201
|
# backwards compatible
|
205
202
|
# TODO: (Next Major Version) get rid of upcase'd version
|
@@ -216,8 +213,7 @@ module PSWindows::Exec
|
|
216
213
|
# Overrides the {Windows::Exec#ssh_permit_user_environment} method,
|
217
214
|
# since no steps are needed in this setup to allow user ssh environments
|
218
215
|
# to work.
|
219
|
-
def ssh_permit_user_environment
|
220
|
-
end
|
216
|
+
def ssh_permit_user_environment; end
|
221
217
|
|
222
218
|
# Sets the user SSH environment.
|
223
219
|
#
|
@@ -231,18 +227,18 @@ module PSWindows::Exec
|
|
231
227
|
# @api private
|
232
228
|
# @return nil
|
233
229
|
def ssh_set_user_environment(env)
|
234
|
-
#add the env var set to this test host
|
230
|
+
# add the env var set to this test host
|
235
231
|
env.each_pair do |var, value|
|
236
232
|
add_env_var(var, value)
|
237
233
|
end
|
238
234
|
end
|
239
235
|
|
240
|
-
#First path it finds for the command executable
|
241
|
-
|
236
|
+
# First path it finds for the command executable
|
237
|
+
# @param [String] command The command executable to search for
|
242
238
|
#
|
243
239
|
# @return [String] Path to the searched executable or empty string if not found
|
244
240
|
#
|
245
|
-
|
241
|
+
# @example
|
246
242
|
# host.which('ruby')
|
247
243
|
def which(command)
|
248
244
|
where_command = "cmd /C \"where #{command}\""
|
@@ -3,15 +3,13 @@ module PSWindows::File
|
|
3
3
|
|
4
4
|
def tmpfile(_name = '')
|
5
5
|
result = exec(powershell('[System.IO.Path]::GetTempFileName()'))
|
6
|
-
result.stdout.chomp
|
6
|
+
result.stdout.chomp
|
7
7
|
end
|
8
8
|
|
9
9
|
def tmpdir(name = '')
|
10
|
-
tmp_path = exec(powershell('[System.IO.Path]::GetTempPath()')).stdout.chomp
|
10
|
+
tmp_path = exec(powershell('[System.IO.Path]::GetTempPath()')).stdout.chomp
|
11
11
|
|
12
|
-
if name == ''
|
13
|
-
name = exec(powershell('[System.IO.Path]::GetRandomFileName()')).stdout.chomp()
|
14
|
-
end
|
12
|
+
name = exec(powershell('[System.IO.Path]::GetRandomFileName()')).stdout.chomp if name == ''
|
15
13
|
exec(powershell("New-Item -Path '#{tmp_path}' -Force -Name '#{name}' -ItemType 'directory'"))
|
16
14
|
File.join(tmp_path, name)
|
17
15
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module PSWindows::Group
|
2
2
|
include Beaker::CommandFactory
|
3
3
|
|
4
|
-
def group_list
|
4
|
+
def group_list
|
5
5
|
execute('cmd /c echo "" | wmic group where localaccount="true" get name /format:value') do |result|
|
6
6
|
groups = []
|
7
7
|
result.stdout.each_line do |line|
|
@@ -28,10 +28,10 @@ module PSWindows::Group
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def group_present(name, &block)
|
31
|
-
execute("net localgroup /add \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
|
31
|
+
execute("net localgroup /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block)
|
32
32
|
end
|
33
33
|
|
34
34
|
def group_absent(name, &block)
|
35
|
-
execute("net localgroup /delete \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
|
35
|
+
execute("net localgroup /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block)
|
36
36
|
end
|
37
37
|
end
|
@@ -7,25 +7,25 @@ module PSWindows::Pkg
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def check_for_package(_name)
|
10
|
-
#HACK NOOP
|
11
|
-
#raise "Cannot check for package #{name} on #{self}"
|
10
|
+
# HACK: NOOP
|
11
|
+
# raise "Cannot check for package #{name} on #{self}"
|
12
12
|
0
|
13
13
|
end
|
14
14
|
|
15
15
|
def install_package(_name, _cmdline_args = '')
|
16
|
-
#HACK NOOP
|
17
|
-
#raise "Package #{name} cannot be installed on #{self}"
|
16
|
+
# HACK: NOOP
|
17
|
+
# raise "Package #{name} cannot be installed on #{self}"
|
18
18
|
0
|
19
19
|
end
|
20
20
|
|
21
21
|
def uninstall_package(_name, _cmdline_args = '')
|
22
|
-
#HACK NOOP
|
23
|
-
#raise "Package #{name} cannot be uninstalled on #{self}"
|
22
|
+
# HACK: NOOP
|
23
|
+
# raise "Package #{name} cannot be uninstalled on #{self}"
|
24
24
|
0
|
25
25
|
end
|
26
26
|
|
27
|
-
#Examine the host system to determine the architecture, overrides default host determine_if_x86_64 so that wmic is used
|
28
|
-
|
27
|
+
# Examine the host system to determine the architecture, overrides default host determine_if_x86_64 so that wmic is used
|
28
|
+
# @return [Boolean] true if x86_64, false otherwise
|
29
29
|
def determine_if_x86_64
|
30
30
|
identify_windows_architecture.include?('64')
|
31
31
|
end
|
@@ -37,10 +37,10 @@ module PSWindows::Pkg
|
|
37
37
|
arch = nil
|
38
38
|
execute("wmic os get osarchitecture", :accept_all_exit_codes => true) do |result|
|
39
39
|
arch = if result.exit_code == 0
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
result.stdout.include?('64') ? '64' : '32'
|
41
|
+
else
|
42
|
+
identify_windows_architecture_from_os_name_for_win2003
|
43
|
+
end
|
44
44
|
end
|
45
45
|
arch
|
46
46
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module PSWindows::User
|
2
2
|
include Beaker::CommandFactory
|
3
3
|
|
4
|
-
def user_list
|
4
|
+
def user_list
|
5
5
|
execute('cmd /c echo "" | wmic useraccount where localaccount="true" get name /format:value') do |result|
|
6
6
|
users = []
|
7
7
|
result.stdout.each_line do |line|
|
@@ -24,10 +24,10 @@ module PSWindows::User
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def user_present(name, &block)
|
27
|
-
execute("net user /add \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
|
27
|
+
execute("net user /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block)
|
28
28
|
end
|
29
29
|
|
30
30
|
def user_absent(name, &block)
|
31
|
-
execute("net user /delete \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
|
31
|
+
execute("net user /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block)
|
32
32
|
end
|
33
33
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
[
|
1
|
+
['host', 'command_factory', 'command', 'options', 'dsl/wrappers'].each do |lib|
|
2
2
|
require "beaker/#{lib}"
|
3
3
|
end
|
4
4
|
|
5
5
|
module PSWindows
|
6
6
|
class Host < Windows::Host
|
7
|
-
[
|
7
|
+
%w[user group exec pkg file].each do |lib|
|
8
8
|
require "beaker/host/pswindows/#{lib}"
|
9
9
|
end
|
10
10
|
|
@@ -16,12 +16,14 @@ module PSWindows
|
|
16
16
|
|
17
17
|
def external_copy_base
|
18
18
|
return @external_copy_base if @external_copy_base
|
19
|
+
|
19
20
|
@external_copy_base = execute('for %I in (%ALLUSERSPROFILE%) do @echo %~I')
|
20
21
|
@external_copy_base
|
21
22
|
end
|
22
23
|
|
23
24
|
# attr_reader :network_separator, :external_copy_base, :system_temp_path
|
24
25
|
attr_reader :scp_separator, :system_temp_path
|
26
|
+
|
25
27
|
def initialize name, host_hash, options
|
26
28
|
super
|
27
29
|
|
@@ -33,6 +35,5 @@ module PSWindows
|
|
33
35
|
@external_copy_base = nil
|
34
36
|
# @external_copy_base = '/programdata'
|
35
37
|
end
|
36
|
-
|
37
38
|
end
|
38
39
|
end
|