Skip to content

Commit

Permalink
Merge pull request #19053 from Fryguy/blacklist_permissions_store
Browse files Browse the repository at this point in the history
Convert Vmdb::PermissionsStore to a blacklist
  • Loading branch information
h-kataria authored Jul 24, 2019
2 parents 82fe638 + de224fd commit 7146738
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 71 deletions.
59 changes: 0 additions & 59 deletions config/permissions.tmpl.yml

This file was deleted.

4 changes: 2 additions & 2 deletions lib/vmdb/permission_stores/yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ def self.create(config)

class YAML
def initialize(file)
@permissions = Psych.load_file(file)
@blacklist = Psych.load_file(file)
end

def can?(permission)
@permissions.include?(permission)
!@blacklist.include?(permission)
end

def supported_ems_type?(type)
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/vmdb/permission_stores_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@

describe '::YAML' do
it '#can?' do
stub_vmdb_permission_store_with_types(["foo"]) do
stub_vmdb_permission_store_with_types(["bar"]) do
instance = Vmdb::PermissionStores.instance
expect(instance.can?('foo')).to be_truthy
expect(instance.can?('bar')).to be_falsey
end
end

it '#supported_ems_type?' do
stub_vmdb_permission_store_with_types(["ems-type:foo"]) do
stub_vmdb_permission_store_with_types(["ems-type:bar"]) do
instance = Vmdb::PermissionStores.instance
expect(instance.supported_ems_type?('foo')).to be_truthy
expect(instance.supported_ems_type?('bar')).to be_falsey
Expand Down
9 changes: 1 addition & 8 deletions spec/models/ext_management_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,7 @@

it "with removed permissions" do
stub_vmdb_permission_store_with_types(["ems-type:vmwarews"]) do
expect(described_class.supported_types_and_descriptions_hash).to eq("vmwarews" => "VMware vCenter")
end
end

it "permissions.tmpl.yml should contain all EMS types" do
types = YAML.load_file(Rails.root.join("config/permissions.tmpl.yml"))
stub_vmdb_permission_store_with_types(types) do
expect(described_class.supported_types_and_descriptions_hash).to eq(all_types_and_descriptions)
expect(described_class.supported_types_and_descriptions_hash).to_not include("vmwarews")
end
end
end
Expand Down

0 comments on commit 7146738

Please sign in to comment.