Get all certificates from NSX

client.get method retrieves only the first page of results from NSX. In large
scale environments, we wouldn't return all the Certificates. The patch fixes
this behavior to return all the certificates on NSX

Issue: #3048262
Change-Id: Ic43c28eb93bf706209980f66c97d217bd4c4d611
This commit is contained in:
Gautam Verma 2022-10-13 15:30:25 +05:30
parent ed1fe81f56
commit c9fea99b4f
2 changed files with 4 additions and 4 deletions

View File

@ -44,7 +44,7 @@ class TestNsxLibTrustManagement(nsxlib_testcase.NsxClientTestCase):
def test_find_cert_with_pem_empty(self):
pem = 'abc'
with mock.patch.object(self.nsxlib.client, 'get',
with mock.patch.object(self.nsxlib.client, 'list',
return_value={'results': []}):
results = self.nsxlib.trust_management.find_cert_with_pem(pem)
self.assertEqual(0, len(results))
@ -52,7 +52,7 @@ class TestNsxLibTrustManagement(nsxlib_testcase.NsxClientTestCase):
def test_find_cert_with_pem_found(self):
pem = consts.FAKE_CERT_PEM
with mock.patch.object(
self.nsxlib.client, 'get',
self.nsxlib.client, 'list',
return_value={'results': consts.FAKE_CERT_LIST}):
results = self.nsxlib.trust_management.find_cert_with_pem(pem)
self.assertEqual(1, len(results))
@ -60,7 +60,7 @@ class TestNsxLibTrustManagement(nsxlib_testcase.NsxClientTestCase):
def test_find_cert_with_pem_rn_found(self):
pem = consts.FAKE_CERT_PEM.replace('\n', '\r\n')
with mock.patch.object(
self.nsxlib.client, 'get',
self.nsxlib.client, 'list',
return_value={'results': consts.FAKE_CERT_LIST}):
results = self.nsxlib.trust_management.find_cert_with_pem(pem)
self.assertEqual(1, len(results))

View File

@ -60,7 +60,7 @@ class NsxLibTrustManagement(utils.NsxLibApiBase):
return self.client.get(resource)
def get_certs(self):
return self.client.get(CERT_SECTION)['results']
return self.client.list(CERT_SECTION)['results']
def delete_cert(self, cert_id):
resource = CERT_SECTION + '/' + cert_id