Revision e8d6d2d6
Added by Shlomi Zadok over 8 years ago
test/unit/authorizer_test.rb | ||
---|---|---|
|
||
test "#find_collection(Host, :permission => :view_hosts, :joined_on: Report) for admin" do
|
||
host = FactoryGirl.create(:host)
|
||
report = FactoryGirl.create(:report, :host => host)
|
||
report = FactoryGirl.create(:config_report, :host => host)
|
||
@user.update_attribute(:admin, true)
|
||
auth = Authorizer.new(@user)
|
||
|
||
... | ... | |
permission = Permission.find_by_name('view_hosts')
|
||
FactoryGirl.create(:filter, :role => @role, :permissions => [permission], :unlimited => true)
|
||
host = FactoryGirl.create(:host)
|
||
report = FactoryGirl.create(:report, :host => host)
|
||
report = FactoryGirl.create(:config_report, :host => host)
|
||
auth = Authorizer.new(@user)
|
||
|
||
assert_includes auth.find_collection(Host::Managed, :permission => :view_hosts, :joined_on => Report), report
|
||
... | ... | |
FactoryGirl.create(:filter, :role => @role, :permissions => [permission],
|
||
:search => 'hostgroup ~ hostgroup*')
|
||
host = FactoryGirl.create(:host, :with_hostgroup)
|
||
report = FactoryGirl.create(:report, :host => host)
|
||
report = FactoryGirl.create(:config_report, :host => host)
|
||
auth = Authorizer.new(@user)
|
||
|
||
assert_includes auth.find_collection(Host::Managed, :permission => :view_hosts, :joined_on => Report), report
|
||
... | ... | |
FactoryGirl.create(:filter, :role => @role, :permissions => [permission],
|
||
:search => 'hostgroup ~ hostgroup*')
|
||
(host1, host2) = FactoryGirl.create_pair(:host, :with_hostgroup)
|
||
report1 = FactoryGirl.create(:report, :host => host1)
|
||
report2 = FactoryGirl.create(:report, :host => host2)
|
||
report1 = FactoryGirl.create(:config_report, :host => host1)
|
||
report2 = FactoryGirl.create(:config_report, :host => host2)
|
||
auth = Authorizer.new(@user, :collection => [host2])
|
||
|
||
collection = auth.find_collection(Host::Managed, :permission => :view_hosts, :joined_on => Report)
|
||
... | ... | |
permission = Permission.find_by_name('view_hosts')
|
||
FactoryGirl.create(:filter, :role => @role, :permissions => [permission], :unlimited => true)
|
||
hosts = FactoryGirl.create_pair(:host)
|
||
report1 = FactoryGirl.create(:report, :host => hosts.first)
|
||
report2 = FactoryGirl.create(:report, :host => hosts.last)
|
||
report1 = FactoryGirl.create(:config_report, :host => hosts.first)
|
||
report2 = FactoryGirl.create(:config_report, :host => hosts.last)
|
||
auth = Authorizer.new(@user)
|
||
|
||
collection = auth.find_collection(Host::Managed, :permission => :view_hosts, :joined_on => Report,
|
Also available in: Unified diff
fixes #4151 - enable reports STI
Permits subclassing of ReportImporter and Report to import and store
new types of reports associated to hosts.