Skip to content

Commit

Permalink
Convert Vmdb::PermissionsStore to a blacklist
Browse files Browse the repository at this point in the history
Since it's now a blacklist, there's no need for a sample file with the
full possible whitelist
  • Loading branch information
Fryguy committed Jul 24, 2019
1 parent 82fe638 commit de224fd
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 de224fd

Please sign in to comment.