From c34310cc1f59e7de42c57fd38f75b0818f7739a3 Mon Sep 17 00:00:00 2001 From: Yuuichi Fujioka Date: Tue, 17 Sep 2013 16:04:33 +0900 Subject: [PATCH] Allow blank to email in user-update User cannot set blank to email address when use "user-update". This patch fixes this problem. Change-Id: I3b9494a1c668358a529031c366c55b303f43c533 Closes-bug: #1226439 --- keystoneclient/v2_0/shell.py | 2 +- tests/v2_0/test_shell.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/keystoneclient/v2_0/shell.py b/keystoneclient/v2_0/shell.py index a580a7217..2e6ca8243 100644 --- a/keystoneclient/v2_0/shell.py +++ b/keystoneclient/v2_0/shell.py @@ -102,7 +102,7 @@ def do_user_update(kc, args): kwargs = {} if args.name: kwargs['name'] = args.name - if args.email: + if args.email is not None: kwargs['email'] = args.email if args.enabled: kwargs['enabled'] = utils.string_to_bool(args.enabled) diff --git a/tests/v2_0/test_shell.py b/tests/v2_0/test_shell.py index 847265e91..b3a05d371 100644 --- a/tests/v2_0/test_shell.py +++ b/tests/v2_0/test_shell.py @@ -71,7 +71,10 @@ class ShellTests(utils.TestCase): orig = sys.stdout try: sys.stdout = cStringIO.StringIO() - self.shell.main(cmd.split()) + if isinstance(cmd, list): + self.shell.main(cmd) + else: + self.shell.main(cmd.split()) except SystemExit: exc_type, exc_value, exc_traceback = sys.exc_info() self.assertEqual(exc_value.code, 0) @@ -130,6 +133,14 @@ class ShellTests(utils.TestCase): out = self.run_command('user-update 1') self.assertThat(out, matchers.MatchesRegex(required)) + self.run_command(['user-update', '--email', '', '1']) + self.fake_client.assert_called_anytime( + 'PUT', '/users/1', + {'user': + {'id': '1', + 'email': ''} + }) + def test_role_create(self): self.run_command('role-create --name new-role') self.fake_client.assert_called_anytime(