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

ADD rbac_tenant_manage_quotas to tenant product features #18151

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
2 changes: 1 addition & 1 deletion app/models/miq_product_feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MiqProductFeature < ApplicationRecord
REQUIRED_ATTRIBUTES = [:identifier].freeze
OPTIONAL_ATTRIBUTES = %i(name feature_type description children hidden protected).freeze
ALLOWED_ATTRIBUTES = (REQUIRED_ATTRIBUTES + OPTIONAL_ATTRIBUTES).freeze
TENANT_FEATURE_ROOT_IDENTIFIERS = %w(dialog_new_editor dialog_edit_editor dialog_copy_editor dialog_delete).freeze
TENANT_FEATURE_ROOT_IDENTIFIERS = %w(dialog_new_editor dialog_edit_editor dialog_copy_editor dialog_delete rbac_tenant_manage_quotas).freeze

def name
value = self[:name]
Expand Down
5 changes: 4 additions & 1 deletion spec/models/miq_user_role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
policy
vm
dialog_edit_editor
rbac_tenant_manage_quotas
))

feature1 = MiqProductFeature.find_all_by_identifier("dashboard_admin")
Expand Down Expand Up @@ -80,7 +81,7 @@
let!(:tenant_1) { FactoryGirl.create(:tenant, :parent => root_tenant) }
let!(:tenant_2) { FactoryGirl.create(:tenant, :parent => root_tenant) }

let(:feature) { MiqProductFeature.find_all_by_identifier(["dialog_edit_editor_tenant_#{tenant_2.id}"]) }
let(:feature) { MiqProductFeature.find_all_by_identifier(["dialog_edit_editor_tenant_#{tenant_2.id}", "rbac_tenant_manage_quotas_tenant_#{tenant_2.id}"]) }
let(:role) { FactoryGirl.create(:miq_user_role, :miq_product_features => feature) }
let(:group_tenant_1) { FactoryGirl.create(:miq_group, :miq_user_role => role, :tenant => tenant_1) }
let(:group_tenant_2) { FactoryGirl.create(:miq_group, :miq_user_role => role, :tenant => tenant_2) }
Expand All @@ -90,12 +91,14 @@
it "doesn't authorise user without dynamic product feature" do
User.with_user(user_1) do
expect(user_1.role_allows?(:identifier => "dialog_edit_editor")).to be_falsey
expect(user_1.role_allows?(:identifier => "rbac_tenant_manage_quotas")).to be_falsey
end
end

it "authorise user with dynamic product feature" do
User.with_user(user_2) do
expect(user_2.role_allows?(:identifier => "dialog_edit_editor")).to be_truthy
expect(user_2.role_allows?(:identifier => "rbac_tenant_manage_quotas")).to be_truthy
end
end
end
Expand Down