Browse Source

CredentialsV3: Ensure all attributes are cleared by unset

Currently the unset method only clears attributes defined in the base
Crednetial class and ones specific to CredentialV3 are left set.
This change ensures the method clears all attributes.

Closes-Bug: #1942145
Change-Id: I4bddbf9bb3c6251aa8b68a8bc2ef8799f3c8065e
changes/57/806657/2
Takashi Kajinami 2 months ago
parent
commit
d1eb834a20
  1. 8
      lib/puppet/provider/openstack/credentials.rb
  2. 2
      spec/unit/provider/openstack/credentials_spec.rb

8
lib/puppet/provider/openstack/credentials.rb

@ -45,10 +45,10 @@ class Puppet::Provider::Openstack::Credentials
end
def unset
KEYS.each do |key|
if key != :identity_api_version &&
self.instance_variable_defined?("@#{key}")
set(key, '')
self.instance_variables.each do |var|
if var.to_s != '@identity_api_version' &&
self.instance_variable_defined?(var.to_s)
set(var.to_s.sub(/^@/,''), '')
end
end
end

2
spec/unit/provider/openstack/credentials_spec.rb

@ -86,6 +86,7 @@ describe Puppet::Provider::Openstack::Credentials do
creds.auth_url = 'auth_url'
creds.password = 'password'
creds.project_name = 'project_name'
creds.domain_name = 'domain_name'
creds.username = 'username'
creds.token = 'token'
creds.endpoint = 'endpoint'
@ -94,6 +95,7 @@ describe Puppet::Provider::Openstack::Credentials do
expect(creds.auth_url).to eq('')
expect(creds.password).to eq('')
expect(creds.project_name).to eq('')
expect(creds.domain_name).to eq('')
expect(creds.username).to eq('')
expect(creds.token).to eq('')
expect(creds.endpoint).to eq('')

Loading…
Cancel
Save