Skip to content

Commit

Permalink
Merge pull request #16828 from syncrou/add_auth_private_key_to_rbac
Browse files Browse the repository at this point in the history
Add acts_as_miq_taggable to AuthPrivateKey
(cherry picked from commit fad3529)

https://bugzilla.redhat.com/show_bug.cgi?id=1533139
  • Loading branch information
gmcculloug authored and simaishi committed Jan 18, 2018
1 parent e413880 commit bb43558
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/models/auth_private_key.rb
@@ -1,2 +1,3 @@
class AuthPrivateKey < Authentication
acts_as_miq_taggable
end
Expand Up @@ -35,7 +35,7 @@ def allowed_cloud_subnets(_options = {})

def allowed_guest_access_key_pairs(_options = {})
source = load_ar_obj(get_source_vm)
targets = get_targets_for_ems(source, :cloud_filter, ManageIQ::Providers, 'key_pairs')
targets = get_targets_for_ems(source, :cloud_filter, ManageIQ::Providers::CloudManager::AuthKeyPair, 'key_pairs')
targets.each_with_object({}) { |kp, h| h[kp.id] = kp.name }
end

Expand Down
Expand Up @@ -74,7 +74,10 @@
FactoryGirl.create(:classification_cost_center_with_tags)
admin.current_group.entitlement = Entitlement.create!(:filters => {'managed' => [['/managed/cc/001']],
'belongsto' => []})

2.times do |i|
kp = ManageIQ::Providers::CloudManager::AuthKeyPair.create(:name => "auth_#{i}")
ems.key_pairs << kp
end
2.times { FactoryGirl.create(:availability_zone, :ems_id => ems.id) }
2.times do
FactoryGirl.create(:security_group, :name => "sgb_1",
Expand All @@ -84,11 +87,23 @@
:supports_64_bit => true)
ems.flavors << FactoryGirl.create(:flavor, :name => "m1.large", :supports_32_bit => false,
:supports_64_bit => true)

tagged_key_pair = ems.key_pairs.first
tagged_zone = ems.availability_zones.first
tagged_flavor = ems.flavors.first
Classification.classify(tagged_zone, 'cc', '001')
Classification.classify(tagged_flavor, 'cc', '001')
Classification.classify(tagged_key_pair, 'cc', '001')
end

context "key_pairs" do
it "#get_targets_for_ems" do
expect(ems.key_pairs.size).to eq(2)
expect(ems.key_pairs.first.tags.size).to eq(1)
expect(ems.key_pairs.last.tags.size).to eq(0)
filtered = workflow.send(:get_targets_for_ems, ems, :cloud_filter, ManageIQ::Providers::CloudManager::AuthKeyPair,
'key_pairs')
expect(filtered.size).to eq(1)
end
end

context "availability_zones" do
Expand Down

0 comments on commit bb43558

Please sign in to comment.