X-Git-Url: https://git.donarmstrong.com/?p=dsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fkeystone%2Fspec%2Funit%2Fprovider%2Fkeystone_spec.rb;fp=3rdparty%2Fmodules%2Fkeystone%2Fspec%2Funit%2Fprovider%2Fkeystone_spec.rb;h=0000000000000000000000000000000000000000;hp=de9ceb0d1893a19075d31ae0b4dc637838bcc568;hb=6eb028a997c0756fdd3d27a16297180db269631b;hpb=31a3a9671cd1bc17dba562dea642c62aff3bc7ef diff --git a/3rdparty/modules/keystone/spec/unit/provider/keystone_spec.rb b/3rdparty/modules/keystone/spec/unit/provider/keystone_spec.rb deleted file mode 100644 index de9ceb0d..00000000 --- a/3rdparty/modules/keystone/spec/unit/provider/keystone_spec.rb +++ /dev/null @@ -1,115 +0,0 @@ -require 'puppet' -require 'spec_helper' -require 'puppet/provider/keystone' -require 'tempfile' - - -klass = Puppet::Provider::Keystone - -class Puppet::Provider::Keystone - def self.reset - @admin_endpoint = nil - @tenant_hash = nil - @admin_token = nil - @keystone_file = nil - end -end - -describe Puppet::Provider::Keystone do - - after :each do - klass.reset - end - - - describe 'when retrieving the security token' do - - it 'should return nothing if there is no keystone config file' do - ini_file = Puppet::Util::IniConfig::File.new - t = Tempfile.new('foo') - path = t.path - t.unlink - ini_file.read(path) - expect(klass.get_admin_token).to be_nil - end - - it 'should return nothing if the keystone config file does not have a DEFAULT section' do - mock = {} - Puppet::Util::IniConfig::File.expects(:new).returns(mock) - mock.expects(:read).with('/etc/keystone/keystone.conf') - expect(klass.get_admin_token).to be_nil - end - - it 'should fail if the keystone config file does not contain an admin token' do - mock = {'DEFAULT' => {'not_a_token' => 'foo'}} - Puppet::Util::IniConfig::File.expects(:new).returns(mock) - mock.expects(:read).with('/etc/keystone/keystone.conf') - expect(klass.get_admin_token).to be_nil - end - - it 'should parse the admin token if it is in the config file' 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' - 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/' - 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/' - 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/' - 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/' - 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/' - 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/' - 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/' - 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/' - end - - end - -end