1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
require 'spec_helper'
describe 'keystone::federation::identity_provider' do
let :params do
{
:user => 'keystone',
:certfile => '/etc/keystone/ssl/certs/signing_cert.pem',
:keyfile => '/etc/keystone/ssl/private/signing_key.pem',
:idp_entity_id => 'https://keystone.example.com/v3/OS-FEDERATION/saml2/idp',
:idp_sso_endpoint => 'https://keystone.example.com/v3/OS-FEDERATION/saml2/sso',
:idp_metadata_path => '/etc/keystone/saml2_idp_metadata.xml'
}
end
let :optional_params do
{
:idp_organization_name => 'ExampleCompany',
:idp_organization_display_name => 'Example',
:idp_organization_url => 'www.example.com',
:idp_contact_company => 'someone',
:idp_contact_name => 'name',
:idp_contact_surname => 'surname',
:idp_contact_email => 'name@example.com',
:idp_contact_telephone => '+55000000000',
:idp_contact_type => 'other'
}
end
shared_examples 'keystone::federation::identity_provider' do
let :pre_condition do
"include apache
class { 'keystone':
service_name => 'httpd',
}"
end
context 'with required params' do
it { is_expected.to contain_class('keystone::params') }
it { is_expected.to contain_package('xmlsec1').with(
:ensure => 'present',
)}
it {
is_expected.to contain_keystone_config('saml/certfile').with_value(params[:certfile])
is_expected.to contain_keystone_config('saml/keyfile').with_value(params[:keyfile])
is_expected.to contain_keystone_config('saml/idp_entity_id').with_value(params[:idp_entity_id])
is_expected.to contain_keystone_config('saml/idp_sso_endpoint').with_value(params[:idp_sso_endpoint])
is_expected.to contain_keystone_config('saml/idp_metadata_path').with_value(params[:idp_metadata_path])
}
it { is_expected.to contain_exec('saml_idp_metadata').with(
:command => "keystone-manage saml_idp_metadata > #{params[:idp_metadata_path]}",
:creates => "#{params[:idp_metadata_path]}",
)}
it { is_expected.to contain_file("#{params[:idp_metadata_path]}").with(
:ensure => 'present',
:mode => '0600',
:owner => 'keystone',
)}
end
context 'with keystone optional params' do
before do
params.merge!(optional_params)
end
it {
is_expected.to contain_keystone_config('saml/certfile').with_value(params[:certfile])
is_expected.to contain_keystone_config('saml/keyfile').with_value(params[:keyfile])
is_expected.to contain_keystone_config('saml/idp_entity_id').with_value(params[:idp_entity_id])
is_expected.to contain_keystone_config('saml/idp_sso_endpoint').with_value(params[:idp_sso_endpoint])
is_expected.to contain_keystone_config('saml/idp_metadata_path').with_value(params[:idp_metadata_path])
is_expected.to contain_keystone_config('saml/idp_organization_name').with_value(params[:idp_organization_name])
is_expected.to contain_keystone_config('saml/idp_organization_display_name').with_value(params[:idp_organization_display_name])
is_expected.to contain_keystone_config('saml/idp_organization_url').with_value(params[:idp_organization_url])
is_expected.to contain_keystone_config('saml/idp_contact_company').with_value(params[:idp_contact_company])
is_expected.to contain_keystone_config('saml/idp_contact_name').with_value(params[:idp_contact_name])
is_expected.to contain_keystone_config('saml/idp_contact_surname').with_value(params[:idp_contact_surname])
is_expected.to contain_keystone_config('saml/idp_contact_email').with_value(params[:idp_contact_email])
is_expected.to contain_keystone_config('saml/idp_contact_telephone').with_value(params[:idp_contact_telephone])
is_expected.to contain_keystone_config('saml/idp_contact_type').with_value(params[:idp_contact_type])
}
end
context 'with invalid values for idp_contact_type' do
before do
params.merge!(:idp_contact_type => 'foobar')
end
it { is_expected.to raise_error(Puppet::Error, /Allowed values for idp_contact_type are: technical, support, administrative, billing and other/) }
end
end
shared_examples 'keystone::federation::identity_provider without Apache' do
let :pre_condition do
"class { 'keystone':
service_name => '#{platform_params[:keystone_service]}',
}"
end
context 'with default parameters' do
it { is_expected.to raise_error(Puppet::Error, /Keystone need to be running under Apache for Federation work./) }
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
let (:platform_params) do
if facts[:os]['family'] == 'RedHat'
keystone_service = 'openstack-keystone'
python_pysaml2_package_name = 'python3-pysaml2'
else
keystone_service = 'keystone'
python_pysaml2_package_name = 'python3-pysaml2'
end
{
:keystone_service => keystone_service,
:python_pysaml2_package_name => python_pysaml2_package_name
}
end
it_behaves_like 'keystone::federation::identity_provider'
it_behaves_like 'keystone::federation::identity_provider without Apache'
end
end
end
|