Skip to content

Commit

Permalink
Merge "keystone_user_role supports email as username"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Aug 4, 2014
2 parents e1e3f09 + 9b2078a commit 03b100e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/puppet/provider/keystone_user_role/keystone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def self.get_user_and_tenant(user, tenant)
end

def get_user_and_tenant
user, tenant = resource[:name].split('@', 2)
user = resource[:name].rpartition('@').first
tenant = resource[:name].rpartition('@').last
self.class.get_user_and_tenant(user, tenant)
end

Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/type/keystone_user_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
This is currently used to model the creation of
keystone users roles.
User roles are an assigment of a role to a user on
a certain tenant. The combintation of all of these
User roles are an assignment of a role to a user on
a certain tenant. The combination of all of these
attributes is unique.
EOT

Expand All @@ -32,11 +32,11 @@
end

autorequire(:keystone_user) do
self[:name].split('@', 2).first
self[:name].rpartition('@').first
end

autorequire(:keystone_tenant) do
self[:name].split('@', 2).last
self[:name].rpartition('@').last
end

autorequire(:keystone_role) do
Expand Down
40 changes: 40 additions & 0 deletions spec/unit/provider/keystone_user_role/keystone_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'puppet'
require 'spec_helper'
require 'puppet/provider/keystone_user_role/keystone'

provider_class = Puppet::Type.type(:keystone_user_role).provider(:keystone)

describe provider_class do

describe '#get_user_and_tenant' do

let :user do
'[email protected]'
end

let :tenant do
'test'
end

let :resource do
Puppet::Type::Keystone_user_role.new(
{
:name => "#{user}@#{tenant}",
:roles => [ '_member_' ],
}
)
end

let :provider do
provider_class.new(resource)
end

before :each do
provider_class.expects(:get_user_and_tenant).with(user,tenant).returns([user,tenant])
end

it 'should handle an email address as username' do
provider.get_user_and_tenant.should == [ user, tenant ]
end
end
end

0 comments on commit 03b100e

Please sign in to comment.