Rework completed. Added test cases, changed helper method name, etc.
This commit is contained in:
@@ -25,7 +25,6 @@ from nova import log as logging
|
||||
from nova import test
|
||||
from nova.auth import manager
|
||||
from nova.api.ec2 import cloud
|
||||
from nova.auth import authutils
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
LOG = logging.getLogger('nova.tests.auth_unittest')
|
||||
@@ -102,9 +101,43 @@ class _AuthManagerBaseTestCase(test.TestCase):
|
||||
self.assertEqual('private-party', u.access)
|
||||
|
||||
def test_004_signature_is_valid(self):
|
||||
#self.assertTrue(self.manager.authenticate(**boto.generate_url ...? ))
|
||||
pass
|
||||
#raise NotImplementedError
|
||||
with user_generator(self.manager, name='admin', secret='admin',
|
||||
access='admin'):
|
||||
with project_generator(self.manager, name="admin",
|
||||
manager_user='admin'):
|
||||
accesskey = 'admin:admin'
|
||||
expected_result = (self.manager.get_user('admin'),
|
||||
self.manager.get_project('admin'))
|
||||
# captured sig and query string using boto 1.9b/euca2ools 1.2
|
||||
sig = 'd67Wzd9Bwz8xid9QU+lzWXcF2Y3tRicYABPJgrqfrwM='
|
||||
auth_params = {'AWSAccessKeyId': 'admin:admin',
|
||||
'Action': 'DescribeAvailabilityZones',
|
||||
'SignatureMethod': 'HmacSHA256',
|
||||
'SignatureVersion': '2',
|
||||
'Timestamp': '2011-04-22T11:29:29',
|
||||
'Version': '2009-11-30'}
|
||||
self.assertTrue(expected_result, self.manager.authenticate(
|
||||
accesskey,
|
||||
sig,
|
||||
auth_params,
|
||||
'GET',
|
||||
'127.0.0.1:8773',
|
||||
'/services/Cloud/'))
|
||||
# captured sig and query string using RightAWS 1.10.0
|
||||
sig = 'ECYLU6xdFG0ZqRVhQybPJQNJ5W4B9n8fGs6+/fuGD2c='
|
||||
auth_params = {'AWSAccessKeyId': 'admin:admin',
|
||||
'Action': 'DescribeAvailabilityZones',
|
||||
'SignatureMethod': 'HmacSHA256',
|
||||
'SignatureVersion': '2',
|
||||
'Timestamp': '2011-04-22T11:29:49.000Z',
|
||||
'Version': '2008-12-01'}
|
||||
self.assertTrue(expected_result, self.manager.authenticate(
|
||||
accesskey,
|
||||
sig,
|
||||
auth_params,
|
||||
'GET',
|
||||
'127.0.0.1',
|
||||
'/services/Cloud'))
|
||||
|
||||
def test_005_can_get_credentials(self):
|
||||
return
|
||||
@@ -340,29 +373,6 @@ class AuthManagerDbTestCase(_AuthManagerBaseTestCase):
|
||||
auth_driver = 'nova.auth.dbdriver.DbDriver'
|
||||
|
||||
|
||||
class AuthManagerUtilTestCase(test.TestCase):
|
||||
def test_get_host_only_server_string(self):
|
||||
result = authutils.get_host_only_server_string('::1')
|
||||
self.assertEqual('', result)
|
||||
result = authutils.get_host_only_server_string('[::1]:8773')
|
||||
self.assertEqual('::1', result)
|
||||
result = authutils.get_host_only_server_string('2001:db8::192.168.1.1')
|
||||
self.assertEqual('', result)
|
||||
result = authutils.get_host_only_server_string(
|
||||
'[2001:db8::192.168.1.1]:8773')
|
||||
self.assertEqual('2001:db8::192.168.1.1', result)
|
||||
result = authutils.get_host_only_server_string('192.168.1.1')
|
||||
self.assertEqual('', result)
|
||||
result = authutils.get_host_only_server_string('192.168.1.2:8773')
|
||||
self.assertEqual('192.168.1.2', result)
|
||||
result = authutils.get_host_only_server_string('192.168.1.3')
|
||||
self.assertEqual('', result)
|
||||
result = authutils.get_host_only_server_string('www.example.com:8443')
|
||||
self.assertEqual('www.example.com', result)
|
||||
result = authutils.get_host_only_server_string('www.example.com')
|
||||
self.assertEqual('', result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# TODO: Implement use_fake as an option
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user