Skip to content

Commit 2603379

Browse files
authored
Merge pull request #2283 from ekohl/add-mod_auth_openidc-acceptance-test
Manage DNF module for mod_auth_openidc
2 parents b0fff67 + 8417c0b commit 2603379

File tree

11 files changed

+98
-8
lines changed

11 files changed

+98
-8
lines changed

manifests/mod/auth_basic.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
# @see https://httpd.apache.org/docs/current/mod/mod_auth_basic.html for additional documentation.
55
#
66
class apache::mod::auth_basic {
7+
include apache::mod::authn_core
78
::apache::mod { 'auth_basic': }
89
}

manifests/mod/auth_cas.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
}
116116

117117
include apache
118+
include apache::mod::authn_core
118119
::apache::mod { 'auth_cas': }
119120

120121
file { $cas_cookie_path:

manifests/mod/auth_mellon.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
Optional[Integer] $mellon_post_count = undef
3535
) inherits apache::params {
3636
include apache
37+
include apache::mod::authn_core
3738
::apache::mod { 'auth_mellon': }
3839

3940
# Template uses

manifests/mod/auth_openidc.pp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
# @summary
22
# Installs and configures `mod_auth_openidc`.
3-
#
3+
#
4+
# @param manage_dnf_module Whether to manage the DNF module
5+
# @param dnf_module_ensure The DNF module name to ensure. Only relevant if manage_dnf_module is set to true.
6+
# @param dnf_module_name The DNF module name to manage. Only relevant if manage_dnf_module is set to true.
7+
#
48
# @see https://github.com/zmartzone/mod_auth_openidc for additional documentation.
9+
# @note Unsupported platforms: OracleLinux: 6; RedHat: 6; Scientific: 6; SLES: all
510
#
6-
class apache::mod::auth_openidc inherits apache::params {
11+
class apache::mod::auth_openidc (
12+
Boolean $manage_dnf_module = $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8',
13+
String[1] $dnf_module_ensure = 'present',
14+
String[1] $dnf_module_name = 'mod_auth_openidc',
15+
) {
716
include apache
17+
include apache::mod::authn_core
818
include apache::mod::authz_user
19+
920
apache::mod { 'auth_openidc': }
21+
22+
if $manage_dnf_module {
23+
package { 'dnf-module-mod_auth_openidc':
24+
ensure => $dnf_module_ensure,
25+
name => $dnf_module_name,
26+
provider => 'dnfmodule',
27+
before => Apache::Mod['auth_openidc'],
28+
}
29+
}
1030
}

manifests/vhost.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@
19451945
Optional[Variant[String, Array[String]]] $comment = undef,
19461946
Hash $define = {},
19471947
Boolean $auth_oidc = false,
1948-
Optional[Apache::OIDCSettings] $oidc_settings = undef,
1948+
Apache::OIDCSettings $oidc_settings = {},
19491949
Optional[Variant[Boolean, String]] $mdomain = undef,
19501950
Optional[Variant[String[1], Array[String[1]]]] $userdir = undef,
19511951
) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper_acceptance'
4+
5+
describe 'apache::mod::auth_openidc', if: mod_supported_on_platform?('apache::mod::auth_openidc') do
6+
pp = <<-MANIFEST
7+
include apache
8+
apache::vhost { 'example.com':
9+
docroot => '/var/www/example.com',
10+
port => 80,
11+
auth_oidc => true,
12+
oidc_settings => {
13+
'ProviderMetadataURL' => 'https://login.example.com/.well-known/openid-configuration',
14+
'ClientID' => 'test',
15+
'RedirectURI' => 'https://login.example.com/redirect_uri',
16+
'ProviderTokenEndpointAuth' => 'client_secret_basic',
17+
'RemoteUserClaim' => 'sub',
18+
'ClientSecret' => 'aae053a9-4abf-4824-8956-e94b2af335c8',
19+
'CryptoPassphrase' => '4ad1bb46-9979-450e-ae58-c696967df3cd',
20+
},
21+
}
22+
MANIFEST
23+
24+
it 'succeeds in configuring a virtual host using mod_auth_openidc' do
25+
apply_manifest(pp, catch_failures: true)
26+
end
27+
28+
it 'is idempotent' do
29+
apply_manifest(pp, catch_changes: true)
30+
end
31+
end

spec/classes/mod/auth_cas_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
include_examples 'Debian 11'
2828

2929
it { is_expected.to contain_class('apache::params') }
30+
it { is_expected.to contain_class('apache::mod::authn_core') }
3031
it { is_expected.to contain_apache__mod('auth_cas') }
3132
it { is_expected.to contain_package('libapache2-mod-auth-cas') }
3233
it { is_expected.to contain_file('auth_cas.conf').with_path('/etc/apache2/mods-available/auth_cas.conf') }
@@ -36,6 +37,7 @@
3637
include_examples 'RedHat 6'
3738

3839
it { is_expected.to contain_class('apache::params') }
40+
it { is_expected.to contain_class('apache::mod::authn_core') }
3941
it { is_expected.to contain_apache__mod('auth_cas') }
4042
it { is_expected.to contain_package('mod_auth_cas') }
4143
it { is_expected.to contain_file('auth_cas.conf').with_path('/etc/httpd/conf.d/auth_cas.conf') }
@@ -50,6 +52,7 @@
5052
include_examples 'RedHat 6'
5153

5254
it { is_expected.to contain_class('apache::params') }
55+
it { is_expected.to contain_class('apache::mod::authn_core') }
5356
it { is_expected.to contain_apache__mod('auth_cas') }
5457
it { is_expected.to contain_package('mod_auth_cas') }
5558
it { is_expected.to contain_file('auth_cas.conf').with_path('/etc/httpd/conf.d/auth_cas.conf') }

spec/classes/mod/auth_gssapi_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,31 @@
1010
include_examples 'Debian 11'
1111

1212
it { is_expected.to contain_class('apache::params') }
13+
it { is_expected.to contain_class('apache::mod::authn_core') }
1314
it { is_expected.to contain_apache__mod('auth_gssapi') }
1415
it { is_expected.to contain_package('libapache2-mod-auth-gssapi') }
1516
end
1617
context 'on a RedHat OS', :compile do
1718
include_examples 'RedHat 6'
1819

1920
it { is_expected.to contain_class('apache::params') }
21+
it { is_expected.to contain_class('apache::mod::authn_core') }
2022
it { is_expected.to contain_apache__mod('auth_gssapi') }
2123
it { is_expected.to contain_package('mod_auth_gssapi') }
2224
end
2325
context 'on a FreeBSD OS', :compile do
2426
include_examples 'FreeBSD 9'
2527

2628
it { is_expected.to contain_class('apache::params') }
29+
it { is_expected.to contain_class('apache::mod::authn_core') }
2730
it { is_expected.to contain_apache__mod('auth_gssapi') }
2831
it { is_expected.to contain_package('www/mod_auth_gssapi') }
2932
end
3033
context 'on a Gentoo OS', :compile do
3134
include_examples 'Gentoo'
3235

3336
it { is_expected.to contain_class('apache::params') }
37+
it { is_expected.to contain_class('apache::mod::authn_core') }
3438
it { is_expected.to contain_apache__mod('auth_gssapi') }
3539
it { is_expected.to contain_package('www-apache/mod_auth_gssapi') }
3640
end

spec/classes/mod/auth_kerb_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,31 @@
1010
include_examples 'Debian 10'
1111

1212
it { is_expected.to contain_class('apache::params') }
13+
it { is_expected.to contain_class('apache::mod::authn_core') }
1314
it { is_expected.to contain_apache__mod('auth_kerb') }
1415
it { is_expected.to contain_package('libapache2-mod-auth-kerb') }
1516
end
1617
context 'on a RedHat OS', :compile do
1718
include_examples 'RedHat 6'
1819

1920
it { is_expected.to contain_class('apache::params') }
21+
it { is_expected.to contain_class('apache::mod::authn_core') }
2022
it { is_expected.to contain_apache__mod('auth_kerb') }
2123
it { is_expected.to contain_package('mod_auth_kerb') }
2224
end
2325
context 'on a FreeBSD OS', :compile do
2426
include_examples 'FreeBSD 9'
2527

2628
it { is_expected.to contain_class('apache::params') }
29+
it { is_expected.to contain_class('apache::mod::authn_core') }
2730
it { is_expected.to contain_apache__mod('auth_kerb') }
2831
it { is_expected.to contain_package('www/mod_auth_kerb2') }
2932
end
3033
context 'on a Gentoo OS', :compile do
3134
include_examples 'Gentoo'
3235

3336
it { is_expected.to contain_class('apache::params') }
37+
it { is_expected.to contain_class('apache::mod::authn_core') }
3438
it { is_expected.to contain_apache__mod('auth_kerb') }
3539
it { is_expected.to contain_package('www-apache/mod_auth_kerb') }
3640
end
@@ -49,6 +53,7 @@ class { 'apache':
4953
MANIFEST
5054
end
5155

56+
it { is_expected.to contain_class('apache::mod::authn_core') }
5257
it { is_expected.to contain_apache__mod('auth_kerb') }
5358
it { is_expected.to contain_package('httpd24-mod_auth_kerb') }
5459
it { is_expected.not_to contain_package('mod_auth_kerb') }

spec/classes/mod/auth_mellon_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
include_examples 'Debian 11'
1010

1111
describe 'with no parameters' do
12+
it { is_expected.to contain_class('apache::mod::authn_core') }
1213
it { is_expected.to contain_apache__mod('auth_mellon') }
1314
it { is_expected.to contain_package('libapache2-mod-auth-mellon') }
1415
it { is_expected.to contain_file('auth_mellon.conf').with_path('/etc/apache2/mods-available/auth_mellon.conf') }
@@ -38,6 +39,7 @@
3839
include_examples 'RedHat 6'
3940

4041
describe 'with no parameters' do
42+
it { is_expected.to contain_class('apache::mod::authn_core') }
4143
it { is_expected.to contain_apache__mod('auth_mellon') }
4244
it { is_expected.to contain_package('mod_auth_mellon') }
4345
it { is_expected.to contain_file('auth_mellon.conf').with_path('/etc/httpd/conf.d/auth_mellon.conf') }

0 commit comments

Comments
 (0)