@@ -1047,6 +1047,76 @@ class { 'foreman_proxy::globals':
10471047
10481048 it { should contain_user ( "#{ proxy_user_name } " ) . with_shell ( '/dne/foo' ) }
10491049 end
1050+
1051+ describe 'manage_certificates' do
1052+ let ( :params ) do
1053+ super ( ) . merge (
1054+ manage_certificates : true ,
1055+ )
1056+ end
1057+
1058+ context 'when ssl_ca, ssl_cert and ssl_key are defined' do
1059+ it { should compile . with_all_deps }
1060+
1061+ it do
1062+ should contain_file ( '/etc/foreman-proxy/ssl_ca.pem' )
1063+ . with_owner ( 'root' )
1064+ . with_group ( 'foreman-proxy' )
1065+ . with_mode ( '0440' )
1066+ end
1067+ it do
1068+ should contain_file ( '/etc/foreman-proxy/ssl_cert.pem' )
1069+ . with_owner ( 'root' )
1070+ . with_group ( 'foreman-proxy' )
1071+ . with_mode ( '0440' )
1072+ end
1073+ it do
1074+ should contain_file ( '/etc/foreman-proxy/ssl_key.pem' )
1075+ . with_owner ( 'root' )
1076+ . with_group ( 'foreman-proxy' )
1077+ . with_mode ( '0440' )
1078+ end
1079+
1080+ it { should_not contain_file ( '/etc/foreman-proxy/foreman_ssl_ca.pem' ) }
1081+ it { should_not contain_file ( '/etc/foreman-proxy/foreman_ssl_cert.pem' ) }
1082+ it { should_not contain_file ( '/etc/foreman-proxy/foreman_ssl_key.pem' ) }
1083+ end
1084+
1085+ context 'when foreman_ssl_ca, foreman_ssl_cert and foreman_ssl_key are defined' do
1086+ let ( :params ) do
1087+ super ( ) . merge (
1088+ manage_certificates : true ,
1089+ foreman_ssl_ca : '/root/certificates/ca.pem' ,
1090+ foreman_ssl_cert : '/root/certificates/cert.pem' ,
1091+ foreman_ssl_key : '/root/certificates/key.pem' ,
1092+ )
1093+ end
1094+
1095+ it { should compile . with_all_deps }
1096+
1097+ it do
1098+ should contain_file ( '/etc/foreman-proxy/foreman_ssl_ca.pem' )
1099+ . with_source ( '/root/certificates/ca.pem' )
1100+ . with_owner ( 'root' )
1101+ . with_group ( 'foreman-proxy' )
1102+ . with_mode ( '0440' )
1103+ end
1104+ it do
1105+ should contain_file ( '/etc/foreman-proxy/foreman_ssl_cert.pem' )
1106+ . with_source ( '/root/certificates/cert.pem' )
1107+ . with_owner ( 'root' )
1108+ . with_group ( 'foreman-proxy' )
1109+ . with_mode ( '0440' )
1110+ end
1111+ it do
1112+ should contain_file ( '/etc/foreman-proxy/foreman_ssl_key.pem' )
1113+ . with_source ( '/root/certificates/key.pem' )
1114+ . with_owner ( 'root' )
1115+ . with_group ( 'foreman-proxy' )
1116+ . with_mode ( '0440' )
1117+ end
1118+ end
1119+ end
10501120 end
10511121 end
10521122end
0 commit comments