2012-01-02 15:39:23 -08:00
require 'spec_helper'
describe 'keystone' do
2014-07-17 16:22:34 -06:00
let :global_facts do
{
:concat_basedir = > '/var/lib/puppet/concat' ,
:fqdn = > 'some.host.tld'
}
end
2012-10-14 14:16:47 -07:00
let :facts do
2015-11-21 03:24:54 +00:00
@default_facts . merge ( global_facts . merge ( {
2014-07-17 16:22:34 -06:00
:osfamily = > 'Debian' ,
:operatingsystem = > 'Debian' ,
2015-01-23 11:29:22 -07:00
:operatingsystemrelease = > '7.0' ,
2018-10-26 12:08:28 +05:30
:os = > { :name = > 'Debian' , :family = > 'Debian' , :release = > { :major = > '7' , :minor = > '0' } } ,
2015-11-21 03:24:54 +00:00
} ) )
2012-10-14 14:16:47 -07:00
end
2014-07-17 16:22:34 -06:00
default_params = {
2016-10-30 00:40:51 +08:00
'package_ensure' = > 'present' ,
'client_package_ensure' = > 'present' ,
'public_bind_host' = > '0.0.0.0' ,
'public_port' = > '5000' ,
'catalog_type' = > 'sql' ,
'catalog_driver' = > false ,
2016-10-20 13:06:12 -06:00
'token_provider' = > 'fernet' ,
2018-09-13 11:23:40 +02:00
'password_hash_algorithm' = > '<SERVICE DEFAULT>' ,
'password_hash_rounds' = > '<SERVICE DEFAULT>' ,
2016-10-30 00:40:51 +08:00
'revoke_driver' = > 'sql' ,
'revoke_by_id' = > true ,
'enable_ssl' = > false ,
'ssl_certfile' = > '/etc/keystone/ssl/certs/keystone.pem' ,
'ssl_keyfile' = > '/etc/keystone/ssl/private/keystonekey.pem' ,
'ssl_ca_certs' = > '/etc/keystone/ssl/certs/ca.pem' ,
'ssl_ca_key' = > '/etc/keystone/ssl/private/cakey.pem' ,
'ssl_cert_subject' = > '/C=US/ST=Unset/L=Unset/O=Unset/CN=localhost' ,
'enabled' = > true ,
'manage_service' = > true ,
2016-11-08 12:57:39 -07:00
'default_transport_url' = > '<SERVICE DEFAULT>' ,
2017-01-23 14:52:16 -05:00
'notification_transport_url' = > '<SERVICE DEFAULT>' ,
2016-10-30 00:40:51 +08:00
'rabbit_heartbeat_timeout_threshold' = > '<SERVICE DEFAULT>' ,
'rabbit_heartbeat_rate' = > '<SERVICE DEFAULT>' ,
2019-08-21 14:21:01 +08:00
'rabbit_heartbeat_in_pthread' = > '<SERVICE DEFAULT>' ,
2018-08-08 20:53:57 +08:00
'amqp_durable_queues' = > '<SERVICE DEFAULT>' ,
2016-10-30 00:40:51 +08:00
'member_role_id' = > '<SERVICE DEFAULT>' ,
'member_role_name' = > '<SERVICE DEFAULT>' ,
'sync_db' = > true ,
'purge_config' = > false ,
'keystone_user' = > 'keystone' ,
'keystone_group' = > 'keystone' ,
2016-05-13 13:10:59 -06:00
}
2012-01-02 15:39:23 -08:00
2014-07-17 16:22:34 -06:00
override_params = {
2016-10-30 00:40:51 +08:00
'package_ensure' = > 'latest' ,
'client_package_ensure' = > 'latest' ,
'public_bind_host' = > '0.0.0.0' ,
'public_port' = > '5001' ,
'catalog_type' = > 'template' ,
'token_provider' = > 'uuid' ,
2018-09-13 11:23:40 +02:00
'password_hash_algorithm' = > 'pbkdf2_sha512' ,
'password_hash_rounds' = > '29000' ,
2016-10-30 00:40:51 +08:00
'revoke_driver' = > 'kvs' ,
'revoke_by_id' = > false ,
2019-09-12 19:24:02 +09:00
'public_endpoint' = > 'https://localhost:5000' ,
2016-10-30 00:40:51 +08:00
'enable_ssl' = > true ,
'ssl_certfile' = > '/etc/keystone/ssl/certs/keystone.pem' ,
'ssl_keyfile' = > '/etc/keystone/ssl/private/keystonekey.pem' ,
'ssl_ca_certs' = > '/etc/keystone/ssl/certs/ca.pem' ,
'ssl_ca_key' = > '/etc/keystone/ssl/private/cakey.pem' ,
'ssl_cert_subject' = > '/C=US/ST=Unset/L=Unset/O=Unset/CN=localhost' ,
'enabled' = > false ,
'manage_service' = > true ,
2016-11-08 12:57:39 -07:00
'default_transport_url' = > 'rabbit://user:pass@host:1234/virt' ,
2017-01-23 14:52:16 -05:00
'notification_transport_url' = > 'rabbit://user:pass@host:1234/virt' ,
2016-10-30 00:40:51 +08:00
'rabbit_heartbeat_timeout_threshold' = > '60' ,
'rabbit_heartbeat_rate' = > '10' ,
2019-08-21 14:21:01 +08:00
'rabbit_heartbeat_in_pthread' = > true ,
2016-10-30 00:40:51 +08:00
'rabbit_ha_queues' = > true ,
2018-08-08 20:53:57 +08:00
'amqp_durable_queues' = > true ,
2016-10-30 00:40:51 +08:00
'default_domain' = > 'other_domain' ,
'member_role_id' = > '123456789' ,
'member_role_name' = > 'othermember' ,
'using_domain_config' = > false ,
'keystone_user' = > 'test_user' ,
'keystone_group' = > 'test_group' ,
2012-01-02 15:39:23 -08:00
}
2014-07-17 16:22:34 -06:00
httpd_params = { 'service_name' = > 'httpd' } . merge ( default_params )
2020-02-03 23:17:58 +01:00
shared_examples 'core keystone examples' do | param_hash |
2015-09-25 15:18:32 +02:00
it { is_expected . to contain_class ( 'keystone::logging' ) }
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_class ( 'keystone::params' ) }
2017-06-15 14:16:13 -04:00
it { is_expected . to contain_class ( 'keystone::policy' ) }
2014-07-17 16:22:34 -06:00
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_package ( 'keystone' ) . with (
2015-02-05 20:26:43 -07:00
'ensure' = > param_hash [ 'package_ensure' ] ,
2015-07-22 15:10:25 +02:00
'tag' = > [ 'openstack' , 'keystone-package' ] ,
2014-07-17 16:22:34 -06:00
) }
2015-08-06 17:41:01 +03:00
it { is_expected . to contain_class ( 'keystone::client' ) . with (
2015-02-17 11:02:50 -07:00
'ensure' = > param_hash [ 'client_package_ensure' ] ,
) }
2015-05-06 16:32:05 +02:00
it 'should synchronize the db if $sync_db is true' do
if param_hash [ 'sync_db' ]
2015-03-15 16:32:35 +01:00
is_expected . to contain_exec ( 'keystone-manage db_sync' ) . with (
2015-07-08 13:38:00 -06:00
:command = > 'keystone-manage db_sync' ,
2014-07-17 16:22:34 -06:00
:user = > 'keystone' ,
:refreshonly = > true ,
2016-02-23 18:31:15 -07:00
:subscribe = > [ 'Anchor[keystone::install::end]' ,
'Anchor[keystone::config::end]' ,
'Anchor[keystone::dbsync::begin]' ] ,
:notify = > 'Anchor[keystone::dbsync::end]' ,
2014-07-17 16:22:34 -06:00
)
2012-01-02 15:39:23 -08:00
end
2014-07-17 16:22:34 -06:00
end
2012-01-02 15:39:23 -08:00
2016-05-13 13:10:59 -06:00
it 'passes purge to resource' do
is_expected . to contain_resources ( 'keystone_config' ) . with ( {
:purge = > false
} )
end
2014-07-17 16:22:34 -06:00
it 'should contain correct config' do
[
2016-06-28 16:36:15 +10:00
'member_role_id' ,
'member_role_name' ,
2014-07-17 16:22:34 -06:00
] . each do | config |
2015-03-15 16:32:35 +01:00
is_expected . to contain_keystone_config ( " DEFAULT/ #{ config } " ) . with_value ( param_hash [ config ] )
2012-01-02 15:39:23 -08:00
end
2014-07-17 16:22:34 -06:00
end
2012-01-02 15:39:23 -08:00
2014-07-17 16:22:34 -06:00
it 'should contain correct mysql config' do
2019-04-30 08:13:17 -06:00
is_expected . to contain_class ( 'keystone::db' )
2014-07-17 16:22:34 -06:00
end
2012-01-02 15:39:23 -08:00
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_keystone_config ( 'token/provider' ) . with_value (
2014-07-17 16:22:34 -06:00
param_hash [ 'token_provider' ]
) }
2012-04-05 16:58:36 -07:00
2015-03-02 09:27:27 -07:00
it 'should contain correct revoke driver' do
2015-07-20 15:57:55 +02:00
is_expected . to contain_keystone_config ( 'revoke/driver' ) . with_value ( param_hash [ 'revoke_driver' ] )
2015-03-02 09:27:27 -07:00
end
2018-09-13 11:23:40 +02:00
it 'should contain password_hash_algorithm' do
is_expected . to contain_keystone_config ( 'identity/password_hash_algorithm' ) . with_value ( param_hash [ 'password_hash_algorithm' ] )
end
it 'should contain password_hash_rounds' do
is_expected . to contain_keystone_config ( 'identity/password_hash_rounds' ) . with_value ( param_hash [ 'password_hash_rounds' ] )
end
2015-10-27 15:48:53 +02:00
it 'should contain default revoke_by_id value ' do
is_expected . to contain_keystone_config ( 'token/revoke_by_id' ) . with_value ( param_hash [ 'revoke_by_id' ] )
end
2019-08-22 17:03:14 +09:00
it 'should ensure proper setting of public_endpoint' do
2014-07-17 16:22:34 -06:00
if param_hash [ 'public_endpoint' ]
2015-03-15 16:32:35 +01:00
is_expected . to contain_keystone_config ( 'DEFAULT/public_endpoint' ) . with_value ( param_hash [ 'public_endpoint' ] )
2014-07-17 16:22:34 -06:00
else
2020-07-22 15:16:15 +09:00
is_expected . to contain_keystone_config ( 'DEFAULT/public_endpoint' ) . with_value ( '<SERVICE DEFAULT>' )
2014-07-17 16:22:34 -06:00
end
end
2016-11-08 12:57:39 -07:00
it 'should contain correct default transport url' do
is_expected . to contain_keystone_config ( 'DEFAULT/transport_url' ) . with_value ( params [ 'default_transport_url' ] )
end
2015-06-22 15:41:02 -06:00
it 'should contain correct rabbit heartbeat configuration' do
is_expected . to contain_keystone_config ( 'oslo_messaging_rabbit/heartbeat_timeout_threshold' ) . with_value ( param_hash [ 'rabbit_heartbeat_timeout_threshold' ] )
is_expected . to contain_keystone_config ( 'oslo_messaging_rabbit/heartbeat_rate' ) . with_value ( param_hash [ 'rabbit_heartbeat_rate' ] )
2019-08-21 14:21:01 +08:00
is_expected . to contain_keystone_config ( 'oslo_messaging_rabbit/heartbeat_in_pthread' ) . with_value ( param_hash [ 'rabbit_heartbeat_in_pthread' ] )
2018-08-08 20:53:57 +08:00
is_expected . to contain_keystone_config ( 'oslo_messaging_rabbit/amqp_durable_queues' ) . with_value ( param_hash [ 'amqp_durable_queues' ] )
2014-07-17 16:22:34 -06:00
end
2014-11-24 11:37:52 +13:00
it 'should remove max_token_size param by default' do
2015-11-27 20:29:05 +00:00
is_expected . to contain_keystone_config ( 'DEFAULT/max_token_size' ) . with_value ( '<SERVICE DEFAULT>' )
2014-11-24 11:37:52 +13:00
end
2015-01-23 11:29:22 -07:00
2015-06-30 14:30:02 +03:00
it 'should ensure rabbit_ha_queues' do
if param_hash [ 'rabbit_ha_queues' ]
is_expected . to contain_keystone_config ( 'oslo_messaging_rabbit/rabbit_ha_queues' ) . with_value ( param_hash [ 'rabbit_ha_queues' ] )
else
2016-04-06 18:30:13 +03:00
is_expected . to contain_keystone_config ( 'oslo_messaging_rabbit/rabbit_ha_queues' ) . with_value ( '<SERVICE DEFAULT>' )
2015-06-30 14:30:02 +03:00
end
end
2015-04-17 15:21:41 -06:00
if param_hash [ 'default_domain' ]
it { is_expected . to contain_keystone_domain ( param_hash [ 'default_domain' ] ) . with ( :is_default = > true ) }
2015-07-24 14:24:37 -04:00
it { is_expected . to contain_anchor ( 'default_domain_created' ) }
2015-04-17 15:21:41 -06:00
end
2014-07-17 16:22:34 -06:00
end
[ default_params , override_params ] . each do | param_hash |
describe " when #{ param_hash == default_params ? " using default " : " specifying " } class parameters for service " do
let :params do
param_hash
end
2020-02-03 23:17:58 +01:00
it_behaves_like 'core keystone examples' , param_hash
2012-01-02 15:39:23 -08:00
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_service ( 'keystone' ) . with (
2014-08-25 14:52:37 +02:00
'ensure' = > ( param_hash [ 'manage_service' ] && param_hash [ 'enabled' ] ) ? 'running' : 'stopped' ,
2012-06-18 10:46:01 -07:00
'enable' = > param_hash [ 'enabled' ] ,
2013-05-09 23:17:08 -04:00
'hasstatus' = > true ,
2015-07-22 15:10:25 +02:00
'hasrestart' = > true ,
'tag' = > 'keystone-service' ,
2012-01-02 15:39:23 -08:00
) }
2016-02-23 18:31:15 -07:00
it { is_expected . to contain_anchor ( 'keystone::service::end' ) }
2015-07-13 15:09:12 -04:00
2014-07-17 16:22:34 -06:00
end
end
2013-03-13 09:18:36 -07:00
2020-02-03 23:17:58 +01:00
shared_examples " when using default class parameters for httpd on Debian " do
2014-07-17 16:22:34 -06:00
let :params do
httpd_params
end
2013-08-13 19:14:27 +00:00
2014-07-17 16:22:34 -06:00
let :pre_condition do
2019-12-08 23:09:22 +01:00
'include keystone::wsgi::apache'
2014-07-17 16:22:34 -06:00
end
2014-03-03 23:37:36 -05:00
2020-02-03 23:17:58 +01:00
it_behaves_like 'core keystone examples' , httpd_params
2014-06-11 13:26:52 +02:00
2014-07-17 16:22:34 -06:00
it do
expect {
2015-07-20 15:57:55 +02:00
is_expected . to contain_service ( platform_parameters [ :service_name ] ) . with ( 'ensure' = > 'running' )
2014-10-13 13:27:32 +02:00
} . to raise_error ( RSpec :: Expectations :: ExpectationNotMetError , / expected that the catalogue would contain Service \ [ #{ platform_parameters [ :service_name ] } \ ] / )
2013-03-13 09:18:36 -07:00
end
2014-07-17 16:22:34 -06:00
2015-12-10 22:46:17 -08:00
it { is_expected . to contain_exec ( 'restart_keystone' ) . with (
'command' = > " service #{ platform_parameters [ :httpd_service_name ] } restart " ,
) }
2014-10-13 13:27:32 +02:00
end
2020-02-03 23:17:58 +01:00
shared_examples " when using default class parameters for httpd on RedHat " do
2016-05-12 16:48:01 -04:00
let :params do
httpd_params
end
let :pre_condition do
2019-12-08 23:09:22 +01:00
'include keystone::wsgi::apache'
2016-05-12 16:48:01 -04:00
end
2020-02-03 23:17:58 +01:00
it_behaves_like 'core keystone examples' , httpd_params
2016-05-12 16:48:01 -04:00
it do
expect {
is_expected . to contain_service ( platform_parameters [ :service_name ] ) . with ( 'ensure' = > 'running' )
} . to raise_error ( RSpec :: Expectations :: ExpectationNotMetError , / expected that the catalogue would contain Service \ [ #{ platform_parameters [ :service_name ] } \ ] / )
end
it { is_expected . to contain_service ( 'httpd' ) . with_before ( / Anchor \ [keystone::service::end \ ] / ) }
it { is_expected . to contain_exec ( 'restart_keystone' ) . with (
'command' = > " service #{ platform_parameters [ :httpd_service_name ] } restart " ,
) }
end
2014-10-13 13:27:32 +02:00
describe 'when using invalid service name for keystone' do
let ( :params ) { { 'service_name' = > 'foo' } . merge ( default_params ) }
it_raises 'a Puppet::Error' , / Invalid service_name /
2013-03-13 09:18:36 -07:00
end
2014-02-10 14:26:27 -05:00
2014-08-25 14:52:37 +02:00
describe 'with disabled service managing' do
let :params do
2019-11-02 12:32:24 +01:00
{ :manage_service = > false ,
2014-08-25 14:52:37 +02:00
:enabled = > false }
end
it { is_expected . to contain_service ( 'keystone' ) . with (
'ensure' = > nil ,
'enable' = > false ,
'hasstatus' = > true ,
'hasrestart' = > true
) }
2016-02-23 18:31:15 -07:00
it { is_expected . to contain_anchor ( 'keystone::service::end' ) }
2014-08-25 14:52:37 +02:00
end
2017-01-20 16:09:47 +00:00
describe 'when configuring signing token provider' do
describe 'when configuring as UUID' do
let :params do
{
'token_provider' = > 'keystone.token.providers.uuid.Provider'
}
end
end
describe 'with invalid catalog_type' do
let :params do
2019-11-02 12:32:24 +01:00
{ :catalog_type = > 'invalid' }
2017-01-20 16:09:47 +00:00
end
2019-02-23 12:32:35 +01:00
it { should raise_error ( Puppet :: Error ) }
2017-01-20 16:09:47 +00:00
end
describe 'when configuring catalog driver' do
let :params do
2019-11-02 12:32:24 +01:00
{ :catalog_driver = > 'alien' }
2017-01-20 16:09:47 +00:00
end
it { is_expected . to contain_keystone_config ( 'catalog/driver' ) . with_value ( params [ :catalog_driver ] ) }
end
end
2013-12-10 10:12:43 -06:00
describe 'when configuring token expiration' do
let :params do
{
'token_expiration' = > '42' ,
}
end
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_keystone_config ( " token/expiration " ) . with_value ( '42' ) }
2013-12-10 10:12:43 -06:00
end
describe 'when not configuring token expiration' do
let :params do
2019-11-02 12:32:24 +01:00
{ }
2013-12-10 10:12:43 -06:00
end
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_keystone_config ( " token/expiration " ) . with_value ( '3600' ) }
2013-12-10 10:12:43 -06:00
end
2015-04-07 14:51:00 +02:00
describe 'when sync_db is set to false' do
let :params do
{
2019-11-02 12:32:24 +01:00
'sync_db' = > false ,
2015-04-07 14:51:00 +02:00
}
end
it { is_expected . not_to contain_exec ( 'keystone-manage db_sync' ) }
end
2014-02-11 10:11:43 -05:00
describe 'when enabling SSL' do
let :params do
{
2016-10-30 00:40:51 +08:00
'enable_ssl' = > true ,
2014-02-11 10:11:43 -05:00
}
end
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_keystone_config ( 'ssl/enable' ) . with_value ( true ) }
it { is_expected . to contain_keystone_config ( 'ssl/certfile' ) . with_value ( '/etc/keystone/ssl/certs/keystone.pem' ) }
it { is_expected . to contain_keystone_config ( 'ssl/keyfile' ) . with_value ( '/etc/keystone/ssl/private/keystonekey.pem' ) }
it { is_expected . to contain_keystone_config ( 'ssl/ca_certs' ) . with_value ( '/etc/keystone/ssl/certs/ca.pem' ) }
it { is_expected . to contain_keystone_config ( 'ssl/ca_key' ) . with_value ( '/etc/keystone/ssl/private/cakey.pem' ) }
it { is_expected . to contain_keystone_config ( 'ssl/cert_subject' ) . with_value ( '/C=US/ST=Unset/L=Unset/O=Unset/CN=localhost' ) }
2014-02-11 10:11:43 -05:00
end
2019-09-12 19:24:02 +09:00
2014-02-11 10:11:43 -05:00
describe 'when disabling SSL' do
let :params do
{
2019-11-02 12:32:24 +01:00
'enable_ssl' = > false ,
2014-02-11 10:11:43 -05:00
}
end
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_keystone_config ( 'ssl/enable' ) . with_value ( false ) }
2014-02-11 10:11:43 -05:00
end
2019-09-12 19:24:02 +09:00
2014-02-12 15:25:21 +08:00
describe 'not setting notification settings by default' do
let :params do
default_params
end
2017-01-23 14:52:16 -05:00
it { is_expected . to contain_keystone_config ( 'oslo_messaging_notifications/transport_url' ) . with_value ( '<SERVICE DEFAULT>' ) }
2016-04-06 18:30:13 +03:00
it { is_expected . to contain_keystone_config ( 'oslo_messaging_notifications/driver' ) . with_value ( '<SERVICE DEFAULT>' ) }
it { is_expected . to contain_keystone_config ( 'oslo_messaging_notifications/topics' ) . with_value ( '<SERVICE DEFAULT>' ) }
2015-11-27 20:29:05 +00:00
it { is_expected . to contain_keystone_config ( 'DEFAULT/notification_format' ) . with_value ( '<SERVICE DEFAULT>' ) }
it { is_expected . to contain_keystone_config ( 'DEFAULT/control_exchange' ) . with_value ( '<SERVICE DEFAULT>' ) }
2017-03-01 10:12:09 +08:00
it { is_expected . to contain_keystone_config ( 'DEFAULT/rpc_response_timeout' ) . with_value ( '<SERVICE DEFAULT>' ) }
2014-02-12 15:25:21 +08:00
end
2014-06-10 12:36:43 -04:00
describe 'with RabbitMQ communication SSLed' do
let :params do
default_params . merge! ( {
:rabbit_use_ssl = > true ,
:kombu_ssl_ca_certs = > '/path/to/ssl/ca/certs' ,
:kombu_ssl_certfile = > '/path/to/ssl/cert/file' ,
:kombu_ssl_keyfile = > '/path/to/ssl/keyfile' ,
2015-01-02 20:48:44 +01:00
:kombu_ssl_version = > 'TLSv1'
2014-06-10 12:36:43 -04:00
} )
end
2017-03-10 13:47:48 +02:00
it { is_expected . to contain_oslo__messaging__rabbit ( 'keystone_config' ) . with (
:rabbit_use_ssl = > true ,
:kombu_ssl_ca_certs = > '/path/to/ssl/ca/certs' ,
:kombu_ssl_certfile = > '/path/to/ssl/cert/file' ,
:kombu_ssl_keyfile = > '/path/to/ssl/keyfile' ,
:kombu_ssl_version = > 'TLSv1'
) }
2014-06-10 12:36:43 -04:00
end
describe 'with RabbitMQ communication not SSLed' do
let :params do
default_params . merge! ( {
2015-11-27 20:29:05 +00:00
:rabbit_use_ssl = > '<SERVICE DEFAULT>' ,
:kombu_ssl_ca_certs = > '<SERVICE DEFAULT>' ,
:kombu_ssl_certfile = > '<SERVICE DEFAULT>' ,
:kombu_ssl_keyfile = > '<SERVICE DEFAULT>' ,
:kombu_ssl_version = > '<SERVICE DEFAULT>'
2014-06-10 12:36:43 -04:00
} )
end
2017-03-10 13:47:48 +02:00
it { is_expected . to contain_oslo__messaging__rabbit ( 'keystone_config' ) . with (
:rabbit_use_ssl = > '<SERVICE DEFAULT>' ,
:kombu_ssl_ca_certs = > '<SERVICE DEFAULT>' ,
:kombu_ssl_certfile = > '<SERVICE DEFAULT>' ,
:kombu_ssl_keyfile = > '<SERVICE DEFAULT>' ,
:kombu_ssl_version = > '<SERVICE DEFAULT>'
) }
2014-06-10 12:36:43 -04:00
end
2014-11-24 11:37:52 +13:00
describe 'when configuring max_token_size' do
let :params do
default_params . merge ( { :max_token_size = > '16384' } )
end
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_keystone_config ( 'DEFAULT/max_token_size' ) . with_value ( params [ :max_token_size ] ) }
2014-11-24 11:37:52 +13:00
end
2014-02-12 15:25:21 +08:00
describe 'setting notification settings' do
let :params do
default_params . merge ( {
2017-03-01 10:12:09 +08:00
:notification_driver = > [ 'keystone.openstack.common.notifier.rpc_notifier' ] ,
:notification_topics = > [ 'notifications' ] ,
:notification_format = > 'cadf' ,
:control_exchange = > 'keystone' ,
:rpc_response_timeout = > '120'
2014-02-12 15:25:21 +08:00
} )
end
2020-04-26 23:11:53 +09:00
it { is_expected . to contain_keystone_config ( 'oslo_messaging_notifications/driver' ) . with_value ( [ 'keystone.openstack.common.notifier.rpc_notifier' ] ) }
2016-04-06 18:30:13 +03:00
it { is_expected . to contain_keystone_config ( 'oslo_messaging_notifications/topics' ) . with_value ( 'notifications' ) }
2015-04-16 09:18:42 -06:00
it { is_expected . to contain_keystone_config ( 'DEFAULT/notification_format' ) . with_value ( 'cadf' ) }
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_keystone_config ( 'DEFAULT/control_exchange' ) . with_value ( 'keystone' ) }
2017-03-01 10:12:09 +08:00
it { is_expected . to contain_keystone_config ( 'DEFAULT/rpc_response_timeout' ) . with_value ( '120' ) }
2014-02-12 15:25:21 +08:00
end
2016-05-11 20:03:52 +03:00
describe 'setting kombu settings' do
let :params do
default_params . merge ( {
:kombu_reconnect_delay = > '1.0' ,
:kombu_compression = > 'gzip' ,
} )
end
it { is_expected . to contain_keystone_config ( 'oslo_messaging_rabbit/kombu_reconnect_delay' ) . with_value ( '1.0' ) }
it { is_expected . to contain_keystone_config ( 'oslo_messaging_rabbit/kombu_compression' ) . with_value ( 'gzip' ) }
it { is_expected . to contain_keystone_config ( 'oslo_messaging_rabbit/kombu_failover_strategy' ) . with_value ( '<SERVICE DEFAULT>' ) }
end
2016-07-13 10:50:20 +03:00
describe 'setting enable_proxy_headers_parsing' do
let :params do
default_params . merge ( { :enable_proxy_headers_parsing = > true } )
end
2018-03-21 11:24:02 +08:00
it { is_expected . to contain_oslo__middleware ( 'keystone_config' ) . with (
:enable_proxy_headers_parsing = > true ,
) }
2016-07-13 10:50:20 +03:00
end
2019-07-03 09:52:44 +03:00
describe 'setting max_request_body_size' do
let :params do
default_params . merge ( { :max_request_body_size = > '1146880' } )
end
2019-07-04 13:35:31 +08:00
it { is_expected . to contain_oslo__middleware ( 'keystone_config' ) . with (
:max_request_body_size = > '1146880' ,
) }
2019-07-03 09:52:44 +03:00
end
2015-11-02 18:49:28 +02:00
describe 'setting sql policy driver' do
let :params do
default_params . merge ( { :policy_driver = > 'sql' } )
end
it { is_expected . to contain_keystone_config ( 'policy/driver' ) . with_value ( 'sql' ) }
end
2014-03-27 12:49:41 +01:00
describe 'setting sql (default) catalog' do
let :params do
default_params
end
2016-02-26 10:03:15 -05:00
it { is_expected . to contain_keystone_config ( 'catalog/driver' ) . with_value ( 'sql' ) }
2014-03-27 12:49:41 +01:00
end
describe 'setting default template catalog' do
let :params do
{
2016-10-30 00:40:51 +08:00
:catalog_type = > 'template'
2014-03-27 12:49:41 +01:00
}
end
2016-02-26 10:03:15 -05:00
it { is_expected . to contain_keystone_config ( 'catalog/driver' ) . with_value ( 'templated' ) }
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_keystone_config ( 'catalog/template_file' ) . with_value ( '/etc/keystone/default_catalog.templates' ) }
2014-03-27 12:49:41 +01:00
end
describe 'setting another template catalog' do
let :params do
{
2016-10-30 00:40:51 +08:00
:catalog_type = > 'template' ,
:catalog_template_file = > '/some/template_file'
2014-03-27 12:49:41 +01:00
}
end
2016-02-26 10:03:15 -05:00
it { is_expected . to contain_keystone_config ( 'catalog/driver' ) . with_value ( 'templated' ) }
2015-03-15 16:32:35 +01:00
it { is_expected . to contain_keystone_config ( 'catalog/template_file' ) . with_value ( '/some/template_file' ) }
2014-03-27 12:49:41 +01:00
end
2014-04-10 14:34:35 +04:00
2016-09-02 15:18:07 -04:00
describe 'when using credentials' do
describe 'when enabling credential_setup' do
let :params do
default_params . merge ( {
'enable_credential_setup' = > true ,
'credential_key_repository' = > '/etc/keystone/credential-keys' ,
} )
end
it { is_expected . to contain_file ( params [ 'credential_key_repository' ] ) . with (
:ensure = > 'directory' ,
:owner = > params [ 'keystone_user' ] ,
:group = > params [ 'keystone_group' ] ,
2016-10-04 22:29:02 -06:00
'mode' = > '0600' ,
2016-09-02 15:18:07 -04:00
) }
it { is_expected . to contain_exec ( 'keystone-manage credential_setup' ) . with (
:command = > " keystone-manage credential_setup --keystone-user #{ params [ 'keystone_user' ] } --keystone-group #{ params [ 'keystone_group' ] } " ,
:user = > params [ 'keystone_user' ] ,
:creates = > '/etc/keystone/credential-keys/0' ,
:require = > 'File[/etc/keystone/credential-keys]' ,
) }
it { is_expected . to contain_keystone_config ( 'credential/key_repository' ) . with_value ( '/etc/keystone/credential-keys' ) }
end
describe 'when overriding the credential key directory' do
let :params do
default_params . merge ( {
'enable_credential_setup' = > true ,
'credential_key_repository' = > '/var/lib/credential-keys' ,
} )
end
it { is_expected . to contain_exec ( 'keystone-manage credential_setup' ) . with (
:creates = > '/var/lib/credential-keys/0'
) }
end
describe 'when overriding the keystone group and user' do
let :params do
default_params . merge ( {
'enable_credential_setup' = > true ,
'keystone_user' = > 'test_user' ,
'keystone_group' = > 'test_group' ,
} )
end
it { is_expected . to contain_exec ( 'keystone-manage credential_setup' ) . with (
:command = > " keystone-manage credential_setup --keystone-user #{ params [ 'keystone_user' ] } --keystone-group #{ params [ 'keystone_group' ] } " ,
:user = > params [ 'keystone_user' ] ,
:creates = > '/etc/keystone/credential-keys/0' ,
:require = > 'File[/etc/keystone/credential-keys]' ,
) }
end
2016-09-06 18:13:32 -04:00
describe 'when setting credential_keys parameter' do
let :params do
default_params . merge ( {
'enable_credential_setup' = > true ,
'credential_keys' = > {
'/etc/keystone/credential-keys/0' = > {
'content' = > 't-WdduhORSqoyAykuqWAQSYjg2rSRuJYySgI2xh48CI=' ,
} ,
'/etc/keystone/credential-keys/1' = > {
'content' = > 'GLlnyygEVJP4-H2OMwClXn3sdSQUZsM5F194139Unv8=' ,
} ,
}
} )
end
it { is_expected . to_not contain_exec ( 'keystone-manage credential_setup' ) }
it { is_expected . to contain_file ( '/etc/keystone/credential-keys/0' ) . with (
'content' = > 't-WdduhORSqoyAykuqWAQSYjg2rSRuJYySgI2xh48CI=' ,
'owner' = > 'keystone' ,
'subscribe' = > 'Anchor[keystone::install::end]' ,
) }
it { is_expected . to contain_file ( '/etc/keystone/credential-keys/1' ) . with (
'content' = > 'GLlnyygEVJP4-H2OMwClXn3sdSQUZsM5F194139Unv8=' ,
'owner' = > 'keystone' ,
'subscribe' = > 'Anchor[keystone::install::end]' ,
) }
end
2016-09-02 15:18:07 -04:00
describe 'when disabling credential_setup' do
let :params do
default_params . merge ( {
'enable_credential_setup' = > false ,
'credential_key_repository' = > '/etc/keystone/credential-keys' ,
} )
end
it { is_expected . to_not contain_file ( params [ 'credential_key_repository' ] ) }
it { is_expected . to_not contain_exec ( 'keystone-manage credential_setup' ) }
end
end
2015-05-25 12:47:09 -06:00
describe 'when using fernet tokens' do
describe 'when enabling fernet_setup' do
let :params do
default_params . merge ( {
'enable_fernet_setup' = > true ,
'fernet_max_active_keys' = > 5 ,
2015-10-27 15:48:53 +02:00
'revoke_by_id' = > false ,
2016-06-28 00:40:54 +03:00
'fernet_key_repository' = > '/etc/keystone/fernet-keys' ,
2015-05-25 12:47:09 -06:00
} )
end
2016-06-28 00:40:54 +03:00
it { is_expected . to contain_file ( params [ 'fernet_key_repository' ] ) . with (
:ensure = > 'directory' ,
:owner = > params [ 'keystone_user' ] ,
:group = > params [ 'keystone_group' ] ,
2016-10-04 22:29:02 -06:00
:mode = > '0600' ,
2016-06-28 00:40:54 +03:00
) }
2015-05-25 12:47:09 -06:00
it { is_expected . to contain_exec ( 'keystone-manage fernet_setup' ) . with (
2016-06-28 00:40:54 +03:00
:command = > " keystone-manage fernet_setup --keystone-user #{ params [ 'keystone_user' ] } --keystone-group #{ params [ 'keystone_group' ] } " ,
:user = > params [ 'keystone_user' ] ,
:creates = > '/etc/keystone/fernet-keys/0' ,
:require = > 'File[/etc/keystone/fernet-keys]' ,
2015-05-25 12:47:09 -06:00
) }
it { is_expected . to contain_keystone_config ( 'fernet_tokens/max_active_keys' ) . with_value ( 5 ) }
2015-10-27 15:48:53 +02:00
it { is_expected . to contain_keystone_config ( 'token/revoke_by_id' ) . with_value ( false ) }
2015-05-25 12:47:09 -06:00
end
describe 'when overriding the fernet key directory' do
let :params do
default_params . merge ( {
'enable_fernet_setup' = > true ,
'fernet_key_repository' = > '/var/lib/fernet-keys' ,
} )
end
it { is_expected . to contain_exec ( 'keystone-manage fernet_setup' ) . with (
:creates = > '/var/lib/fernet-keys/0'
) }
end
2016-06-28 00:40:54 +03:00
describe 'when overriding the keystone group and user' do
let :params do
default_params . merge ( {
'enable_fernet_setup' = > true ,
'fernet_key_repository' = > '/etc/keystone/fernet-keys' ,
'keystone_user' = > 'test_user' ,
'keystone_group' = > 'test_group' ,
} )
end
it { is_expected . to contain_exec ( 'keystone-manage fernet_setup' ) . with (
:command = > " keystone-manage fernet_setup --keystone-user #{ params [ 'keystone_user' ] } --keystone-group #{ params [ 'keystone_group' ] } " ,
:user = > params [ 'keystone_user' ] ,
:creates = > '/etc/keystone/fernet-keys/0' ,
:require = > 'File[/etc/keystone/fernet-keys]' ,
) }
end
2015-05-25 12:47:09 -06:00
end
2016-09-15 22:54:16 -04:00
describe 'when setting fernet_keys parameter' do
let :params do
default_params . merge ( {
'enable_fernet_setup' = > true ,
'fernet_keys' = > {
'/etc/keystone/fernet-keys/0' = > {
'content' = > 't-WdduhORSqoyAykuqWAQSYjg2rSRuJYySgI2xh48CI=' ,
} ,
'/etc/keystone/fernet-keys/1' = > {
'content' = > 'GLlnyygEVJP4-H2OMwClXn3sdSQUZsM5F194139Unv8=' ,
} ,
}
} )
end
it { is_expected . to_not contain_exec ( 'keystone-manage fernet_setup' ) }
it { is_expected . to contain_file ( '/etc/keystone/fernet-keys/0' ) . with (
'content' = > 't-WdduhORSqoyAykuqWAQSYjg2rSRuJYySgI2xh48CI=' ,
'owner' = > 'keystone' ,
2016-10-04 22:29:02 -06:00
'mode' = > '0600' ,
2017-03-15 15:54:50 +02:00
'replace' = > true ,
2016-09-15 22:54:16 -04:00
'subscribe' = > 'Anchor[keystone::install::end]' ,
2020-06-18 16:15:07 +02:00
'tag' = > 'keystone-fernet-key' ,
2016-09-15 22:54:16 -04:00
) }
it { is_expected . to contain_file ( '/etc/keystone/fernet-keys/1' ) . with (
'content' = > 'GLlnyygEVJP4-H2OMwClXn3sdSQUZsM5F194139Unv8=' ,
'owner' = > 'keystone' ,
2017-03-15 15:54:50 +02:00
'mode' = > '0600' ,
'replace' = > true ,
'subscribe' = > 'Anchor[keystone::install::end]' ,
2020-06-18 16:15:07 +02:00
'tag' = > 'keystone-fernet-key' ,
2017-03-15 15:54:50 +02:00
) }
end
describe 'when not replacing fernet_keys and setting fernet_keys parameter' do
let :params do
default_params . merge ( {
'enable_fernet_setup' = > true ,
'fernet_keys' = > {
'/etc/keystone/fernet-keys/0' = > {
'content' = > 't-WdduhORSqoyAykuqWAQSYjg2rSRuJYySgI2xh48CI=' ,
} ,
'/etc/keystone/fernet-keys/1' = > {
'content' = > 'GLlnyygEVJP4-H2OMwClXn3sdSQUZsM5F194139Unv8=' ,
} ,
} ,
'fernet_replace_keys' = > false ,
} )
end
it { is_expected . to_not contain_exec ( 'keystone-manage fernet_setup' ) }
it { is_expected . to contain_file ( '/etc/keystone/fernet-keys/0' ) . with (
'content' = > 't-WdduhORSqoyAykuqWAQSYjg2rSRuJYySgI2xh48CI=' ,
'owner' = > 'keystone' ,
'mode' = > '0600' ,
'replace' = > false ,
'subscribe' = > 'Anchor[keystone::install::end]' ,
) }
it { is_expected . to contain_file ( '/etc/keystone/fernet-keys/1' ) . with (
'content' = > 'GLlnyygEVJP4-H2OMwClXn3sdSQUZsM5F194139Unv8=' ,
2016-09-15 22:54:16 -04:00
'owner' = > 'keystone' ,
2016-10-04 22:29:02 -06:00
'mode' = > '0600' ,
2017-03-15 15:54:50 +02:00
'replace' = > false ,
2016-09-15 22:54:16 -04:00
'subscribe' = > 'Anchor[keystone::install::end]' ,
) }
end
2020-02-03 23:17:58 +01:00
shared_examples " when configuring default domain " do
2015-07-30 10:16:30 -04:00
describe 'with default domain and eventlet service is managed and enabled' do
2015-04-17 15:21:41 -06:00
let :params do
default_params . merge ( {
'default_domain' = > 'test' ,
} )
end
2015-07-30 10:16:30 -04:00
it { is_expected . to contain_exec ( 'restart_keystone' ) . with (
'command' = > " service #{ platform_parameters [ :service_name ] } restart " ,
) }
it { is_expected . to contain_anchor ( 'default_domain_created' ) }
end
describe 'with default domain and wsgi service is managed and enabled' do
let :pre_condition do
2019-12-08 23:09:22 +01:00
'include apache'
2015-07-30 10:16:30 -04:00
end
let :params do
default_params . merge ( {
'default_domain' = > 'test' ,
'service_name' = > 'httpd' ,
} )
end
2015-07-24 14:24:37 -04:00
it { is_expected . to contain_anchor ( 'default_domain_created' ) }
2015-04-17 15:21:41 -06:00
end
describe 'with default domain and service is not managed' do
let :params do
default_params . merge ( {
'default_domain' = > 'test' ,
'manage_service' = > false ,
} )
end
it { is_expected . to_not contain_exec ( 'restart_keystone' ) }
2015-07-24 14:24:37 -04:00
it { is_expected . to contain_anchor ( 'default_domain_created' ) }
2015-04-17 15:21:41 -06:00
end
end
2014-10-13 13:27:32 +02:00
context 'on RedHat platforms' do
let :facts do
2015-11-21 03:24:54 +00:00
@default_facts . merge ( global_facts . merge ( {
2014-10-13 13:27:32 +02:00
:osfamily = > 'RedHat' ,
2016-12-22 08:09:28 -07:00
:operatingsystem = > 'RedHat' ,
2018-10-26 12:08:28 +05:30
:operatingsystemrelease = > '7.0' ,
:os = > { :name = > 'RedHat' , :family = > 'RedHat' , :release = > { :major = > '7' , :minor = > '0' } } ,
2015-11-21 03:24:54 +00:00
} ) )
2014-10-13 13:27:32 +02:00
end
let :platform_parameters do
{
2015-07-30 10:16:30 -04:00
:service_name = > 'openstack-keystone' ,
:httpd_service_name = > 'httpd' ,
2014-10-13 13:27:32 +02:00
}
end
2020-02-03 23:17:58 +01:00
it_behaves_like 'when using default class parameters for httpd on RedHat'
it_behaves_like 'when configuring default domain'
2014-10-13 13:27:32 +02:00
end
context 'on Debian platforms' do
let :facts do
2015-11-21 03:24:54 +00:00
@default_facts . merge ( global_facts . merge ( {
2014-10-13 13:27:32 +02:00
:osfamily = > 'Debian' ,
:operatingsystem = > 'Debian' ,
2018-10-26 12:08:28 +05:30
:operatingsystemrelease = > '7.0' ,
:os = > { :name = > 'Debian' , :family = > 'Debian' , :release = > { :major = > '7' , :minor = > '0' } } ,
2015-11-21 03:24:54 +00:00
} ) )
2014-10-13 13:27:32 +02:00
end
let :platform_parameters do
{
2015-07-30 10:16:30 -04:00
:service_name = > 'keystone' ,
:httpd_service_name = > 'apache2' ,
2014-10-13 13:27:32 +02:00
}
end
2020-02-03 23:17:58 +01:00
it_behaves_like 'when using default class parameters for httpd on Debian'
it_behaves_like 'when configuring default domain'
2014-10-13 13:27:32 +02:00
end
2015-10-27 15:48:53 +02:00
2015-09-01 16:06:39 +02:00
describe " when configuring using_domain_config " do
describe 'with default config' do
let :params do
default_params
end
it { is_expected . to_not contain_file ( '/etc/keystone/domains' ) }
end
describe 'when using domain config' do
let :params do
default_params . merge ( {
'using_domain_config' = > true ,
} )
end
it { is_expected . to contain_file ( '/etc/keystone/domains' ) . with (
'ensure' = > " directory " ,
) }
it { is_expected
. to contain_keystone_config ( 'identity/domain_specific_drivers_enabled' )
. with ( 'value' = > true ,
) }
it { is_expected
. to contain_keystone_config ( 'identity/domain_config_dir' )
. with ( 'value' = > '/etc/keystone/domains' ,
) }
end
describe 'when using domain config and a wrong directory' do
let :params do
default_params . merge ( {
'using_domain_config' = > true ,
'domain_config_directory' = > 'this/is/not/an/absolute/path'
} )
end
2019-02-23 12:32:35 +01:00
it { should raise_error ( Puppet :: Error ) }
2015-09-01 16:06:39 +02:00
end
describe 'when setting domain directory and not using domain config' do
let :params do
default_params . merge ( {
'using_domain_config' = > false ,
'domain_config_directory' = > '/this/is/an/absolute/path'
} )
end
it 'should raise an error' do
expect { should contain_file ( '/etc/keystone/domains' ) }
. to raise_error ( Puppet :: Error , %r( You must activate domain ) )
end
end
describe 'when setting domain directory and using domain config' do
let :params do
default_params . merge ( {
'using_domain_config' = > true ,
'domain_config_directory' = > '/this/is/an/absolute/path'
} )
end
it { is_expected . to contain_file ( '/this/is/an/absolute/path' ) . with (
'ensure' = > " directory " ,
) }
end
end
2012-01-02 15:39:23 -08:00
end