mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Disable POST to v1 inventory_sources
This commit is contained in:
parent
8983351e99
commit
deb8eaa982
@ -2532,6 +2532,13 @@ class InventorySourceList(ListCreateAPIView):
|
||||
always_allow_superuser = False
|
||||
new_in_320 = True
|
||||
|
||||
@property
|
||||
def allowed_methods(self):
|
||||
methods = super(InventorySourceList, self).allowed_methods
|
||||
if get_request_version(self.request) == 1:
|
||||
methods.remove('POST')
|
||||
return methods
|
||||
|
||||
|
||||
class InventorySourceDetail(RetrieveUpdateDestroyAPIView):
|
||||
|
||||
|
@ -6,7 +6,7 @@ from rest_framework import exceptions
|
||||
|
||||
# AWX
|
||||
from awx.main.views import ApiErrorView
|
||||
from awx.api.views import JobList
|
||||
from awx.api.views import JobList, InventorySourceList
|
||||
|
||||
|
||||
HTTP_METHOD_NAMES = [
|
||||
@ -44,3 +44,10 @@ def test_disable_post_on_v2_jobs_list(version, supports_post):
|
||||
job_list.request = mock.MagicMock()
|
||||
with mock.patch('awx.api.views.get_request_version', return_value=version):
|
||||
assert ('POST' in job_list.allowed_methods) == supports_post
|
||||
|
||||
@pytest.mark.parametrize('version, supports_post', [(1, False), (2, True)])
|
||||
def test_disable_post_on_v1_inventory_source_list(version, supports_post):
|
||||
inv_source_list = InventorySourceList()
|
||||
inv_source_list.request = mock.MagicMock()
|
||||
with mock.patch('awx.api.views.get_request_version', return_value=version):
|
||||
assert ('POST' in inv_source_list.allowed_methods) == supports_post
|
||||
|
Loading…
Reference in New Issue
Block a user