@@ -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_dir } /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_dir } /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_dir } /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_dir } /foreman-proxy/foreman_ssl_ca.pem" ) }
1081+ it { should_not contain_file ( "#{ etc_dir } /foreman-proxy/foreman_ssl_cert.pem" ) }
1082+ it { should_not contain_file ( "#{ etc_dir } /foreman-proxy/foreman_ssl_key.pem" ) }
1083+ end
1084+ end
1085+
1086+ context 'when foreman_ssl_ca, foreman_ssl_cert and foreman_ssl_key are defined' do
1087+ let ( :params ) do
1088+ super ( ) . merge (
1089+ manage_certificates : true ,
1090+ foreman_ssl_ca : '/root/certificates/ca.pem' ,
1091+ foreman_ssl_cert : '/root/certificates/cert.pem' ,
1092+ foreman_ssl_key : '/root/certificates/key.pem' ,
1093+ )
1094+ end
1095+
1096+ it { should compile . with_all_deps }
1097+
1098+ it do
1099+ should contain_file ( "#{ etc_dir } /foreman-proxy/foreman_ssl_ca.pem" )
1100+ . with_source ( '/root/certificates/ca.pem' )
1101+ . with_owner ( 'root' )
1102+ . with_group ( 'foreman-proxy' )
1103+ . with_mode ( '0440' )
1104+ end
1105+ it do
1106+ should contain_file ( "#{ etc_dir } /foreman-proxy/foreman_ssl_cert.pem" )
1107+ . with_source ( '/root/certificates/cert.pem' )
1108+ . with_owner ( 'root' )
1109+ . with_group ( 'foreman-proxy' )
1110+ . with_mode ( '0440' )
1111+ end
1112+ it do
1113+ should contain_file ( "#{ etc_dir } /foreman-proxy/foreman_ssl_key.pem" )
1114+ . with_source ( '/root/certificates/key.pem' )
1115+ . with_owner ( 'root' )
1116+ . with_group ( 'foreman-proxy' )
1117+ . with_mode ( '0440' )
1118+ end
1119+ end
10501120 end
10511121 end
10521122end
0 commit comments