support for Keystone v3 authentication

This adds the class Puppet::Provider::Openstack::CredentialsV3
that implements support for Keystone v3 authentication and all
of the new id and domain authentication parameters.

Implements: blueprint api-v3-support

Change-Id: Icafc4cb8ed000fd9d3ed6ffde2afe1a1250d90af
This commit is contained in:
Rich Megginson 2015-06-02 10:19:06 -06:00 committed by Gilles Dubreuil
parent 46c6b127ee
commit 8441feb39d
2 changed files with 62 additions and 0 deletions

View File

@ -54,3 +54,36 @@ end
class Puppet::Provider::Openstack::CredentialsV2_0 < Puppet::Provider::Openstack::Credentials
end
class Puppet::Provider::Openstack::CredentialsV3 < Puppet::Provider::Openstack::Credentials
KEYS = [
:cacert,
:cert,
:default_domain,
:domain_id,
:domain_name,
:key,
:project_domain_id,
:project_domain_name,
:project_id,
:trust_id,
:user_domain_id,
:user_domain_name,
:user_id
]
KEYS.each { |var| attr_accessor var }
def self.defined?(name)
KEYS.include?(name.to_sym) || super
end
def user_password_set?
return true if (@username || @user_id) && @password && (@project_name || @project_id) && @auth_url
end
def initialize
set(:identity_api_version, version)
end
end

View File

@ -60,4 +60,33 @@ describe Puppet::Provider::Openstack::Credentials do
end
end
end
describe 'using v3' do
let(:creds) do
creds = Puppet::Provider::Openstack::CredentialsV3.new
end
describe 'with v3' do
it 'uses v3 identity api' do
creds.identity_api_version == '3'
end
end
describe '#password_set? with username and project_name' do
it 'is successful' do
creds.auth_url = 'auth_url'
creds.password = 'password'
creds.project_name = 'project_name'
creds.username = 'username'
expect(creds.user_password_set?).to be_truthy
end
end
describe '#password_set? with user_id and project_id' do
it 'is successful' do
creds.auth_url = 'auth_url'
creds.password = 'password'
creds.project_id = 'projid'
creds.user_id = 'userid'
expect(creds.user_password_set?).to be_truthy
end
end
end
end