mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-08-31 14:25:30 +00:00
add approve pending batch change route (#704)
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
from hamcrest import *
|
||||
from utils import *
|
||||
|
||||
@pytest.mark.manual_batch_review
|
||||
def test_approve_batch_change_with_invalid_batch_change_id_fails(shared_zone_test_context):
|
||||
"""
|
||||
Test approving a batch change with invalid batch change ID
|
||||
"""
|
||||
|
||||
client = shared_zone_test_context.ok_vinyldns_client
|
||||
|
||||
error = client.reject_batch_change("some-id", status=404)
|
||||
assert_that(error, is_("Batch change with id some-id cannot be found"))
|
||||
|
||||
@pytest.mark.manual_batch_review
|
||||
def test_approve_batch_change_with_comments_exceeding_max_length_fails(shared_zone_test_context):
|
||||
"""
|
||||
Test approving a batch change with comments exceeding 1024 characters fails
|
||||
"""
|
||||
|
||||
client = shared_zone_test_context.ok_vinyldns_client
|
||||
reject_batch_change_input = {
|
||||
"reviewComment": "a"*1025
|
||||
}
|
||||
errors = client.reject_batch_change("some-id", reject_batch_change_input, status=400)['errors']
|
||||
assert_that(errors, contains_inanyorder("Comment length must not exceed 1024 characters."))
|
||||
|
||||
@pytest.mark.manual_batch_review
|
||||
def test_approve_batch_change_fails_with_forbidden_error_for_non_system_admins(shared_zone_test_context):
|
||||
"""
|
||||
Test approving a batch change if the reviewer is not a super user or support user
|
||||
"""
|
||||
client = shared_zone_test_context.ok_vinyldns_client
|
||||
batch_change_input = {
|
||||
"changes": [
|
||||
get_change_A_AAAA_json("no-owner-group-id.ok.", address="4.3.2.1")
|
||||
]
|
||||
}
|
||||
to_delete = []
|
||||
|
||||
try:
|
||||
result = client.create_batch_change(batch_change_input, status=202)
|
||||
completed_batch = client.wait_until_batch_change_completed(result)
|
||||
to_delete = [(change['zoneId'], change['recordSetId']) for change in completed_batch['changes']]
|
||||
error = client.reject_batch_change(completed_batch['id'], status=403)
|
||||
assert_that(error, is_("User does not have access to item " + completed_batch['id']))
|
||||
finally:
|
||||
clear_zoneid_rsid_tuple_list(to_delete, client)
|
@@ -584,6 +584,17 @@ class VinylDNSClient(object):
|
||||
_, data = self.make_request(url, u'POST', self.headers, json.dumps(reject_batch_change_input), **kwargs)
|
||||
return data
|
||||
|
||||
def approve_batch_change(self, batch_change_id, approve_batch_change_input=None, **kwargs):
|
||||
"""
|
||||
Approves an existing batch change pending manual review
|
||||
:param batch_change_id: ID of the batch change to approve
|
||||
:param approve_batch_change_input: optional body for approve batch change request
|
||||
:return: the content of the response
|
||||
"""
|
||||
url = urljoin(self.index_url, u'/zones/batchrecordchanges/{0}/approve'.format(batch_change_id))
|
||||
_, data = self.make_request(url, u'POST', self.headers, json.dumps(approve_batch_change_input), **kwargs)
|
||||
return data
|
||||
|
||||
def list_batch_change_summaries(self, start_from=None, max_items=None, list_all=False, **kwargs):
|
||||
"""
|
||||
Gets list of user's batch change summaries
|
||||
|
Reference in New Issue
Block a user