mirror of
https://github.com/ansible/awx.git
synced 2026-01-21 06:28:01 -03:30
Deprecate post to v2 jobs (#18)
This commit is contained in:
parent
01316aebf7
commit
8983351e99
@ -3719,6 +3719,13 @@ class JobList(ListCreateAPIView):
|
||||
metadata_class = JobTypeMetadata
|
||||
serializer_class = JobListSerializer
|
||||
|
||||
@property
|
||||
def allowed_methods(self):
|
||||
methods = super(JobList, self).allowed_methods
|
||||
if get_request_version(self.request) > 1:
|
||||
methods.remove('POST')
|
||||
return methods
|
||||
|
||||
|
||||
class JobDetail(RetrieveUpdateDestroyAPIView):
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ from rest_framework import exceptions
|
||||
|
||||
# AWX
|
||||
from awx.main.views import ApiErrorView
|
||||
from awx.api.views import JobList
|
||||
|
||||
|
||||
HTTP_METHOD_NAMES = [
|
||||
@ -35,3 +36,11 @@ def test_exception_view_raises_exception(api_view_obj_fixture, method_name):
|
||||
request_mock = mock.MagicMock()
|
||||
with pytest.raises(exceptions.APIException):
|
||||
getattr(api_view_obj_fixture, method_name)(request_mock)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('version, supports_post', [(1, True), (2, False)])
|
||||
def test_disable_post_on_v2_jobs_list(version, supports_post):
|
||||
job_list = JobList()
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user