Project

General

Profile

« Previous | Next » 

Revision 5f606e11

Added by Daniel Lobato Garcia over 7 years ago

Fixes #16982 - Scope properly when no taxonomies are set

The default scope for hosts and other objects did not restrict
properly by taxonomies. An user without organizations or
locations, could do anything it's permissions allow to.
The list of hosts was unrestricted and showed hosts in
any location or organization.

This is fixed to work so that:

Users without taxonomies, when set to 'any context' cannot see
anything (at all)

Users with taxonomies, when set to 'any context' can see
everything within all of their taxonomies context (including
children taxonomies).

Admins set to 'any context' can see everything - regardless
of whether it has a taxonomy or not.

Users or admins set to some organization/location scope
can only see stuff within scope.

View differences:

test/controllers/api/v2/domains_controller_test.rb
test "should update valid domain" do
put :update, { :id => Domain.first.to_param, :domain => { :name => "domain.new" } }
assert_equal "domain.new", Domain.first.name
assert_equal "domain.new", Domain.unscoped.first.name
assert_response :success
end
......
test "should get domains for location only" do
get :index, {:location_id => taxonomies(:location1).id }
assert_response :success
assert_equal 2, assigns(:domains).length
assert_equal assigns(:domains), [domains(:mydomain), domains(:yourdomain)]
assert_equal taxonomies(:location1).domains.length, assigns(:domains).length
assert_equal assigns(:domains), taxonomies(:location1).domains
end
test "should get domains for organization only" do
get :index, {:organization_id => taxonomies(:organization1).id }
assert_response :success
assert_equal 1, assigns(:domains).length
assert_equal assigns(:domains), [domains(:mydomain)]
assert_equal taxonomies(:organization1).domains.length, assigns(:domains).length
assert_equal taxonomies(:organization1).domains, assigns(:domains)
end
test "should get domains for both location and organization" do

Also available in: Unified diff