From 938eb92d21ed8610e83ca606fcfd5ef153a6cda0 Mon Sep 17 00:00:00 2001 From: Kamil Sambor Date: Tue, 29 Jul 2014 17:29:35 +0200 Subject: [PATCH] Added validation of new password during changing in fuel-cli Change-Id: I26f1a94d9137b246d248299b4842038ae293b43a Closes-Bug: #1349734 --- fuelclient/cli/actions/user.py | 7 ++++++- tests/test_client.py | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/fuelclient/cli/actions/user.py b/fuelclient/cli/actions/user.py index 3b8ee9a..0e9bc7d 100644 --- a/fuelclient/cli/actions/user.py +++ b/fuelclient/cli/actions/user.py @@ -14,6 +14,7 @@ from fuelclient.cli.actions.base import Action import fuelclient.cli.arguments as Args +from fuelclient.cli.error import ArgumentException from fuelclient.client import APIClient @@ -37,4 +38,8 @@ class UserAction(Action): """To change user password: fuel user change-password """ - APIClient.update_own_password(params.newpass) + if params.newpass: + APIClient.update_own_password(params.newpass) + else: + raise ArgumentException( + "Expect password [--newpass NEWPASS]") diff --git a/tests/test_client.py b/tests/test_client.py index 305acfd..26dd7ff 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -128,6 +128,15 @@ class TestHandlers(BaseTestCase): ) +class TestUserActions(BaseTestCase): + + def test_change_password_params(self): + cmd = "user --change-password" + msg = "Expect password [--newpass NEWPASS]" + result = self.run_cli_command(cmd, check_errors=True) + self.assertTrue(msg, result) + + class TestCharset(BaseTestCase): def test_charset_problem(self):