Skip to content

Commit 1094e85

Browse files
committed
Add support to serve /assets/apps
1 parent 5cd0fcf commit 1094e85

File tree

4 files changed

+96
-8
lines changed

4 files changed

+96
-8
lines changed

manifests/apache.pp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
# @summary Setups Apache for Katello development
22
# @api private
33
class katello_devel::apache {
4+
$proxy_no_proxy_uris = ['/pulp', '/pub', '/icons', '/images', '/server-status']
5+
6+
if $katello_devel::enable_iop and !$katello_devel::iop_proxy_assets_apps {
7+
$_proxy_no_proxy_uris = $proxy_no_proxy_uris + ['/assets/apps']
8+
} else {
9+
$_proxy_no_proxy_uris = $proxy_no_proxy_uris
10+
}
11+
412
class { 'foreman::config::apache':
5-
ssl => true,
6-
ssl_cert => $certs::apache::apache_cert,
7-
ssl_key => $certs::apache::apache_key,
8-
ssl_ca => $certs::apache::apache_client_ca_cert,
9-
ssl_chain => $certs::apache::apache_ca_cert,
10-
proxy_backend => "http://localhost:${katello_devel::rails_port}/",
11-
proxy_assets => true,
13+
ssl => true,
14+
ssl_cert => $certs::apache::apache_cert,
15+
ssl_key => $certs::apache::apache_key,
16+
ssl_ca => $certs::apache::apache_client_ca_cert,
17+
ssl_chain => $certs::apache::apache_ca_cert,
18+
proxy_backend => "http://localhost:${katello_devel::rails_port}/",
19+
proxy_assets => true,
20+
proxy_no_proxy_uris => $_proxy_no_proxy_uris,
1221
}
1322

1423
# required by configuration in katello/katello-apache-ssl.conf
@@ -18,5 +27,11 @@
1827
ssl_content => file('katello/katello-apache-ssl.conf'),
1928
}
2029

30+
if $katello_devel::iop_proxy_assets_apps {
31+
foreman::config::apache::fragment { 'katello-iop-assets':
32+
ssl_content => 'ProxyPass /assets/apps http://localhost:8002/',
33+
}
34+
}
35+
2136
User<|title == apache|> { groups +> $katello_devel::group }
2237
}

manifests/init.pp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
# @param enable_iop
7878
# Enable iop integration
7979
#
80+
# @param iop_proxy_assets_apps
81+
# Configure Apache to proxy /assets/apps to a backend running on localhost:8002
82+
#
8083
class katello_devel (
8184
String $user = undef,
8285
Stdlib::Absolutepath $deployment_dir = '/home/vagrant',
@@ -103,7 +106,12 @@
103106
Boolean $rex_manage_repo = true,
104107
Hash[String, Any] $rails_cache_store = { 'type' => 'redis' },
105108
Boolean $enable_iop = false,
109+
Boolean $iop_proxy_assets_apps = false,
106110
) inherits katello_devel::params {
111+
if $iop_proxy_assets_apps and !$enable_iop {
112+
fail('iop_proxy_assets_apps requires enable_iop to be true')
113+
}
114+
107115
$group = $user
108116

109117
$changeme = '$6$lb06/IMy$nZhR3LkR2tUunTQm68INFWMyb/8VA2vfYq0/fRzLoKSfuri.vvtjeLJf9V.wuHzw92.aw8NgUlJchMy/qK25x.'

spec/acceptance/iop_spec.rb

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper_acceptance'
22

3-
describe 'Scenario: install katello_devel' do
3+
describe 'Scenario: install katello_devel with IoP' do
44
let(:manifest) do
55
<<-PUPPET
66
class { 'katello_devel':
@@ -13,4 +13,30 @@ class { 'katello_devel':
1313
it 'applies with no errors' do
1414
apply_manifest(manifest, catch_failures: true)
1515
end
16+
17+
describe file('/etc/httpd/conf.d/05-foreman-ssl.conf') do
18+
it { is_expected.to be_file }
19+
its(:content) { should match /ProxyPass \/assets\/apps !/ }
20+
end
21+
end
22+
23+
describe 'Scenario: install katello_devel with IoP proxy assets apps' do
24+
let(:manifest) do
25+
<<-PUPPET
26+
class { 'katello_devel':
27+
user => 'vagrant',
28+
enable_iop => true,
29+
iop_proxy_assets_apps => true,
30+
}
31+
PUPPET
32+
end
33+
34+
it 'applies with no errors' do
35+
apply_manifest(manifest, catch_failures: true)
36+
end
37+
38+
describe file('/etc/httpd/conf.d/05-foreman-ssl.d/katello-iop-assets.conf') do
39+
it { is_expected.to be_file }
40+
its(:content) { should match /ProxyPass \/assets\/apps http:\/\/localhost:8002\// }
41+
end
1642
end

spec/classes/katello_devel_spec.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,45 @@
253253
it { is_expected.to contain_katello_devel__plugin('theforeman/foreman_remote_execution') }
254254
it { is_expected.to contain_katello_devel__git_repo('foreman_remote_execution').with_revision('1.2.z') }
255255
end
256+
257+
context 'with enable_iop true' do
258+
let(:params) do
259+
{
260+
:user => 'vagrant',
261+
:enable_iop => true,
262+
}
263+
end
264+
265+
it { is_expected.to compile.with_all_deps }
266+
it { is_expected.to contain_class('katello_devel::iop') }
267+
it { is_expected.to contain_class('katello_devel::apache') }
268+
end
269+
270+
context 'with iop_proxy_assets_apps true' do
271+
let(:params) do
272+
{
273+
:user => 'vagrant',
274+
:enable_iop => true,
275+
:iop_proxy_assets_apps => true,
276+
}
277+
end
278+
279+
it { is_expected.to compile.with_all_deps }
280+
it { is_expected.to contain_class('katello_devel::iop') }
281+
it { is_expected.to contain_class('katello_devel::apache') }
282+
end
283+
284+
context 'with iop_proxy_assets_apps true but enable_iop false' do
285+
let(:params) do
286+
{
287+
:user => 'vagrant',
288+
:enable_iop => false,
289+
:iop_proxy_assets_apps => true,
290+
}
291+
end
292+
293+
it { is_expected.to compile.and_raise_error(/iop_proxy_assets_apps requires enable_iop to be true/) }
294+
end
256295
end
257296
end
258297
end

0 commit comments

Comments
 (0)