mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-08-31 14:25:30 +00:00
Add approvalStatus query param to list batch changes (#715)
This commit is contained in:
@@ -63,7 +63,8 @@ class ListBatchChangeSummariesFixture():
|
||||
shared_zone_test_context.ok_vinyldns_client.wait_until_recordset_change_status(delete_result, 'Complete')
|
||||
clear_ok_acl_rules(shared_zone_test_context)
|
||||
|
||||
def check_batch_change_summaries_page_accuracy(self, summaries_page, size, next_id=False, start_from=False, max_items=100):
|
||||
def check_batch_change_summaries_page_accuracy(self, summaries_page, size, next_id=False, start_from=False,
|
||||
max_items=100, approval_status=False):
|
||||
# validate fields
|
||||
if next_id:
|
||||
assert_that(summaries_page, has_key('nextId'))
|
||||
@@ -73,6 +74,10 @@ class ListBatchChangeSummariesFixture():
|
||||
assert_that(summaries_page['startFrom'], is_(start_from))
|
||||
else:
|
||||
assert_that(summaries_page, is_not(has_key('startFrom')))
|
||||
if approval_status:
|
||||
assert_that(summaries_page, has_key('approvalStatus'))
|
||||
else:
|
||||
assert_that(summaries_page, is_not(has_key('approvalStatus')))
|
||||
assert_that(summaries_page['maxItems'], is_(max_items))
|
||||
|
||||
|
||||
@@ -145,6 +150,15 @@ def test_list_batch_change_summaries_with_next_id(list_fixture):
|
||||
list_fixture.check_batch_change_summaries_page_accuracy(next_page_result, size=1, start_from=batch_change_summaries_result['nextId'])
|
||||
|
||||
|
||||
def test_list_batch_change_summaries_with_pending_status(list_fixture):
|
||||
"""
|
||||
Test listing a limited number of user's batch change summaries with maxItems parameter
|
||||
"""
|
||||
client = list_fixture.client
|
||||
batch_change_summaries_result = client.list_batch_change_summaries(status=200, approval_status="PendingApproval")
|
||||
|
||||
list_fixture.check_batch_change_summaries_page_accuracy(batch_change_summaries_result, size=0, approval_status="PendingApproval")
|
||||
|
||||
def test_list_batch_change_summaries_with_list_batch_change_summaries_with_no_changes_passes():
|
||||
"""
|
||||
Test successfully getting an empty list of summaries when user has no batch changes
|
||||
@@ -252,7 +266,7 @@ def test_list_batch_change_summaries_with_deleted_record_owner_group_passes(shar
|
||||
client.wait_until_recordset_change_status(delete_result, 'Complete')
|
||||
|
||||
|
||||
def test_list_batch_change_summaries_with_list_all_true_only_shows_requesting_users_records(shared_zone_test_context):
|
||||
def test_list_batch_change_summaries_with_ignore_access_true_only_shows_requesting_users_records(shared_zone_test_context):
|
||||
"""
|
||||
Test that getting a batch change summary with list all set to true only returns the requesting user's batch changes
|
||||
if they are not a super user
|
||||
@@ -287,7 +301,7 @@ def test_list_batch_change_summaries_with_list_all_true_only_shows_requesting_us
|
||||
record_set_list = [(change['zoneId'], change['recordSetId']) for change in completed_batch['changes']]
|
||||
record_to_delete = set(record_set_list)
|
||||
|
||||
batch_change_summaries_result = client.list_batch_change_summaries(list_all=True, status=200)["batchChanges"]
|
||||
batch_change_summaries_result = client.list_batch_change_summaries(ignore_access=True, status=200)["batchChanges"]
|
||||
|
||||
under_test = [item for item in batch_change_summaries_result if item['id'] == completed_batch['id']]
|
||||
assert_that(under_test, has_length(1))
|
||||
@@ -299,7 +313,7 @@ def test_list_batch_change_summaries_with_list_all_true_only_shows_requesting_us
|
||||
ok_record_set_list = [(change['zoneId'], change['recordSetId']) for change in ok_completed_batch['changes']]
|
||||
ok_record_to_delete = set(ok_record_set_list)
|
||||
|
||||
ok_batch_change_summaries_result = ok_client.list_batch_change_summaries(list_all=True, status=200)["batchChanges"]
|
||||
ok_batch_change_summaries_result = ok_client.list_batch_change_summaries(ignore_access=True, status=200)["batchChanges"]
|
||||
|
||||
ok_under_test = [item for item in ok_batch_change_summaries_result if (item['id'] == ok_completed_batch['id'] or item['id'] == completed_batch['id']) ]
|
||||
assert_that(ok_under_test, has_length(1))
|
||||
@@ -311,3 +325,4 @@ def test_list_batch_change_summaries_with_list_all_true_only_shows_requesting_us
|
||||
for result_rs in ok_record_to_delete:
|
||||
delete_result = client.delete_recordset(result_rs[0], result_rs[1], status=202)
|
||||
client.wait_until_recordset_change_status(delete_result, 'Complete')
|
||||
|
||||
|
@@ -127,9 +127,9 @@ def test_list_zones_max_items_100(list_zones_context):
|
||||
result = list_zones_context.client.list_zones(status=200)
|
||||
assert_that(result['maxItems'], is_(100))
|
||||
|
||||
def test_list_zones_list_all_default_false(list_zones_context):
|
||||
def test_list_zones_ignore_access_default_false(list_zones_context):
|
||||
"""
|
||||
Test that the default list all value for a list zones request is false
|
||||
Test that the default ignore access value for a list zones request is false
|
||||
"""
|
||||
result = list_zones_context.client.list_zones(status=200)
|
||||
assert_that(result['ignoreAccess'], is_(False))
|
||||
@@ -248,22 +248,22 @@ def test_list_zones_with_search_last_page(list_zones_context):
|
||||
assert_that(result['nameFilter'], is_('*test-searched-3'))
|
||||
assert_that(result['startFrom'], is_('list-zones-test-searched-2.'))
|
||||
|
||||
def test_list_zones_list_all_success(list_zones_context):
|
||||
def test_list_zones_ignore_access_success(list_zones_context):
|
||||
"""
|
||||
Test that we can retrieve a list of all zones
|
||||
Test that we can retrieve a list of zones regardless of zone access
|
||||
"""
|
||||
result = list_zones_context.client.list_zones(list_all=True, status=200)
|
||||
result = list_zones_context.client.list_zones(ignore_access=True, status=200)
|
||||
retrieved = result['zones']
|
||||
|
||||
assert_that(result['ignoreAccess'], is_(True))
|
||||
assert_that(len(retrieved), greater_than(5))
|
||||
|
||||
|
||||
def test_list_zones_list_all_success_with_name_filter(list_zones_context):
|
||||
def test_list_zones_ignore_access_success_with_name_filter(list_zones_context):
|
||||
"""
|
||||
Test that we can retrieve a list of all zones with a name filter
|
||||
"""
|
||||
result = list_zones_context.client.list_zones(name_filter='shared', list_all=True, status=200)
|
||||
result = list_zones_context.client.list_zones(name_filter='shared', ignore_access=True, status=200)
|
||||
retrieved = result['zones']
|
||||
|
||||
assert_that(result['ignoreAccess'], is_(True))
|
||||
|
@@ -444,7 +444,7 @@ class VinylDNSClient(object):
|
||||
response, data = self.make_request(url, u'GET', self.headers, not_found_ok=True, **kwargs)
|
||||
return data
|
||||
|
||||
def list_zones(self, name_filter=None, start_from=None, max_items=None, list_all=False, **kwargs):
|
||||
def list_zones(self, name_filter=None, start_from=None, max_items=None, ignore_access=False, **kwargs):
|
||||
"""
|
||||
Gets a list of zones that currently exist
|
||||
:return: a list of zones
|
||||
@@ -461,8 +461,8 @@ class VinylDNSClient(object):
|
||||
if max_items:
|
||||
query.append(u'maxItems=' + str(max_items))
|
||||
|
||||
if list_all:
|
||||
query.append(u'ignoreAccess=' + str(list_all))
|
||||
if ignore_access:
|
||||
query.append(u'ignoreAccess=' + str(ignore_access))
|
||||
|
||||
if query:
|
||||
url = url + u'?' + u'&'.join(query)
|
||||
@@ -595,7 +595,7 @@ class VinylDNSClient(object):
|
||||
_, 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):
|
||||
def list_batch_change_summaries(self, start_from=None, max_items=None, ignore_access=False, approval_status=None, **kwargs):
|
||||
"""
|
||||
Gets list of user's batch change summaries
|
||||
:return: the content of the response
|
||||
@@ -605,8 +605,10 @@ class VinylDNSClient(object):
|
||||
args.append(u'startFrom={0}'.format(start_from))
|
||||
if max_items is not None:
|
||||
args.append(u'maxItems={0}'.format(max_items))
|
||||
if list_all:
|
||||
args.append(u'ignoreAccess={0}'.format(list_all))
|
||||
if ignore_access:
|
||||
args.append(u'ignoreAccess={0}'.format(ignore_access))
|
||||
if approval_status:
|
||||
args.append(u'approvalStatus={0}'.format(approval_status))
|
||||
|
||||
url = urljoin(self.index_url, u'/zones/batchrecordchanges') + u'?' + u'&'.join(args)
|
||||
|
||||
|
Reference in New Issue
Block a user