Fix spec tests for RSpec 3.x and Puppet 4.x

Remove value test for ldap/project_filter and
ldap/project_attribute_ignore (the value is undef), and the comportment
is different between puppet3.x and puppet4.x (.with_value(nil) and
.with_value('')).

This patch also update RSpec 3.x matcher in order to remove deprecation
warnings (in unit spec/unit/provider/keystone_spec.rb).

Closes-bug: #1447620
Change-Id: Ib7118375d2ef72de045ece515fa611bdd3dda8e4
This commit is contained in:
Sebastien Badia 2015-04-23 20:20:23 +02:00
parent d7aa157e5e
commit 3ab8faf6a1
3 changed files with 12 additions and 12 deletions

@ -211,7 +211,7 @@ describe 'keystone::ldap' do
end
it 'should work with deprecated params' do
is_expected.to contain_keystone_config('ldap/project_tree_dn').with_value('ou=projects,ou=openstack,dc=example,dc=com')
is_expected.to contain_keystone_config('ldap/project_filter').with_value(nil)
is_expected.to contain_keystone_config('ldap/project_filter')
is_expected.to contain_keystone_config('ldap/project_objectclass').with_value('organizationalUnit')
is_expected.to contain_keystone_config('ldap/project_id_attribute').with_value('ou')
is_expected.to contain_keystone_config('ldap/project_member_attribute').with_value('member')
@ -219,7 +219,7 @@ describe 'keystone::ldap' do
is_expected.to contain_keystone_config('ldap/project_name_attribute').with_value('ou')
is_expected.to contain_keystone_config('ldap/project_enabled_attribute').with_value('enabled')
is_expected.to contain_keystone_config('ldap/project_domain_id_attribute').with_value('businessCategory')
is_expected.to contain_keystone_config('ldap/project_attribute_ignore').with_value(nil)
is_expected.to contain_keystone_config('ldap/project_attribute_ignore')
is_expected.to contain_keystone_config('ldap/project_allow_create').with_value('True')
is_expected.to contain_keystone_config('ldap/project_allow_update').with_value('True')
is_expected.to contain_keystone_config('ldap/project_allow_delete').with_value('True')

@ -45,7 +45,7 @@ describe 'keystone::resource::service_identity' do
it { is_expected.to contain_keystone_user_role("#{title}@services").with(
:ensure => 'present',
:roles => 'admin',
:roles => ['admin'],
)}
it { is_expected.to contain_keystone_service(title).with(

@ -51,63 +51,63 @@ describe Puppet::Provider::Keystone do
mock = {'DEFAULT' => {'admin_token' => 'foo'}}
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/keystone/keystone.conf')
klass.get_admin_token.should == 'foo'
expect(klass.get_admin_token).to eq('foo')
end
it 'should use the specified bind_host in the admin endpoint' do
mock = {'DEFAULT' => {'admin_bind_host' => '192.168.56.210', 'admin_port' => '35357' }}
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/keystone/keystone.conf')
klass.get_admin_endpoint.should == 'http://192.168.56.210:35357/v2.0/'
expect(klass.get_admin_endpoint).to eq('http://192.168.56.210:35357/v2.0/')
end
it 'should use localhost in the admin endpoint if bind_host is 0.0.0.0' do
mock = {'DEFAULT' => { 'admin_bind_host' => '0.0.0.0', 'admin_port' => '35357' }}
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/keystone/keystone.conf')
klass.get_admin_endpoint.should == 'http://127.0.0.1:35357/v2.0/'
expect(klass.get_admin_endpoint).to eq('http://127.0.0.1:35357/v2.0/')
end
it 'should use [::1] in the admin endpoint if bind_host is ::0' do
mock = {'DEFAULT' => { 'admin_bind_host' => '::0', 'admin_port' => '35357' }}
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/keystone/keystone.conf')
klass.get_admin_endpoint.should == 'http://[::1]:35357/v2.0/'
expect(klass.get_admin_endpoint).to eq('http://[::1]:35357/v2.0/')
end
it 'should use localhost in the admin endpoint if bind_host is unspecified' do
mock = {'DEFAULT' => { 'admin_port' => '35357' }}
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/keystone/keystone.conf')
klass.get_admin_endpoint.should == 'http://127.0.0.1:35357/v2.0/'
expect(klass.get_admin_endpoint).to eq('http://127.0.0.1:35357/v2.0/')
end
it 'should use https if ssl is enabled' do
mock = {'DEFAULT' => {'admin_bind_host' => '192.168.56.210', 'admin_port' => '35357' }, 'ssl' => {'enable' => 'True'}}
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/keystone/keystone.conf')
klass.get_admin_endpoint.should == 'https://192.168.56.210:35357/v2.0/'
expect(klass.get_admin_endpoint).to eq('https://192.168.56.210:35357/v2.0/')
end
it 'should use http if ssl is disabled' do
mock = {'DEFAULT' => {'admin_bind_host' => '192.168.56.210', 'admin_port' => '35357' }, 'ssl' => {'enable' => 'False'}}
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/keystone/keystone.conf')
klass.get_admin_endpoint.should == 'http://192.168.56.210:35357/v2.0/'
expect(klass.get_admin_endpoint).to eq('http://192.168.56.210:35357/v2.0/')
end
it 'should use the defined admin_endpoint if available' do
mock = {'DEFAULT' => {'admin_endpoint' => 'https://keystone.example.com' }, 'ssl' => {'enable' => 'False'}}
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/keystone/keystone.conf')
klass.get_admin_endpoint.should == 'https://keystone.example.com/v2.0/'
expect(klass.get_admin_endpoint).to eq('https://keystone.example.com/v2.0/')
end
it 'should handle an admin_endpoint with a trailing slash' do
mock = {'DEFAULT' => {'admin_endpoint' => 'https://keystone.example.com/' }, 'ssl' => {'enable' => 'False'}}
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/keystone/keystone.conf')
klass.get_admin_endpoint.should == 'https://keystone.example.com/v2.0/'
expect(klass.get_admin_endpoint).to eq('https://keystone.example.com/v2.0/')
end
end