Merge "Add Create identity with cert" into stable/train
This commit is contained in:
commit
955dc46656
|
@ -64,3 +64,24 @@ class TestNsxLibTrustManagement(nsxlib_testcase.NsxClientTestCase):
|
||||||
return_value={'results': consts.FAKE_CERT_LIST}):
|
return_value={'results': consts.FAKE_CERT_LIST}):
|
||||||
results = self.nsxlib.trust_management.find_cert_with_pem(pem)
|
results = self.nsxlib.trust_management.find_cert_with_pem(pem)
|
||||||
self.assertEqual(1, len(results))
|
self.assertEqual(1, len(results))
|
||||||
|
|
||||||
|
def test_create_identity_with_cert(self):
|
||||||
|
fake_pem = consts.FAKE_CERT_PEM
|
||||||
|
name = "test-identity"
|
||||||
|
cert_api = self.nsxlib.trust_management
|
||||||
|
body = {
|
||||||
|
'name': name,
|
||||||
|
'certificate_pem': fake_pem,
|
||||||
|
'node_id': 'test_node_id',
|
||||||
|
'role': 'enterprise_admin',
|
||||||
|
'is_protected': True
|
||||||
|
}
|
||||||
|
with mock.patch.object(self.nsxlib.client, 'create') as create:
|
||||||
|
cert_api.create_identity_with_cert(
|
||||||
|
name=name,
|
||||||
|
cert_pem=fake_pem,
|
||||||
|
node_id='test_node_id',
|
||||||
|
role='enterprise_admin')
|
||||||
|
create.assert_called_with(
|
||||||
|
'trust-management/principal-identities/with-certificate',
|
||||||
|
body)
|
||||||
|
|
|
@ -21,6 +21,7 @@ from vmware_nsxlib.v3 import utils
|
||||||
BASE_SECTION = 'trust-management'
|
BASE_SECTION = 'trust-management'
|
||||||
CERT_SECTION = BASE_SECTION + '/certificates'
|
CERT_SECTION = BASE_SECTION + '/certificates'
|
||||||
ID_SECTION = BASE_SECTION + '/principal-identities'
|
ID_SECTION = BASE_SECTION + '/principal-identities'
|
||||||
|
ID_WITH_CERT_SECTION = BASE_SECTION + '/principal-identities/with-certificate'
|
||||||
USER_GROUP_TYPES = [
|
USER_GROUP_TYPES = [
|
||||||
'read_only_api_users',
|
'read_only_api_users',
|
||||||
'read_write_api_users',
|
'read_write_api_users',
|
||||||
|
@ -136,3 +137,11 @@ class NsxLibTrustManagement(utils.NsxLibApiBase):
|
||||||
except nsxlib_exc.ManagerError as e:
|
except nsxlib_exc.ManagerError as e:
|
||||||
self.delete_cert(nsx_cert_id)
|
self.delete_cert(nsx_cert_id)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
def create_identity_with_cert(self, name, cert_pem,
|
||||||
|
node_id, role,
|
||||||
|
is_protected=True):
|
||||||
|
body = {'name': name, 'certificate_pem': cert_pem,
|
||||||
|
'node_id': node_id, 'role': role,
|
||||||
|
'is_protected': is_protected}
|
||||||
|
self.client.create(ID_WITH_CERT_SECTION, body)
|
||||||
|
|
Loading…
Reference in New Issue