diff --git a/heatclient/shell.py b/heatclient/shell.py index 3aa0e1a1..2793ad51 100644 --- a/heatclient/shell.py +++ b/heatclient/shell.py @@ -282,9 +282,12 @@ class HeatShell(object): raise exc.CommandError("You must provide a username via" " either --os-username or env[OS_USERNAME]") - if not args.os_password: - raise exc.CommandError("You must provide a password via" - " either --os-password or env[OS_PASSWORD]") + if not args.os_password and not args.os_auth_token: + raise exc.CommandError("You must provide a password or auth token." + " To provide password use --os-password or " + "env[OS_PASSWORD]. To provide auth token " + "use --os-auth-token or " + "env[OS_AUTH_TOKEN]") if not (args.os_tenant_id or args.os_tenant_name): raise exc.CommandError("You must provide a tenant_id via" diff --git a/heatclient/tests/test_shell.py b/heatclient/tests/test_shell.py index 6737237c..25c27a54 100644 --- a/heatclient/tests/test_shell.py +++ b/heatclient/tests/test_shell.py @@ -154,6 +154,22 @@ class ShellParamValidationTest(TestCase): cmd = '%s --template-file=%s ' % (self.command, template_file) self.shell_error(cmd, self.err) + def test_no_token_no_password(self): + self.m.StubOutWithMock(ksclient, 'Client') + self.m.StubOutWithMock(v1client.Client, 'json_request') + + self.m.ReplayAll() + fake_env = { + 'OS_USERNAME': 'username', + 'OS_TENANT_NAME': 'tenant_name', + 'OS_AUTH_URL': 'http://no.where', + } + self.set_fake_env(fake_env) + template_file = os.path.join(TEST_VAR_DIR, 'minimal.template') + cmd = '%s --template-file=%s ' % (self.command, template_file) + err = 'You must provide a password or auth token.' + self.shell_error(cmd, err) + class ShellValidationTest(TestCase):