Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Vmdb::PermissionsStore to a blacklist #19053

Merged
merged 1 commit into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to tell, but the big change is the ! here.

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