-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathkatello_devel_spec.rb
261 lines (230 loc) · 9.89 KB
/
katello_devel_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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
require 'spec_helper'
describe 'katello_devel' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }
describe 'with minimal params' do
let(:params) do
{
:user => 'vagrant',
:oauth_key => 'OAUTH_KEY',
:oauth_secret => 'OAUTH_SECRET',
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_package('nodejs').with_provider('dnfmodule').with_ensure('18') }
it { is_expected.to contain_package('npm') }
it { is_expected.to contain_class('katello_devel::install') }
it { is_expected.to contain_class('katello_devel::config') }
it { is_expected.to contain_katello_devel__plugin('katello/katello') }
it { is_expected.to contain_katello_devel__git_repo('foreman') }
it { is_expected.to contain_katello_devel__git_repo('katello') }
it { is_expected.to contain_katello_devel__git_repo('foreman_remote_execution') }
it { is_expected.to contain_class('katello_devel::database') }
it { is_expected.not_to contain_katello_devel__bundle('exec rails s -d') }
it { is_expected.to contain_file('/usr/local/bin/ktest').with_content(%r{^FOREMAN_PATH=/home/vagrant/foreman$}) }
it { verify_exact_contents(catalogue, '/home/vagrant/foreman/.env', [
'BIND=0.0.0.0',
'PORT=3000',
"RAILS_STARTUP='puma -w 2 -p $PORT --preload'",
"WEBPACK_OPTS='--https --key /etc/pki/katello/private/katello-apache.key --cert /etc/pki/katello/certs/katello-apache.crt --cacert /etc/pki/katello/certs/katello-default-ca.crt --host 0.0.0.0 --public #{facts[:fqdn]}'",
"REDUX_LOGGER=false",
]) }
it do
verify_exact_contents(catalogue, '/home/vagrant/foreman/config/settings.yaml', [
':unattended: true',
':login: true',
':require_ssl: false',
':locations_enabled: true',
':organizations_enabled: true',
':oauth_active: true',
':oauth_map_users: true',
':oauth_consumer_key: OAUTH_KEY',
':oauth_consumer_secret: OAUTH_SECRET',
':ssl_ca_file: /home/vagrant/foreman-certs/proxy_ca.pem',
':ssl_certificate: /home/vagrant/foreman-certs/client_cert.pem',
':ssl_priv_key: /home/vagrant/foreman-certs/client_key.pem',
':ssl_client_dn_env: HTTP_SSL_CLIENT_S_DN',
':ssl_client_verify_env: HTTP_SSL_CLIENT_VERIFY',
':ssl_client_cert_env: HTTP_SSL_CLIENT_CERT',
':webpack_dev_server: true',
':webpack_dev_server_https: true',
':assets_debug: false',
':rails_cache_store:',
' :type: redis',
' :urls:',
' - redis://localhost:6379/4',
' :options:',
' :compress: true',
' :namespace: foreman',
':loggers:',
' :audit:',
' :enabled: true',
' :level: error',
' :taxonomy:',
' :enabled: true',
' :level: error',
' :dynflow:',
' :enabled: true',
' :level: info',
])
end
it do
verify_exact_contents(catalogue, '/home/vagrant/foreman/config/settings.plugins.d/katello.yaml', [
':katello:',
' :rest_client_timeout: 3600',
' :katello_applicability: true',
' :candlepin:',
' :url: https://localhost:23443/candlepin',
' :oauth_key: OAUTH_KEY',
' :oauth_secret: OAUTH_SECRET',
' :ca_cert_file: /etc/pki/katello/certs/katello-default-ca.crt',
' :candlepin_events:',
' :ssl_cert_file: /home/vagrant/foreman-certs/client_cert.pem',
' :ssl_key_file: /home/vagrant/foreman-certs/client_key.pem',
' :ssl_ca_file: /etc/pki/katello/certs/katello-default-ca.crt',
' :katello_applicability: true',
])
end
it do
verify_exact_contents(catalogue, '/home/vagrant/foreman/bundler.d/katello.local.rb', [
"gemspec :path => '../katello', :development_group => 'katello_dev', :name => 'katello'",
"eval_gemfile('/home/vagrant/katello/gemfile.d/test.rb')"
])
end
end
describe 'with modulestream_nodejs' do
let(:params) do
{
:user => 'vagrant',
:oauth_key => 'OAUTH_KEY',
:oauth_secret => 'OAUTH_SECRET',
:modulestream_nodejs => '14',
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_package('nodejs').with_provider('dnfmodule').with_ensure('14') }
it { is_expected.to contain_package('npm') }
end
describe 'with github_username' do
let(:params) do
{
:user => 'vagrant',
:github_username => 'foo',
}
end
it { is_expected.to contain_class('katello_devel::install') }
it { is_expected.to contain_class('katello_devel::config') }
it { is_expected.to contain_class('katello_devel::database') }
it { is_expected.not_to contain_katello_devel__bundle('exec rails s -d') }
it { is_expected.to contain_file('/usr/local/bin/ktest').with_content(%r{^FOREMAN_PATH=/home/vagrant/foreman$}) }
end
describe 'with blank github_username' do
let(:params) do
{
:user => 'vagrant',
:github_username => '',
}
end
it { is_expected.to contain_class('katello_devel::install') }
it { is_expected.to contain_class('katello_devel::config') }
it { is_expected.to contain_class('katello_devel::database') }
it { is_expected.not_to contain_katello_devel__bundle('exec rails s -d') }
it { is_expected.to contain_file('/usr/local/bin/ktest').with_content(%r{^FOREMAN_PATH=/home/vagrant/foreman$}) }
end
describe 'with proxy registration' do
let(:params) do
{
:user => 'vagrant',
}
end
let(:pre_condition) { 'include "foreman_proxy"' }
it { is_expected.to contain_class('Foreman_proxy::Register') }
it { is_expected.to contain_katello_devel__bundle('exec rails s -d') }
end
describe 'unmanaged foreman repo' do
let(:params) do
{
:user => 'vagrant',
:foreman_manage_repo => false,
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.not_to contain_katello_devel__git_repo('foreman') }
end
describe 'extra plugins' do
context 'with foo plugin' do
let(:params) do
{
:user => 'vagrant',
:extra_plugins => ['theforeman/foo'],
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_katello_devel__plugin('theforeman/foo') }
it { is_expected.to contain_katello_devel__git_repo('foo') }
end
context 'with an additional plugin with unmanaged source repository' do
let(:params) do
{
:user => 'vagrant',
:extra_plugins => ['theforeman/foo', { 'name' => 'customorg/bar', 'manage_repo' => false }],
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_katello_devel__plugin('theforeman/foo') }
it { is_expected.to contain_katello_devel__git_repo('foo') }
it { is_expected.to contain_katello_devel__plugin('customorg/bar') }
it { is_expected.not_to contain_katello_devel__git_repo('bar') }
end
context 'with an additional plugin with specified repository branch' do
let(:params) do
{
:user => 'vagrant',
:extra_plugins => ['theforeman/foo', { 'name' => 'customorg/bar', 'scm_revision' => '1.2.3-stable' }],
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_katello_devel__plugin('theforeman/foo') }
it { is_expected.to contain_katello_devel__git_repo('foo') }
it { is_expected.to contain_katello_devel__plugin('customorg/bar') }
it { is_expected.to contain_katello_devel__git_repo('bar').with_source('customorg/bar') }
it { is_expected.to contain_katello_devel__git_repo('bar').with_revision('1.2.3-stable') }
end
context 'with unmanaged katello repo' do
let(:params) do
{
:user => 'vagrant',
:katello_manage_repo => false,
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_katello_devel__plugin('katello/katello') }
it { is_expected.not_to contain_katello_devel__git_repo('katello') }
end
context 'with unmanaged foreman_remote_execution repo' do
let(:params) do
{
:user => 'vagrant',
:rex_manage_repo => false,
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_katello_devel__plugin('theforeman/foreman_remote_execution') }
it { is_expected.not_to contain_katello_devel__git_repo('foreman_remote_execution') }
end
end
context 'with custom foreman_remote_execution repo revision' do
let(:params) do
{
:user => 'vagrant',
:rex_scm_revision => '1.2.z',
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_katello_devel__plugin('theforeman/foreman_remote_execution') }
it { is_expected.to contain_katello_devel__git_repo('foreman_remote_execution').with_revision('1.2.z') }
end
end
end
end