Merge "Fix authtoken parameters to load service user credential"
This commit is contained in:
commit
73e5edcd68
|
@ -17,9 +17,9 @@ class Puppet::Provider::Mistral < Puppet::Provider::MistralWorkflowRequester
|
|||
|
||||
def self.mistral_request(service, action, error, properties=nil)
|
||||
properties ||= []
|
||||
@credentials.username = mistral_credentials['admin_username']
|
||||
@credentials.password = mistral_credentials['admin_password']
|
||||
@credentials.project_name = mistral_credentials['admin_project_name']
|
||||
@credentials.username = mistral_credentials['username']
|
||||
@credentials.password = mistral_credentials['password']
|
||||
@credentials.project_name = mistral_credentials['project_name']
|
||||
@credentials.auth_url = auth_endpoint
|
||||
if mistral_credentials['region_name']
|
||||
@credentials.region_name = mistral_credentials['region_name']
|
||||
|
@ -57,8 +57,7 @@ class Puppet::Provider::Mistral < Puppet::Provider::MistralWorkflowRequester
|
|||
end
|
||||
|
||||
def self.get_mistral_credentials
|
||||
auth_keys = ['auth_url', 'admin_tenant_name', 'admin_user',
|
||||
'admin_password']
|
||||
auth_keys = ['auth_url', 'project_name', 'username', 'password']
|
||||
conf = mistral_conf
|
||||
if conf and conf['keystone_authtoken'] and
|
||||
auth_keys.all?{|k| !conf['keystone_authtoken'][k].nil?}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Now the base ``Puppet::Provider::Mistral`` class loads service user
|
||||
credential using the proper keystoneauth parameters.
|
|
@ -0,0 +1,48 @@
|
|||
require 'puppet'
|
||||
require 'spec_helper'
|
||||
require 'puppet/provider/mistral'
|
||||
require 'tempfile'
|
||||
|
||||
klass = Puppet::Provider::Mistral
|
||||
|
||||
describe Puppet::Provider::Mistral do
|
||||
|
||||
after :each do
|
||||
klass.reset
|
||||
end
|
||||
|
||||
describe 'when retrieving the auth credentials' do
|
||||
|
||||
it 'should fail if no auth params are passed and the mistral config file does not have the expected contents' do
|
||||
mock = {}
|
||||
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
|
||||
mock.expects(:read).with('/etc/mistral/mistral.conf')
|
||||
expect do
|
||||
klass.mistral_credentials
|
||||
end.to raise_error(Puppet::Error, /Mistral types will not work/)
|
||||
end
|
||||
|
||||
it 'should read conf file with all sections' do
|
||||
creds_hash = {
|
||||
'auth_url' => 'https://192.168.56.210:5000/v3/',
|
||||
'project_name' => 'admin_tenant',
|
||||
'username' => 'admin',
|
||||
'password' => 'password',
|
||||
'project_domain_name' => 'Default',
|
||||
'user_domain_name' => 'Default',
|
||||
}
|
||||
mock = {
|
||||
'keystone_authtoken' => {
|
||||
'auth_url' => 'https://192.168.56.210:5000/v3/',
|
||||
'project_name' => 'admin_tenant',
|
||||
'username' => 'admin',
|
||||
'password' => 'password',
|
||||
}
|
||||
}
|
||||
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
|
||||
mock.expects(:read).with('/etc/mistral/mistral.conf')
|
||||
expect(klass.mistral_credentials).to eq(creds_hash)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue