def certificate_authority(self): """ Gets the Certificate Authority API client. Returns: CertificateAuthority: """ return CertificateAuthority(self.__connection)
class CertificateAuthorityTest(unittest.TestCase): def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host, 800) self._certificates = CertificateAuthority(self.connection) @mock.patch.object(ResourceClient, 'get') def test_get_called_once(self, mock_get): self._certificates.get() mock_get.assert_called_once_with('/rest/certificates/ca') @mock.patch.object(ResourceClient, 'get') def test_get_crl_called_once(self, mock_get): self._certificates.get_crl() mock_get.assert_called_once_with('/rest/certificates/ca/crl') @mock.patch.object(ResourceClient, 'delete') def test_delete_called_once(self, mock_delete): self._certificates.delete("default") mock_delete.assert_called_once_with("/rest/certificates/ca/default", timeout=-1)
def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host, 800) self._certificates = CertificateAuthority(self.connection)
class CertificateAuthorityTest(unittest.TestCase): def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host, 800) self._certificates = CertificateAuthority(self.connection) self.uri = '/rest/certificates/ca' @mock.patch.object(Resource, 'create') def test_create_called_once(self, mock_create): resource = dict( certificateDetails=["test1", "test2"], ) resource_rest_call = resource.copy() mock_create.return_value = {} self._certificates.create(resource) mock_create.assert_called_once_with(resource_rest_call, uri=self.uri, timeout=-1) @mock.patch.object(Resource, 'create') def test_create_called_with_parent_task(self, mock_create): resource = dict( certificateDetails=["test1", "test2"], ) uri = "{}?parentTask={}".format(self.uri, 'parent1') resource_rest_call = resource.copy() mock_create.return_value = {} self._certificates.create(resource, 'parent1') mock_create.assert_called_once_with(resource_rest_call, uri=uri, timeout=-1) @mock.patch.object(ResourceHelper, 'get_all') def test_get_all_called_with_filter(self, mock_get_all): self._certificates.get_all(filter='name=TestName', cert_details=False) mock_get_all.assert_called_once_with(custom_headers={'If-Req-CertDetails': False}, filter='name=TestName') @mock.patch.object(ResourceHelper, 'get_all') def test_get_all_called_once(self, mock_get_all): self._certificates.get_all() mock_get_all.assert_called_once_with(custom_headers={'If-Req-CertDetails': True}, filter='') @mock.patch.object(Resource, 'get_by_uri') def test_get_by_aliasname_called_once(self, mock_get): self._certificates.get_by_aliasname('test1') mock_get.assert_called_once_with('/rest/certificates/ca/test1') @mock.patch.object(Resource, 'get_by_uri') def test_get_crl_called_once(self, mock_get): self._certificates.get_crl() mock_get.assert_called_once_with('/rest/certificates/ca/crl') @mock.patch.object(Resource, 'get_by_uri') def test_get_crl_by_aliasname_called_once(self, mock_get): self._certificates.get_crl_by_aliasname('test1') mock_get.assert_called_once_with('/rest/certificates/ca/test1/crl') @mock.patch.object(Resource, 'delete') def test_delete_called_once(self, mock_delete): self._certificates.delete("default") mock_delete.assert_called_once_with("default")