beaker 4.36.0 → 4.37.1

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
  SHA256:
3
- metadata.gz: 156fe839f18012ce2b3dcdc385123d328158e21f33e36b6e11debc5a67f51cee
4
- data.tar.gz: 0dac80928255da4606d5f5710ffb3f569c93afa20d52039318150acafb883ed5
3
+ metadata.gz: f0d409c6cd07fc46ac641d68560cfe5ab40515df89f1a15bf6521b9f3bc044d9
4
+ data.tar.gz: e4d0909c8e1cb8190d35e740ee5c954f9e50241b4e763f416ed2d1374c92d2c2
5
5
  SHA512:
6
- metadata.gz: '005694a4e2e756da6b1221833476bb0789398b0a78e9923ec0bb16a0081b21fbb1a33a8a7f56811da58f3225a0fb4f3e26f2a00dac91745197e20cefa64fde12'
7
- data.tar.gz: 443607f9a33182feef6360a6af2d1956457a581a15156e5c9c2498a132427971332a19ffaf9b18218af9f9f9031c2420a7a2b9a8713b42ceecab50d0a5e44fff
6
+ metadata.gz: 45402a7f027808b4a3b3b7e797cf6fcdfb620d3dd7af45e0e07771fb289c21f7bb65265698a1225eeac15629542738cd0e1f67ae5dfd29bb1e1abeef9f5db554
7
+ data.tar.gz: 48f6623ca4b0f61dd737f1ef16d1258558aa238ba57bbf8596cd69b3403d5b3883d8d89977d73fd637c526b5665fe12d03af3fd68d38c37d646031cffac506d0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.37.1](https://github.com/voxpupuli/beaker/tree/4.37.1) (2022-07-27)
4
+
5
+ ## Fixed
6
+
7
+ - macOS PE tarballs include arch now ([#1747](https://github.com/voxpupuli/beaker/pull/1747))
8
+
9
+ ## [4.37.0](https://github.com/voxpupuli/beaker/tree/4.37.0) (2022-06-27)
10
+
11
+ ## Added
12
+
13
+ - Add support for Win32-OpenSSH ([#1744](https://github.com/voxpupuli/beaker/pull/1744))
14
+
15
+ ## Fixed
16
+
17
+ - Create ~/.ssh on Windows if it doesn't exist ([#1745](https://github.com/voxpupuli/beaker/pull/1745))
18
+
19
+ ## [4.36.1](https://github.com/voxpupuli/beaker/tree/4.36.1) (2022-06-16)
20
+
21
+ ## Fixed
22
+
23
+ - (maint) Remove /etc/environment file for ubuntu2204 ([#1742](https://github.com/voxpupuli/beaker/pull/1742))
24
+
3
25
  ## [4.36.0](https://github.com/voxpupuli/beaker/tree/4.36.0) (2022-05-30)
4
26
 
5
27
  ## Added
@@ -118,7 +118,15 @@ module Mac::Pkg
118
118
 
119
119
  variant, version, arch, codename = self['platform'].to_array
120
120
  release_file = "/repos/apple/#{version}/#{puppet_collection}/#{arch}/puppet-agent-*"
121
- download_file = "puppet-agent-#{variant}-#{version}.tar.gz"
121
+
122
+ # macOS puppet-agent tarballs haven't always included arch
123
+ agent_version = opts[:puppet_agent_version]
124
+ download_file = if agent_version && (agent_version.to_f < 6.28 || agent_version.to_f < 7.18)
125
+ "puppet-agent-#{variant}-#{version}.tar.gz"
126
+ else
127
+ "puppet-agent-#{variant}-#{version}-#{arch}.tar.gz"
128
+ end
129
+
122
130
  return '', release_file, download_file
123
131
  end
124
132
 
@@ -306,7 +306,7 @@ module Unix::Exec
306
306
  directory = tmpdir()
307
307
  exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
308
308
  exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
309
- exec(Beaker::Command.new("echo '' >/etc/environment")) if self['platform'] =~ /ubuntu-20.04/
309
+ exec(Beaker::Command.new("echo '' >/etc/environment")) if self['platform'] =~ /ubuntu-2(0|2).04/
310
310
  when /(free|open)bsd/
311
311
  exec(Beaker::Command.new("sudo perl -pi -e 's/^#?PermitUserEnvironment no/PermitUserEnvironment yes/' /etc/ssh/sshd_config"), {:pty => true} )
312
312
  else
@@ -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 dir
126
- cmd = "mkdir -p \"#{dir}\""
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
- network_path = path.gsub('\\', scp_separator)
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("windows/file.rb:scp_path: ssh server not recognized: '#{determine_ssh_server}'")
68
+ raise ArgumentError, "windows/file.rb:scp_path: ssh server not recognized: '#{determine_ssh_server}'"
67
69
  end
68
70
  end
69
71
 
@@ -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
- @ssh_server = :bitvise if status =~ /4 RUNNING/
42
- logger.debug("windows.rb:determine_ssh_server: determined ssh server: '#{@ssh_server}'")
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
 
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '4.36.0'
3
+ STRING = '4.37.1'
4
4
  end
5
5
  end
@@ -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.36.0
4
+ version: 4.37.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-30 00:00:00.000000000 Z
11
+ date: 2022-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec