Added unit tests for the Diffie-Hellman class. Merged recent trunk changes
This commit is contained in:
@@ -77,12 +77,14 @@ from nova import crypto
|
|||||||
from nova import db
|
from nova import db
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova import flags
|
from nova import flags
|
||||||
|
from nova import log as logging
|
||||||
from nova import quota
|
from nova import quota
|
||||||
from nova import utils
|
from nova import utils
|
||||||
from nova.auth import manager
|
from nova.auth import manager
|
||||||
from nova.cloudpipe import pipelib
|
from nova.cloudpipe import pipelib
|
||||||
|
|
||||||
|
|
||||||
|
logging.basicConfig()
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
flags.DECLARE('fixed_range', 'nova.network.manager')
|
flags.DECLARE('fixed_range', 'nova.network.manager')
|
||||||
flags.DECLARE('num_networks', 'nova.network.manager')
|
flags.DECLARE('num_networks', 'nova.network.manager')
|
||||||
|
|||||||
@@ -721,7 +721,7 @@ class AuthManager(object):
|
|||||||
if project is None:
|
if project is None:
|
||||||
project = user.id
|
project = user.id
|
||||||
pid = Project.safe_id(project)
|
pid = Project.safe_id(project)
|
||||||
return self.__generate_rc(user.access, user.secret, pid, use_dmz)
|
return self.__generate_rc(user, pid, use_dmz)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __generate_rc(user, pid, use_dmz=True, host=None):
|
def __generate_rc(user, pid, use_dmz=True, host=None):
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ from nova.compute import power_state
|
|||||||
from nova.virt import xenapi_conn
|
from nova.virt import xenapi_conn
|
||||||
from nova.virt.xenapi import fake as xenapi_fake
|
from nova.virt.xenapi import fake as xenapi_fake
|
||||||
from nova.virt.xenapi import volume_utils
|
from nova.virt.xenapi import volume_utils
|
||||||
|
from nova.virt.xenapi.vmops import SimpleDH
|
||||||
from nova.tests.db import fakes as db_fakes
|
from nova.tests.db import fakes as db_fakes
|
||||||
from nova.tests.xenapi import stubs
|
from nova.tests.xenapi import stubs
|
||||||
|
|
||||||
@@ -262,3 +263,33 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
instance = db.instance_create(values)
|
instance = db.instance_create(values)
|
||||||
self.conn.spawn(instance)
|
self.conn.spawn(instance)
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class XenAPIDiffieHellmanTestCase(test.TestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for Diffie-Hellman code
|
||||||
|
"""
|
||||||
|
def setUp(self):
|
||||||
|
super(XenAPIDiffieHellmanTestCase, self).setUp()
|
||||||
|
self.alice = SimpleDH()
|
||||||
|
self.bob = SimpleDH()
|
||||||
|
|
||||||
|
def test_shared(self):
|
||||||
|
alice_pub = self.alice.get_public()
|
||||||
|
bob_pub = self.bob.get_public()
|
||||||
|
alice_shared = self.alice.compute_shared(bob_pub)
|
||||||
|
bob_shared = self.bob.compute_shared(alice_pub)
|
||||||
|
self.assertEquals(alice_shared, bob_shared)
|
||||||
|
|
||||||
|
def test_encryption(self):
|
||||||
|
msg = "This is a top-secret message"
|
||||||
|
enc = self.alice.encrypt(msg)
|
||||||
|
dec = self.bob.decrypt(enc)
|
||||||
|
self.assertEquals(dec, msg)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super(XenAPIDiffieHellmanTestCase, self).tearDown()
|
||||||
|
|||||||
Reference in New Issue
Block a user