Skip to content

Commit 0f1d3b2

Browse files
ianballouekohl
authored andcommitted
Refs #37325 - clean up tests + add postgres acceptance
1 parent d9a21db commit 0f1d3b2

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

manifests/plugin/container_gateway.pp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
Optional[Stdlib::Host] $postgresql_host = undef,
4444
Optional[Stdlib::Port] $postgresql_port = undef,
4545
String $postgresql_database = 'container_gateway',
46-
String $postgresql_user = pick($foreman_proxy::globals::user, 'foreman-proxy'),
46+
Optional[String[1]] $postgresql_user = undef,
4747
Optional[String] $postgresql_password = undef
4848
) {
4949
foreman_proxy::plugin::module { 'container_gateway':
@@ -53,14 +53,14 @@
5353
listen_on => $listen_on,
5454
}
5555

56-
if $foreman_proxy::plugin::container_gateway::manage_postgresql and
57-
$foreman_proxy::plugin::container_gateway::database_backend != 'sqlite' {
56+
if $manage_postgresql and $database_backend == 'postgres' {
5857
include postgresql::server
59-
postgresql::server::db { $foreman_proxy::plugin::container_gateway::postgresql_database:
60-
user => $foreman_proxy::plugin::container_gateway::postgresql_user,
58+
$_postgresql_user = pick($postgresql_user, $foreman_proxy::user)
59+
postgresql::server::db { $postgresql_database:
60+
user => $_postgresql_user,
6161
password => postgresql::postgresql_password(
62-
$foreman_proxy::plugin::container_gateway::postgresql_user,
63-
$foreman_proxy::plugin::container_gateway::postgresql_password.lest || {
62+
$_postgresql_user,
63+
$postgresql_password.lest || {
6464
extlib::cache_data('container_gateway_cache_data', 'db_password', extlib::random_password(32))
6565
}
6666
),

spec/acceptance/container_gateway_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@
66
include_examples 'the example', 'container_gateway.pp'
77

88
it_behaves_like 'the default foreman proxy application'
9+
10+
describe service("postgresql") do
11+
it { is_expected.to be_enabled }
12+
it { is_expected.to be_running }
13+
end
914
end

spec/classes/foreman_proxy__plugin__container_gateway_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
':enabled: https',
1515
":pulp_endpoint: https://#{facts[:fqdn]}",
1616
':sqlite_db_path: /var/lib/foreman-proxy/smart_proxy_container_gateway.db',
17-
':db_connection_string: postgres://foreman-proxy:@:/container_gateway'
17+
':db_connection_string: postgres://:@:/container_gateway'
1818
])
1919
end
2020
end
@@ -37,7 +37,6 @@
3737
':enabled: https',
3838
':pulp_endpoint: https://test.example.com',
3939
':sqlite_db_path: /dev/null.db',
40-
':sqlite_timeout: 12345',
4140
':db_connection_string: postgres://foreman-proxy:[email protected]:5432/container_gateway'
4241
])
4342
end

templates/plugin/container_gateway.yml.erb

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
<% if scope.lookupvar("foreman_proxy::plugin::container_gateway::sqlite_timeout") -%>
77
:sqlite_timeout: <%= scope.lookupvar("foreman_proxy::plugin::container_gateway::sqlite_timeout") %>
88
<% end -%>
9-
<% if scope.lookupvar("foreman_proxy::plugin::container_gateway::database_backend") == 'postgres' -%>
10-
:db_connection_string: <%=
11-
"#{scope.lookupvar("foreman_proxy::plugin::container_gateway::database_backend")}://" \
12-
"#{scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_user")}:" \
13-
"#{scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_password")}@" \
14-
"#{scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_host")}:" \
15-
"#{scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_port")}/" \
16-
"#{scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_database")}"
17-
%>
9+
<% if scope.lookupvar('foreman_proxy::plugin::container_gateway::database_backend') == 'postgres' -%>
10+
:db_connection_string: <%= [
11+
scope.lookupvar('foreman_proxy::plugin::container_gateway::database_backend'),
12+
'://',
13+
scope.lookupvar('foreman_proxy::plugin::container_gateway::postgresql_user'),
14+
':',
15+
scope.lookupvar('foreman_proxy::plugin::container_gateway::postgresql_password'),
16+
'@',
17+
scope.lookupvar('foreman_proxy::plugin::container_gateway::postgresql_host'),
18+
':',
19+
scope.lookupvar('foreman_proxy::plugin::container_gateway::postgresql_port'),
20+
'/',
21+
scope.lookupvar('foreman_proxy::plugin::container_gateway::postgresql_database')
22+
].join %>
1823
<% end -%>
1924
<% if scope.lookupvar("foreman_proxy::plugin::container_gateway::database_backend") == 'sqlite' -%>
2025
:db_connection_string: <%=

0 commit comments

Comments
 (0)