beaker 4.36.1 → 4.37.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/beaker/host/windows/exec.rb +9 -3
- data/lib/beaker/host/windows/file.rb +4 -2
- data/lib/beaker/host/windows.rb +8 -2
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/host/windows/exec_spec.rb +30 -0
- data/spec/beaker/host/windows/file_spec.rb +32 -0
- data/spec/beaker/host/windows_spec.rb +23 -1
- 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: 147352406c9fe42bb99fad85f3c583a2be345385191eafe9e685dce331025c21
|
4
|
+
data.tar.gz: 4fe85be2e9ef2e81d59be68d7c83f573648f3d36bc25e3c67fbf8c53e3786de0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2d94a7dccbc611478c859ca640c317e7624a3f6c9ac5d2857c91f24b15c36e52537ab99a412676c7bf7978b6fcf85bfc67a7c1931183e64b080fb86b38b4bd0
|
7
|
+
data.tar.gz: 3af90b7213b32d74a5f5340132ae428eab9a991fc93bbafb69a4a2a6db4d3f9f5e255d3da0bb965401fb05ba552f8d9deafef2c7c5d3899e404e04975e504149
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [4.37.0](https://github.com/voxpupuli/beaker/tree/4.37.0) (2022-06-27)
|
4
|
+
|
5
|
+
## Added
|
6
|
+
|
7
|
+
- Add support for Win32-OpenSSH ([#1744](https://github.com/voxpupuli/beaker/pull/1744))
|
8
|
+
|
9
|
+
## Fixed
|
10
|
+
|
11
|
+
- Create ~/.ssh on Windows if it doesn't exist ([#1745](https://github.com/voxpupuli/beaker/pull/1745))
|
12
|
+
|
3
13
|
## [4.36.1](https://github.com/voxpupuli/beaker/tree/4.36.1) (2022-06-16)
|
4
14
|
|
5
15
|
## Fixed
|
@@ -120,10 +120,16 @@ module Windows::Exec
|
|
120
120
|
end
|
121
121
|
|
122
122
|
# Create the provided directory structure on the host
|
123
|
-
# @param [String] dir The directory structure to create on the host
|
123
|
+
# @param [String,Pathname] dir The directory structure to create on the host
|
124
124
|
# @return [Boolean] True, if directory construction succeeded, otherwise False
|
125
|
-
def mkdir_p
|
126
|
-
|
125
|
+
def mkdir_p(dir)
|
126
|
+
# single or double quotes will disable ~ expansion, so only quote if we have to
|
127
|
+
str = dir.to_s
|
128
|
+
cmd = if str.start_with?('~') && !str.include?(' ')
|
129
|
+
"mkdir -p #{str}"
|
130
|
+
else
|
131
|
+
"mkdir -p \"#{str}\""
|
132
|
+
end
|
127
133
|
result = exec(Beaker::Command.new(cmd), :acceptable_exit_codes => [0, 1])
|
128
134
|
result.exit_code == 0
|
129
135
|
end
|
@@ -59,11 +59,13 @@ module Windows::File
|
|
59
59
|
case determine_ssh_server
|
60
60
|
when :bitvise
|
61
61
|
# swap out separators
|
62
|
-
|
62
|
+
path.gsub('\\', scp_separator)
|
63
63
|
when :openssh
|
64
64
|
path
|
65
|
+
when :win32_openssh
|
66
|
+
path.gsub('\\', '/')
|
65
67
|
else
|
66
|
-
raise ArgumentError
|
68
|
+
raise ArgumentError, "windows/file.rb:scp_path: ssh server not recognized: '#{determine_ssh_server}'"
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
data/lib/beaker/host/windows.rb
CHANGED
@@ -38,8 +38,14 @@ module Windows
|
|
38
38
|
return @ssh_server if @ssh_server
|
39
39
|
@ssh_server = :openssh
|
40
40
|
status = execute('cmd.exe /c sc query BvSshServer', :accept_all_exit_codes => true)
|
41
|
-
|
42
|
-
|
41
|
+
if status =~ /4 RUNNING/
|
42
|
+
@ssh_server = :bitvise
|
43
|
+
else
|
44
|
+
status = execute('cmd.exe /c sc qc sshd', :accept_all_exit_codes => true)
|
45
|
+
if status =~ /C:\\Windows\\System32\\OpenSSH\\sshd\.exe/
|
46
|
+
@ssh_server = :win32_openssh
|
47
|
+
end
|
48
|
+
end
|
43
49
|
@ssh_server
|
44
50
|
end
|
45
51
|
|
data/lib/beaker/version.rb
CHANGED
@@ -96,5 +96,35 @@ module Beaker
|
|
96
96
|
expect( instance.mv(origin, destination, false) ).to be === 0
|
97
97
|
end
|
98
98
|
end
|
99
|
+
|
100
|
+
context 'mkdir_p' do
|
101
|
+
let(:path) { '~/.ssh' }
|
102
|
+
let(:result) do
|
103
|
+
result = Beaker::Result.new(nil, '')
|
104
|
+
result.exit_code = 0
|
105
|
+
result
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'accepts Pathname arguments' do
|
109
|
+
expect( instance ).to receive(:exec).with(having_attributes(command: "mkdir -p #{path}"), anything).and_return(result)
|
110
|
+
expect(instance.mkdir_p(Pathname.new(path))).to eq(true)
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'omits quotes if the path starts with ~ and does not contain spaces' do
|
114
|
+
expect( instance ).to receive(:exec).with(having_attributes(command: "mkdir -p #{path}"), anything).and_return(result)
|
115
|
+
expect(instance.mkdir_p(path)).to eq(true)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'double quotes paths containing spaces' do
|
119
|
+
expect( instance ).to receive(:exec).with(having_attributes(command: "mkdir -p \"~/.foo bar\""), anything).and_return(result)
|
120
|
+
expect(instance.mkdir_p("~/.foo bar")).to eq(true)
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'returns false if the command failed' do
|
124
|
+
result.exit_code = 1
|
125
|
+
expect( instance ).to receive(:exec).with(having_attributes(command: "mkdir -p #{path}"), anything).and_return(result)
|
126
|
+
expect(instance.mkdir_p(path)).to eq(false)
|
127
|
+
end
|
128
|
+
end
|
99
129
|
end
|
100
130
|
end
|
@@ -51,5 +51,37 @@ module Beaker
|
|
51
51
|
host.ls_ld( path )
|
52
52
|
end
|
53
53
|
end
|
54
|
+
|
55
|
+
describe "#scp_to" do
|
56
|
+
let(:path) { 'C:\Windows' }
|
57
|
+
|
58
|
+
it 'replaces backslashes with ??? when using BitVise and cmd' do
|
59
|
+
allow(host).to receive(:determine_ssh_server).and_return(:bitvise)
|
60
|
+
expect(host.scp_path(path)).to eq('C:\Windows')
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'replaces backslashes with forward slashes when using BitVise and powershell' do
|
64
|
+
host = make_host('name', platform: 'windows', is_cygwin: false)
|
65
|
+
allow(host).to receive(:determine_ssh_server).and_return(:bitvise)
|
66
|
+
expect(host.scp_path(path)).to eq('C:/Windows')
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'leaves backslashes as is when using cygwin' do
|
70
|
+
allow(host).to receive(:determine_ssh_server).and_return(:openssh)
|
71
|
+
expect(host.scp_path(path)).to eq('C:\Windows')
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'replace backslashes with forward slashes when using Win32-OpenSSH' do
|
75
|
+
allow(host).to receive(:determine_ssh_server).and_return(:win32_openssh)
|
76
|
+
expect(host.scp_path(path)).to eq('C:/Windows')
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'raises if the server can not be recognized' do
|
80
|
+
allow(host).to receive(:determine_ssh_server).and_return(:unknown)
|
81
|
+
expect {
|
82
|
+
host.scp_path(path)
|
83
|
+
}.to raise_error(ArgumentError, "windows/file.rb:scp_path: ssh server not recognized: 'unknown'")
|
84
|
+
end
|
85
|
+
end
|
54
86
|
end
|
55
87
|
end
|
@@ -37,7 +37,7 @@ module Windows
|
|
37
37
|
|
38
38
|
describe '#determine_ssh_server' do
|
39
39
|
it 'does not care about return codes from the execute call' do
|
40
|
-
expect( host ).to receive( :execute ).with( anything, :accept_all_exit_codes => true )
|
40
|
+
expect( host ).to receive( :execute ).with( anything, :accept_all_exit_codes => true ).twice
|
41
41
|
host.determine_ssh_server
|
42
42
|
end
|
43
43
|
|
@@ -53,6 +53,28 @@ module Windows
|
|
53
53
|
expect( host.determine_ssh_server ).to be === :bitvise
|
54
54
|
end
|
55
55
|
|
56
|
+
it 'reads Windows OpenSSH status correctly' do
|
57
|
+
allow(host).to receive(:execute)
|
58
|
+
.with('cmd.exe /c sc query BvSshServer', anything).and_return(bitvise_check_output(:failure))
|
59
|
+
allow(host).to receive(:execute)
|
60
|
+
.with('cmd.exe /c sc qc sshd', anything).and_return(<<~END)
|
61
|
+
[SC] QueryServiceConfig SUCCESS
|
62
|
+
|
63
|
+
SERVICE_NAME: sshd
|
64
|
+
TYPE : 10 WIN32_OWN_PROCESS
|
65
|
+
START_TYPE : 2 AUTO_START
|
66
|
+
ERROR_CONTROL : 1 NORMAL
|
67
|
+
BINARY_PATH_NAME : C:\\Windows\\System32\\OpenSSH\\sshd.exe
|
68
|
+
LOAD_ORDER_GROUP :
|
69
|
+
TAG : 0
|
70
|
+
DISPLAY_NAME : OpenSSH SSH Server
|
71
|
+
DEPENDENCIES :
|
72
|
+
SERVICE_START_NAME : LocalSystem
|
73
|
+
END
|
74
|
+
|
75
|
+
expect(host.determine_ssh_server).to eq :win32_openssh
|
76
|
+
end
|
77
|
+
|
56
78
|
it 'returns old value if it has already determined before' do
|
57
79
|
ssh_server_before = host.instance_variable_get( :@ssh_server )
|
58
80
|
test_value = :test916
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.37.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|