From c386221bd8f757fe98abd076d21f3a1fdd9712e2 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 9 Nov 2011 04:35:39 -0800 Subject: [PATCH 1/3] started --- novaclient/shell.py | 22 +++++++++++----------- novaclient/v1_0/client.py | 6 +++--- novaclient/v1_1/client.py | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/novaclient/shell.py b/novaclient/shell.py index 5a7bb43cf..1afcd0695 100644 --- a/novaclient/shell.py +++ b/novaclient/shell.py @@ -62,9 +62,9 @@ class OpenStackComputeShell(object): default=env('NOVA_USERNAME'), help='Defaults to env[NOVA_USERNAME].') - parser.add_argument('--apikey', - default=env('NOVA_API_KEY'), - help='Defaults to env[NOVA_API_KEY].') + parser.add_argument('--password', + default=env('NOVA_PASSWORD'), + help='Defaults to env[NOVA_PASSWORD].') parser.add_argument('--projectid', default=env('NOVA_PROJECT_ID'), @@ -153,21 +153,21 @@ class OpenStackComputeShell(object): self.do_help(args) return 0 - user, apikey, projectid, url, region_name, insecure = \ - args.username, args.apikey, args.projectid, args.url, \ + user, password, projectid, url, region_name, insecure = \ + args.username, args.password, args.projectid, args.url, \ args.region_name, args.insecure #FIXME(usrleon): Here should be restrict for project id same as - # for username or apikey but for compatibility it is not. + # for username or password but for compatibility it is not. if not user: raise exc.CommandError("You must provide a username, either" "via --username or via " "env[NOVA_USERNAME]") - if not apikey: - raise exc.CommandError("You must provide an API key, either" - "via --apikey or via" - "env[NOVA_API_KEY]") + if not password: + raise exc.CommandError("You must provide a password, either" + "via --password or via" + "env[NOVA_PASSWORD]") if options.version and options.version != '1.0': if not projectid: raise exc.CommandError("You must provide an projectid, either" @@ -179,7 +179,7 @@ class OpenStackComputeShell(object): "via --url or via" "env[NOVA_URL") - self.cs = self.get_api_class(options.version)(user, apikey, projectid, + self.cs = self.get_api_class(options.version)(user, password, projectid, url, insecure, region_name=region_name) try: diff --git a/novaclient/v1_0/client.py b/novaclient/v1_0/client.py index 4f5a532da..9c3111176 100644 --- a/novaclient/v1_0/client.py +++ b/novaclient/v1_0/client.py @@ -14,7 +14,7 @@ class Client(object): Create an instance with your creds:: - >>> client = Client(USERNAME, API_KEY, PROJECT_ID, AUTH_URL) + >>> client = Client(USERNAME, PASSWORD, PROJECT_ID, AUTH_URL) Then call methods on its managers:: @@ -25,7 +25,7 @@ class Client(object): """ - def __init__(self, username, api_key, project_id, auth_url=None, + def __init__(self, username, password, project_id, auth_url=None, insecure=False, timeout=None, token=None, region_name=None): self.accounts = accounts.AccountManager(self) @@ -39,7 +39,7 @@ class Client(object): _auth_url = auth_url or 'https://auth.api.rackspacecloud.com/v1.0' self.client = client.HTTPClient(username, - api_key, + password, project_id, _auth_url, insecure=insecure, diff --git a/novaclient/v1_1/client.py b/novaclient/v1_1/client.py index 31e49fefb..224139ae2 100644 --- a/novaclient/v1_1/client.py +++ b/novaclient/v1_1/client.py @@ -17,7 +17,7 @@ class Client(object): Create an instance with your creds:: - >>> client = Client(USERNAME, API_KEY, PROJECT_ID, AUTH_URL) + >>> client = Client(USERNAME, PASSWORD, PROJECT_ID, AUTH_URL) Then call methods on its managers:: @@ -29,7 +29,7 @@ class Client(object): """ # FIXME(jesse): project_id isn't required to autenticate - def __init__(self, username, api_key, project_id, auth_url, + def __init__(self, username, password, project_id, auth_url, insecure=False, timeout=None, token=None, region_name=None): self.flavors = flavors.FlavorManager(self) self.floating_ips = floating_ips.FloatingIPManager(self) @@ -46,7 +46,7 @@ class Client(object): security_group_rules.SecurityGroupRuleManager(self) self.client = client.HTTPClient(username, - api_key, + password, project_id, auth_url, insecure=insecure, From cdde0d22cd4b9be02fd2080687ebd02fda80b7f3 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 9 Nov 2011 07:10:46 -0800 Subject: [PATCH 2/3] tests working --- README.rst | 7 ++++--- docs/api.rst | 2 +- docs/shell.rst | 8 ++++---- novaclient/client.py | 8 ++++---- novaclient/v1_0/shell.py | 11 ++++++----- novaclient/v1_1/shell.py | 18 ++++++++++-------- tests/test_shell.py | 2 +- tests/v1_0/fakes.py | 2 +- tests/v1_0/test_shell.py | 6 +++--- tests/v1_1/fakes.py | 6 +++--- tests/v1_1/test_auth.py | 20 ++++++++++---------- tests/v1_1/test_shell.py | 6 +++--- 12 files changed, 50 insertions(+), 46 deletions(-) diff --git a/README.rst b/README.rst index af07bfca6..0ac9a09d9 100644 --- a/README.rst +++ b/README.rst @@ -40,7 +40,7 @@ with the ``--username``, ``--apikey`` and ``--projectid`` params, but it's easi set them as environment variables:: export NOVA_USERNAME=openstack - export NOVA_API_KEY=yadayada + export NOVA_PASSWORD=yadayada export NOVA_PROJECT_ID=myproject You will also need to define the authentication url with ``--url`` and the @@ -64,6 +64,7 @@ You'll find complete documentation on the shell by running usage: nova [--username USERNAME] [--apikey APIKEY] [--projectid PROJECTID] [--url URL] [--version VERSION] [--region_name NAME] + [--endpoint_name NAME] ... Command-line interface to the OpenStack Nova API. @@ -141,7 +142,7 @@ You'll find complete documentation on the shell by running Optional arguments: --username USERNAME Defaults to env[NOVA_USERNAME]. - --apikey APIKEY Defaults to env[NOVA_API_KEY]. + --apikey PASSWORD Defaults to env[NOVA_PASSWORD]. --apikey PROJECTID Defaults to env[NOVA_PROJECT_ID]. --url AUTH_URL Defaults to env[NOVA_URL] or https://auth.api.rackspacecloud.com/v1.0 @@ -164,7 +165,7 @@ __ http://packages.python.org/python-novaclient/ By way of a quick-start:: >>> import novaclient - >>> nt = novaclient.OpenStack(USERNAME, API_KEY,PROJECT_ID [, AUTH_URL]) + >>> nt = novaclient.OpenStack(USERNAME, PASSWORD, PROJECT_ID [, AUTH_URL]) >>> nt.flavors.list() [...] >>> nt.servers.list() diff --git a/docs/api.rst b/docs/api.rst index 1d46c2fdf..6e2b1002a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -12,7 +12,7 @@ Usage First create an instance of :class:`OpenStack` with your credentials:: >>> from novaclient import OpenStack - >>> nova = OpenStack(USERNAME, API_KEY, AUTH_URL) + >>> nova = OpenStack(USERNAME, PASSWORD, AUTH_URL) Then call methods on the :class:`OpenStack` object: diff --git a/docs/shell.rst b/docs/shell.rst index 70a1ab6db..79d9e1a85 100644 --- a/docs/shell.rst +++ b/docs/shell.rst @@ -11,7 +11,7 @@ First, you'll need an OpenStack Nova account and an API key. You get this by using the `nova-manage` command in OpenStack Nova. You'll need to provide :program:`nova` with your OpenStack username and -API key. You can do this with the :option:`--username`, :option:`--apikey` +API key. You can do this with the :option:`--username`, :option:`--password` and :option:`--projectid` options, but it's easier to just set them as environment variables by setting two environment variables: @@ -19,9 +19,9 @@ environment variables by setting two environment variables: Your OpenStack Nova username. -.. envvar:: NOVA_API_KEY +.. envvar:: NOVA_PASSWORD - Your API key. + Your password. .. envvar:: NOVA_PROJECT_ID @@ -38,7 +38,7 @@ environment variables by setting two environment variables: For example, in Bash you'd use:: export NOVA_USERNAME=yourname - export NOVA_API_KEY=yadayadayada + export NOVA_PASSWORD=yadayadayada export NOVA_PROJECT_ID=myproject export NOVA_URL=http://... export NOVA_VERSION=1.0 diff --git a/novaclient/client.py b/novaclient/client.py index 2a07e2c4a..2a7a8e2f8 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -37,11 +37,11 @@ class HTTPClient(httplib2.Http): USER_AGENT = 'python-novaclient' - def __init__(self, user, apikey, projectid, auth_url, insecure=False, + def __init__(self, user, password, projectid, auth_url, insecure=False, timeout=None, token=None, region_name=None): super(HTTPClient, self).__init__(timeout=timeout) self.user = user - self.apikey = apikey + self.password = password self.projectid = projectid self.auth_url = auth_url self.version = 'v1.0' @@ -239,7 +239,7 @@ class HTTPClient(httplib2.Http): raise NoTokenLookupException() headers = {'X-Auth-User': self.user, - 'X-Auth-Key': self.apikey} + 'X-Auth-Key': self.password} if self.projectid: headers['X-Auth-Project-Id'] = self.projectid @@ -260,7 +260,7 @@ class HTTPClient(httplib2.Http): """Authenticate against a v2.0 auth service.""" body = {"auth": { "passwordCredentials": {"username": self.user, - "password": self.apikey}}} + "password": self.password}}} if self.projectid: body['auth']['tenantName'] = self.projectid diff --git a/novaclient/v1_0/shell.py b/novaclient/v1_0/shell.py index 6528c6968..438b60d3d 100644 --- a/novaclient/v1_0/shell.py +++ b/novaclient/v1_0/shell.py @@ -674,7 +674,8 @@ def do_delete(cs, args): @utils.arg('--api_url', dest='api_url', default=None, help='New URL.') @utils.arg('--zone_username', dest='zone_username', default=None, help='New zone username.') -@utils.arg('--password', dest='password', default=None, help='New password.') +@utils.arg('--zone_password', dest='zone_password', default=None, + help='New password.') @utils.arg('--weight_offset', dest='weight_offset', default=None, help='Child Zone weight offset.') @utils.arg('--weight_scale', dest='weight_scale', default=None, @@ -689,8 +690,8 @@ def do_zone(cs, args): zone_delta['api_url'] = args.api_url if args.zone_username: zone_delta['username'] = args.zone_username - if args.password: - zone_delta['password'] = args.password + if args.zone_password: + zone_delta['password'] = args.zone_password if args.weight_offset: zone_delta['weight_offset'] = args.weight_offset if args.weight_scale: @@ -713,7 +714,7 @@ def do_zone_info(cs, args): @utils.arg('--zone_username', metavar='', help='Optional Authentication username. (Default=None)', default=None) -@utils.arg('--password', metavar='', +@utils.arg('--zone_password', metavar='', help='Authentication password. (Default=None)', default=None) @utils.arg('--weight_offset', metavar='', @@ -725,7 +726,7 @@ def do_zone_info(cs, args): def do_zone_add(cs, args): """Add a new child zone.""" zone = cs.zones.create(args.zone_name, args.api_url, - args.zone_username, args.password, + args.zone_username, args.zone_password, args.weight_offset, args.weight_scale) utils.print_dict(zone._info) diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index d44e16a87..de2e31d5a 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -455,15 +455,16 @@ def do_reboot(cs, args): @utils.arg('server', metavar='', help='Name or ID of server.') @utils.arg('image', metavar='', help="Name or ID of new image.") -@utils.arg('--password', dest='password', metavar='', default=False, +@utils.arg('--rebuild_password', dest='rebuild_password', + metavar='', default=False, help="Set the provided password on the rebuild instance.") def do_rebuild(cs, args): """Shutdown, re-image, and re-boot a server.""" server = _find_server(cs, args.server) image = _find_image(cs, args.image) - if args.password != False: - _password = args.password + if args.rebuild_password != False: + _password = args.rebuild_password else: _password = None @@ -675,7 +676,8 @@ def _find_flavor(cs, flavor): @utils.arg('--api_url', dest='api_url', default=None, help='New URL.') @utils.arg('--zone_username', dest='zone_username', default=None, help='New zone username.') -@utils.arg('--password', dest='password', default=None, help='New password.') +@utils.arg('--zone_password', dest='zone_password', default=None, + help='New password.') @utils.arg('--weight_offset', dest='weight_offset', default=None, help='Child Zone weight offset.') @utils.arg('--weight_scale', dest='weight_scale', default=None, @@ -690,8 +692,8 @@ def do_zone(cs, args): zone_delta['api_url'] = args.api_url if args.zone_username: zone_delta['username'] = args.zone_username - if args.password: - zone_delta['password'] = args.password + if args.zone_password: + zone_delta['password'] = args.zone_password if args.weight_offset: zone_delta['weight_offset'] = args.weight_offset if args.weight_scale: @@ -714,7 +716,7 @@ def do_zone_info(cs, args): @utils.arg('--zone_username', metavar='', help='Optional Authentication username. (Default=None)', default=None) -@utils.arg('--password', metavar='', +@utils.arg('--zone_password', metavar='', help='Authentication password. (Default=None)', default=None) @utils.arg('--weight_offset', metavar='', @@ -726,7 +728,7 @@ def do_zone_info(cs, args): def do_zone_add(cs, args): """Add a new child zone.""" zone = cs.zones.create(args.zone_name, args.api_url, - args.zone_username, args.password, + args.zone_username, args.zone_password, args.weight_offset, args.weight_scale) utils.print_dict(zone._info) diff --git a/tests/test_shell.py b/tests/test_shell.py index 38f8ef3a9..27d8fd367 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -14,7 +14,7 @@ class ShellTest(utils.TestCase): global _old_env fake_env = { 'NOVA_USERNAME': 'username', - 'NOVA_API_KEY': 'password', + 'NOVA_PASSWORD': 'password', 'NOVA_PROJECT_ID': 'project_id', 'NOVA_URL': 'http://no.where', } diff --git a/tests/v1_0/fakes.py b/tests/v1_0/fakes.py index 7646a2d05..3659610c5 100644 --- a/tests/v1_0/fakes.py +++ b/tests/v1_0/fakes.py @@ -18,7 +18,7 @@ class FakeClient(fakes.FakeClient, client.Client): class FakeHTTPClient(base_client.HTTPClient): def __init__(self, **kwargs): self.username = 'username' - self.apikey = 'apikey' + self.password = 'password' self.auth_url = 'auth_url' self.callstack = [] diff --git a/tests/v1_0/test_shell.py b/tests/v1_0/test_shell.py index d97bbc4b0..01afdb705 100644 --- a/tests/v1_0/test_shell.py +++ b/tests/v1_0/test_shell.py @@ -14,7 +14,7 @@ class ShellTest(utils.TestCase): self.old_environment = os.environ.copy() os.environ = { 'NOVA_USERNAME': 'username', - 'NOVA_API_KEY': 'password', + 'NOVA_PASSWORD': 'password', 'NOVA_PROJECT_ID': 'project_id', 'NOVA_VERSION': '1.0', } @@ -304,7 +304,7 @@ class ShellTest(utils.TestCase): self.assert_called('GET', '/zones/1') self.run_command('zone 1 --api_url=http://zzz ' - '--zone_username=frank --password=xxx') + '--zone_username=frank --zone_password=xxx') self.assert_called( 'PUT', '/zones/1', {'zone': {'username': 'frank', 'password': 'xxx', @@ -313,7 +313,7 @@ class ShellTest(utils.TestCase): def test_zone_add(self): self.run_command('zone-add child_zone http://zzz ' - '--zone_username=frank --password=xxx ' + '--zone_username=frank --zone_password=xxx ' '--weight_offset=0.0 --weight_scale=1.0') self.assert_called( 'POST', '/zones', diff --git a/tests/v1_1/fakes.py b/tests/v1_1/fakes.py index a1554fe0d..1638de3d0 100644 --- a/tests/v1_1/fakes.py +++ b/tests/v1_1/fakes.py @@ -8,7 +8,7 @@ from tests import fakes class FakeClient(fakes.FakeClient, client.Client): def __init__(self, *args, **kwargs): - client.Client.__init__(self, 'username', 'apikey', + client.Client.__init__(self, 'username', 'password', 'project_id', 'auth_url') self.client = FakeHTTPClient(**kwargs) @@ -17,7 +17,7 @@ class FakeHTTPClient(base_client.HTTPClient): def __init__(self, **kwargs): self.username = 'username' - self.apikey = 'apikey' + self.password = 'password' self.auth_url = 'auth_url' self.callstack = [] @@ -324,7 +324,7 @@ class FakeHTTPClient(base_client.HTTPClient): ]}) def get_os_floating_ips_1(self, **kw): - return (200, {'floating_ip': + return (200, {'floating_ip': {'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1'} }) diff --git a/tests/v1_1/test_auth.py b/tests/v1_1/test_auth.py index 9be2ce365..0e20f500f 100644 --- a/tests/v1_1/test_auth.py +++ b/tests/v1_1/test_auth.py @@ -19,7 +19,7 @@ def to_http_response(resp_dict): class AuthenticateAgainstKeystoneTests(utils.TestCase): def test_authenticate_success(self): - cs = client.Client("username", "apikey", "project_id", "auth_url/v2.0") + cs = client.Client("username", "password", "project_id", "auth_url/v2.0") resp = {"access": {"token": {"expires": "12345", "id": "FAKE_ID"}, "serviceCatalog": [ @@ -44,7 +44,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): 'Content-Type': 'application/json', } body = {'auth': { 'passwordCredentials': {'username': cs.client.user, - 'password': cs.client.apikey}, + 'password': cs.client.password}, 'tenantName': cs.client.projectid, }} token_url = urlparse.urljoin(cs.client.auth_url, "tokens") @@ -60,7 +60,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): test_auth_call() def test_authenticate_failure(self): - cs = client.Client("username", "apikey", "project_id", "auth_url/v2.0") + cs = client.Client("username", "password", "project_id", "auth_url/v2.0") resp = {"unauthorized": {"message": "Unauthorized", "code": "401"}} auth_response = httplib2.Response({ "status": 401, @@ -77,7 +77,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): test_auth_call() def test_auth_redirect(self): - cs = client.Client("username", "apikey", "project_id", "auth_url/v1.0") + cs = client.Client("username", "password", "project_id", "auth_url/v1.0") dict_correct_response = {"access": {"token": {"expires": "12345", "id": "FAKE_ID"}, "serviceCatalog": [{ "type": "compute", @@ -116,7 +116,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): 'Content-Type': 'application/json',} body = {'auth': { 'passwordCredentials': {'username': cs.client.user, - 'password': cs.client.apikey}, + 'password': cs.client.password}, 'tenantName': cs.client.projectid,}} token_url = urlparse.urljoin(cs.client.auth_url, "tokens") @@ -135,7 +135,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): class AuthenticationTests(utils.TestCase): def test_authenticate_success(self): - cs = client.Client("username", "apikey", "project_id", "auth_url") + cs = client.Client("username", "password", "project_id", "auth_url") management_url = 'https://servers.api.rackspacecloud.com/v1.1/443470' auth_response = httplib2.Response({ 'status': 204, @@ -149,7 +149,7 @@ class AuthenticationTests(utils.TestCase): cs.client.authenticate() headers = { 'X-Auth-User': 'username', - 'X-Auth-Key': 'apikey', + 'X-Auth-Key': 'password', 'X-Auth-Project-Id': 'project_id', 'User-Agent': cs.client.USER_AGENT } @@ -163,7 +163,7 @@ class AuthenticationTests(utils.TestCase): test_auth_call() def test_authenticate_failure(self): - cs = client.Client("username", "apikey", "project_id", "auth_url") + cs = client.Client("username", "password", "project_id", "auth_url") auth_response = httplib2.Response({'status': 401}) mock_request = mock.Mock(return_value=(auth_response, None)) @@ -174,7 +174,7 @@ class AuthenticationTests(utils.TestCase): test_auth_call() def test_auth_automatic(self): - cs = client.Client("username", "apikey", "project_id", "auth_url") + cs = client.Client("username", "password", "project_id", "auth_url") http_client = cs.client http_client.management_url = '' mock_request = mock.Mock(return_value=(None, None)) @@ -189,7 +189,7 @@ class AuthenticationTests(utils.TestCase): test_auth_call() def test_auth_manual(self): - cs = client.Client("username", "apikey", "project_id", "auth_url") + cs = client.Client("username", "password", "project_id", "auth_url") @mock.patch.object(cs.client, 'authenticate') def test_auth_call(m): diff --git a/tests/v1_1/test_shell.py b/tests/v1_1/test_shell.py index 33d28a5a5..70c3b5a19 100644 --- a/tests/v1_1/test_shell.py +++ b/tests/v1_1/test_shell.py @@ -17,7 +17,7 @@ class ShellTest(utils.TestCase): self.old_environment = os.environ.copy() os.environ = { 'NOVA_USERNAME': 'username', - 'NOVA_API_KEY': 'password', + 'NOVA_PASSWORD': 'password', 'NOVA_PROJECT_ID': 'project_id', 'NOVA_VERSION': '1.1', 'NOVA_URL': 'http://no.where', @@ -228,7 +228,7 @@ class ShellTest(utils.TestCase): # {'rebuild': {'imageRef': 1}}) self.assert_called('GET', '/images/2') - self.run_command('rebuild sample-server 1 --password asdf') + self.run_command('rebuild sample-server 1 --rebuild_password asdf') # XXX need a way to test multiple calls #self.assert_called('POST', '/servers/1234/action', # {'rebuild': {'imageRef': 1, 'adminPass': 'asdf'}}) @@ -267,7 +267,7 @@ class ShellTest(utils.TestCase): self.assert_called('GET', '/images/2') def test_show_bad_id(self): - self.assertRaises(exceptions.CommandError, + self.assertRaises(exceptions.CommandError, self.run_command, 'show xxx') def test_delete(self): From 00f05317efb8bab78d487a7c36571082269d3139 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 9 Nov 2011 07:18:22 -0800 Subject: [PATCH 3/3] few missing references to api_key --- README.rst | 8 ++++---- tests/test_http.py | 2 +- tests/v1_0/fakes.py | 2 +- tests/v1_0/test_auth.py | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 0ac9a09d9..39305c165 100644 --- a/README.rst +++ b/README.rst @@ -36,7 +36,7 @@ Installing this package gets you a shell command, ``nova``, that you can use to interact with any Rackspace compatible API (including OpenStack). You'll need to provide your OpenStack username and API key. You can do this -with the ``--username``, ``--apikey`` and ``--projectid`` params, but it's easier to just +with the ``--username``, ``--password`` and ``--projectid`` params, but it's easier to just set them as environment variables:: export NOVA_USERNAME=openstack @@ -62,7 +62,7 @@ can specify the one you want with ``--region_name`` (or You'll find complete documentation on the shell by running ``nova help``:: - usage: nova [--username USERNAME] [--apikey APIKEY] [--projectid PROJECTID] + usage: nova [--username USERNAME] [--password PASSWORD] [--projectid PROJECTID] [--url URL] [--version VERSION] [--region_name NAME] [--endpoint_name NAME] ... @@ -142,8 +142,8 @@ You'll find complete documentation on the shell by running Optional arguments: --username USERNAME Defaults to env[NOVA_USERNAME]. - --apikey PASSWORD Defaults to env[NOVA_PASSWORD]. - --apikey PROJECTID Defaults to env[NOVA_PROJECT_ID]. + --password PASSWORD Defaults to env[NOVA_PASSWORD]. + --projectid PROJECTID Defaults to env[NOVA_PROJECT_ID]. --url AUTH_URL Defaults to env[NOVA_URL] or https://auth.api.rackspacecloud.com/v1.0 if undefined. diff --git a/tests/test_http.py b/tests/test_http.py index 90062b425..9ef878e51 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -12,7 +12,7 @@ mock_request = mock.Mock(return_value=(fake_response, fake_body)) def get_client(): - cl = client.HTTPClient("username", "apikey", + cl = client.HTTPClient("username", "password", "project_id", "auth_test") return cl diff --git a/tests/v1_0/fakes.py b/tests/v1_0/fakes.py index 3659610c5..85381ba93 100644 --- a/tests/v1_0/fakes.py +++ b/tests/v1_0/fakes.py @@ -10,7 +10,7 @@ from tests import fakes class FakeClient(fakes.FakeClient, client.Client): def __init__(self, *args, **kwargs): - client.Client.__init__(self, 'username', 'apikey', + client.Client.__init__(self, 'username', 'password', 'project_id', 'auth_url') self.client = FakeHTTPClient(**kwargs) diff --git a/tests/v1_0/test_auth.py b/tests/v1_0/test_auth.py index 3f103fb9a..474bcbaff 100644 --- a/tests/v1_0/test_auth.py +++ b/tests/v1_0/test_auth.py @@ -9,7 +9,7 @@ from tests import utils class AuthenticationTests(utils.TestCase): def test_authenticate_success(self): - cs = client.Client("username", "apikey", "project_id") + cs = client.Client("username", "password", "project_id") management_url = 'https://servers.api.rackspacecloud.com/v1.0/443470' auth_response = httplib2.Response({ 'status': 204, @@ -23,7 +23,7 @@ class AuthenticationTests(utils.TestCase): cs.client.authenticate() headers = { 'X-Auth-User': 'username', - 'X-Auth-Key': 'apikey', + 'X-Auth-Key': 'password', 'X-Auth-Project-Id': 'project_id', 'User-Agent': cs.client.USER_AGENT } @@ -37,7 +37,7 @@ class AuthenticationTests(utils.TestCase): test_auth_call() def test_authenticate_failure(self): - cs = client.Client("username", "apikey", "project_id") + cs = client.Client("username", "password", "project_id") auth_response = httplib2.Response({'status': 401}) mock_request = mock.Mock(return_value=(auth_response, None)) @@ -48,7 +48,7 @@ class AuthenticationTests(utils.TestCase): test_auth_call() def test_auth_automatic(self): - cs = client.Client("username", "apikey", "project_id") + cs = client.Client("username", "password", "project_id") http_client = cs.client http_client.management_url = '' mock_request = mock.Mock(return_value=(None, None)) @@ -63,7 +63,7 @@ class AuthenticationTests(utils.TestCase): test_auth_call() def test_auth_manual(self): - cs = client.Client("username", "apikey", "project_id") + cs = client.Client("username", "password", "project_id") @mock.patch.object(cs.client, 'authenticate') def test_auth_call(m):