Ejemplo n.º 1
0
    def test_store_cert(self):
        x509keypair = utils.get_test_x509keypair()
        with mock.patch.object(self.dbapi, 'create_x509keypair',
                               autospec=True) as mock_create_x509keypair:
            mock_create_x509keypair.return_value = x509keypair

            uuid = x509_cm.CertManager.store_cert(context=self.context,
                                                  **x509keypair)
            self.assertEqual(uuid, '72625085-c507-4410-9b28-cd7cf1fbf1ad')
Ejemplo n.º 2
0
 def setUp(self):
     super(RPCAPITestCase, self).setUp()
     self.fake_bay = dbutils.get_test_bay(driver='fake-driver')
     self.fake_container = dbutils.get_test_container(driver='fake-driver')
     self.fake_pod = dbutils.get_test_pod(driver='fake-driver')
     self.fake_rc = dbutils.get_test_rc(driver='fake-driver')
     self.fake_service = dbutils.get_test_service(driver='fake-driver')
     self.fake_x509keypair = dbutils.get_test_x509keypair(
         driver='fake-driver')
Ejemplo n.º 3
0
 def setUp(self):
     super(RPCAPITestCase, self).setUp()
     self.fake_bay = dbutils.get_test_bay(driver='fake-driver')
     self.fake_container = dbutils.get_test_container(driver='fake-driver')
     self.fake_pod = dbutils.get_test_pod(driver='fake-driver')
     self.fake_rc = dbutils.get_test_rc(driver='fake-driver')
     self.fake_service = dbutils.get_test_service(driver='fake-driver')
     self.fake_x509keypair = dbutils.get_test_x509keypair(
         driver='fake-driver')
    def test_store_cert(self):
        x509keypair = utils.get_test_x509keypair()
        with mock.patch.object(self.dbapi, 'create_x509keypair',
                               autospec=True) as mock_create_x509keypair:
            mock_create_x509keypair.return_value = x509keypair

            uuid = x509_cm.CertManager.store_cert(context=self.context,
                                                  **x509keypair)
            self.assertEqual(uuid, '72625085-c507-4410-9b28-cd7cf1fbf1ad')
Ejemplo n.º 5
0
 def setUp(self):
     super(RPCAPITestCase, self).setUp()
     self.fake_bay = dbutils.get_test_bay(driver='fake-driver')
     self.fake_container = dbutils.get_test_container(driver='fake-driver')
     self.fake_rc = dbutils.get_test_rc(driver='fake-driver')
     self.fake_service = dbutils.get_test_service(driver='fake-driver')
     self.fake_x509keypair = dbutils.get_test_x509keypair(
         driver='fake-driver')
     self.fake_certificate = objects.Certificate.from_db_bay(self.fake_bay)
     self.fake_certificate.csr = 'fake-csr'
Ejemplo n.º 6
0
 def setUp(self):
     super(RPCAPITestCase, self).setUp()
     self.fake_bay = dbutils.get_test_bay(driver='fake-driver')
     self.fake_container = dbutils.get_test_container(driver='fake-driver')
     self.fake_rc = dbutils.get_test_rc(driver='fake-driver')
     self.fake_service = dbutils.get_test_service(driver='fake-driver')
     self.fake_x509keypair = dbutils.get_test_x509keypair(
         driver='fake-driver')
     self.fake_certificate = objects.Certificate.from_db_bay(self.fake_bay)
     self.fake_certificate.csr = 'fake-csr'
Ejemplo n.º 7
0
 def test_delete_cert(self):
     x509keypair = utils.get_test_x509keypair(uuid='fake-uuid')
     with mock.patch.object(self.dbapi, 'get_x509keypair_by_uuid',
                            autospec=True) as mock_get_x509keypair:
         mock_get_x509keypair.return_value = x509keypair
         with mock.patch.object(self.dbapi, 'destroy_x509keypair',
                                autospec=True) as mock_destroy_x509keypair:
             x509_cm.CertManager.delete_cert('fake-uuid',
                                             context=self.context)
             mock_get_x509keypair.assert_called_once_with(self.context,
                                                          'fake-uuid')
             mock_destroy_x509keypair.assert_called_once_with('fake-uuid')
Ejemplo n.º 8
0
def get_test_x509keypair(context, **kw):
    """Return a X509KeyPair object with appropriate attributes.

    NOTE: The object leaves the attributes marked as changed, such
    that a create() could be used to commit it to the DB.
    """
    db_x509keypair = db_utils.get_test_x509keypair(**kw)
    # Let DB generate ID if it isn't specified explicitly
    if 'id' not in kw:
        del db_x509keypair['id']
    x509keypair = objects.X509KeyPair(context)
    for key in db_x509keypair:
        setattr(x509keypair, key, db_x509keypair[key])
    return x509keypair
Ejemplo n.º 9
0
def get_test_x509keypair(context, **kw):
    """Return a X509KeyPair object with appropriate attributes.

    NOTE: The object leaves the attributes marked as changed, such
    that a create() could be used to commit it to the DB.
    """
    db_x509keypair = db_utils.get_test_x509keypair(**kw)
    # Let DB generate ID if it isn't specified explicitly
    if 'id' not in kw:
        del db_x509keypair['id']
    x509keypair = objects.X509KeyPair(context)
    for key in db_x509keypair:
        setattr(x509keypair, key, db_x509keypair[key])
    return x509keypair
Ejemplo n.º 10
0
 def test_get_cert(self):
     x509keypair = utils.get_test_x509keypair(uuid='fake-uuid')
     with mock.patch.object(self.dbapi, 'get_x509keypair_by_uuid',
                            autospec=True) as mock_get_x509keypair:
         mock_get_x509keypair.return_value = x509keypair
         cert_obj = x509_cm.CertManager.get_cert('fake-uuid',
                                                 context=self.context)
         self.assertEqual(cert_obj.certificate, 'certificate')
         self.assertEqual(cert_obj.private_key, 'private_key')
         self.assertEqual(cert_obj.private_key_passphrase,
                          'private_key_passphrase')
         self.assertEqual(cert_obj.intermediates, 'intermediates')
         mock_get_x509keypair.assert_called_once_with(self.context,
                                                      'fake-uuid')
Ejemplo n.º 11
0
def x509keypair_post_data(**kw):
    x509keypair = utils.get_test_x509keypair(**kw)
    internal = x509keypair_controller.X509KeyPairPatchType.internal_attrs()
    return remove_internal(x509keypair, internal)
Ejemplo n.º 12
0
 def setUp(self):
     super(TestX509KeyPairObject, self).setUp()
     self.fake_x509keypair = utils.get_test_x509keypair()
Ejemplo n.º 13
0
 def setUp(self):
     super(TestX509KeyPairObject, self).setUp()
     self.fake_x509keypair = utils.get_test_x509keypair()