-
Notifications
You must be signed in to change notification settings - Fork 50
/
install_spec.rb
96 lines (82 loc) · 3.18 KB
/
install_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
require 'spec_helper'
describe 'peadm::subplans::install' do
# Include the BoltSpec library functions
include BoltSpec::Plans
before(:each) do
allow_any_task
allow_any_plan
allow_any_command
allow_task('peadm::precheck').return_for_targets(
'primary' => {
'hostname' => 'primary',
'platform' => 'el-7.11-x86_64'
},
)
#########
## <🤮>
# rubocop:disable AnyInstance
allow(Tempfile).to receive(:new).and_call_original
allow(Pathname).to receive(:new).and_call_original
allow(Puppet::FileSystem).to receive(:exist?).and_call_original
allow_any_instance_of(BoltSpec::Plans::MockExecutor).to receive(:module_file_id).and_call_original
mockfile = instance_double('Tempfile', path: '/mock', write: nil, flush: nil, close: nil, unlink: nil)
mockpath = instance_double('Pathname', absolute?: true)
allow(Tempfile).to receive(:new).with('peadm').and_return(mockfile)
allow(Pathname).to receive(:new).with('/mock').and_return(mockpath)
allow(Puppet::FileSystem).to receive(:exist?).with('/mock').and_return(true)
allow_any_instance_of(BoltSpec::Plans::MockExecutor).to receive(:module_file_id).with('/mock').and_return('/mock')
allow_upload('/mock')
# rubocop:enable AnyInstance
## </🤮>
##########
end
it 'minimum variables to run' do
params = {
'primary_host' => 'primary',
'console_password' => 'puppetlabs',
'version' => '2019.8.12',
}
expect(run_plan('peadm::subplans::install', params)).to be_ok
end
it 'installs 2023.2 without r10k_known_hosts' do
params = {
'primary_host' => 'primary',
'console_password' => 'puppetlabs',
'version' => '2023.2.0',
'r10k_remote' => 'git@github.com:puppetlabs/nothing',
'r10k_private_key_content' => '-----BEGINfoo',
}
expect(run_plan('peadm::subplans::install', params)).to be_ok
end
it 'fails if 2023.3+ and r10k_private_key set but r10k_known_hosts not set' do
params = {
'primary_host' => 'primary',
'console_password' => 'puppetlabs',
'version' => '2023.3.0',
'r10k_remote' => 'git@github.com:puppetlabs/nothing',
'r10k_private_key_content' => '-----BEGINfoo',
'permit_unsafe_versions' => true,
}
result = run_plan('peadm::subplans::install', params)
expect(result).not_to be_ok
expect(result.value.message).to match(%r{Puppet Enterprise 2023\.3\+ .*requires host key verification})
end
it 'installs 2023.3+ with r10k_private_key and r10k_known_hosts' do
params = {
'primary_host' => 'primary',
'console_password' => 'puppetlabs',
'version' => '2023.3.0',
'r10k_remote' => 'git@github.com:puppetlabs/nothing',
'r10k_private_key_content' => '-----BEGINfoo',
'r10k_known_hosts' => [
{
'name' => 'test',
'type' => 'key-type',
'key' => 'abcdef',
},
],
'permit_unsafe_versions' => true,
}
expect(run_plan('peadm::subplans::install', params)).to be_ok
end
end