mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Fix inventory update permission so update_role is enough to update
This commit is contained in:
parent
5c5e495e1b
commit
b21c7e1d15
@ -524,7 +524,12 @@ class InventorySourceAccess(BaseAccess):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def can_start(self, obj):
|
def can_start(self, obj):
|
||||||
return self.can_change(obj, {}) and obj.can_update
|
if obj and obj.group:
|
||||||
|
return obj.can_update and self.user in obj.group.inventory.update_role
|
||||||
|
elif obj and obj.inventory:
|
||||||
|
return obj.can_update and self.user in obj.inventory.update_role
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class InventoryUpdateAccess(BaseAccess):
|
class InventoryUpdateAccess(BaseAccess):
|
||||||
'''
|
'''
|
||||||
|
@ -148,3 +148,16 @@ def test_delete_inventory_host(delete, host, alice, role_field, expected_status_
|
|||||||
if role_field:
|
if role_field:
|
||||||
getattr(host.inventory, role_field).members.add(alice)
|
getattr(host.inventory, role_field).members.add(alice)
|
||||||
delete(reverse('api:host_detail', args=(host.id,)), alice, expect=expected_status_code)
|
delete(reverse('api:host_detail', args=(host.id,)), alice, expect=expected_status_code)
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("role_field,expected_status_code", [
|
||||||
|
(None, 403),
|
||||||
|
('admin_role', 202),
|
||||||
|
('update_role', 202),
|
||||||
|
('adhoc_role', 403),
|
||||||
|
('use_role', 403)
|
||||||
|
])
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_inventory_source_update(post, inventory_source, alice, role_field, expected_status_code):
|
||||||
|
if role_field:
|
||||||
|
getattr(inventory_source.group.inventory, role_field).members.add(alice)
|
||||||
|
post(reverse('api:inventory_source_update_view', args=(inventory_source.id,)), {}, alice, expect=expected_status_code)
|
||||||
|
Loading…
Reference in New Issue
Block a user