On 8.8.2016 13:26, Martin Basti wrote:
On 08.08.2016 13:27, Jan Cholasta wrote:
Hi,
the attached patch fixes <https://fedorahosted.org/freeipa/ticket/6174>.
Honza
Please document this change in Param dosctring
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -418,6 +418,7 @@ class Param(ReadOnly):
('cli_metavar', str, None),
('no_convert', bool, False),
('deprecated', bool, False),
+ ('confirm', bool, True),
Martin^2
--
Jan Cholasta
From 9b523cd87d9ce2b9bc0505d7762d02d913400c1c Mon Sep 17 00:00:00 2001
From: Jan Cholasta <[email protected]>
Date: Mon, 8 Aug 2016 13:09:39 +0200
Subject: [PATCH] parameters: move the `confirm` kwarg to Param
Whether a parameter is treated like password is determined by the
`password` class attribute defined in the Param class. Whether the CLI will
asks for confirmation of a password parameter depends on the value of the
`confirm` kwarg of the Password class.
Move the `confirm` kwarg from the Password class to the Param class, so
that it can be used by any Param subclass which has the `password` class
attribute set to True.
This fixes confirmation of the --key option of otptoken-add, which is a
Bytes subclass with `password` set to True.
https://fedorahosted.org/freeipa/ticket/6174
---
ipaclient/remote_plugins/schema.py | 2 +-
ipalib/parameters.py | 6 ++----
ipaserver/plugins/otptoken.py | 4 ----
3 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/ipaclient/remote_plugins/schema.py b/ipaclient/remote_plugins/schema.py
index a215452..c06d6d2 100644
--- a/ipaclient/remote_plugins/schema.py
+++ b/ipaclient/remote_plugins/schema.py
@@ -167,7 +167,7 @@ class _SchemaPlugin(object):
elif key in ('cli_metavar',
'cli_name'):
kwargs[key] = str(value)
- elif key == 'confirm' and issubclass(cls, Password):
+ elif key == 'confirm':
kwargs[key] = value
elif key == 'default':
default = value
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index 1581b7d..6917c8d 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -377,6 +377,7 @@ class Param(ReadOnly):
parameter is not `required`
- sortorder: used to sort a list of parameters for Command. See
`Command.finalize()` for further information
+ - confirm: if password, ask for confirmation
"""
# This is a dummy type so that most of the functionality of Param can be
@@ -418,6 +419,7 @@ class Param(ReadOnly):
('cli_metavar', str, None),
('no_convert', bool, False),
('deprecated', bool, False),
+ ('confirm', bool, True),
# The 'default' kwarg gets appended in Param.__init__():
# ('default', self.type, None),
@@ -1511,10 +1513,6 @@ class Password(Str):
password = True
- kwargs = Str.kwargs + (
- ('confirm', bool, True),
- )
-
def _convert_scalar(self, value, index=None):
if isinstance(value, (tuple, list)) and len(value) == 2:
(p1, p2) = value
diff --git a/ipaserver/plugins/otptoken.py b/ipaserver/plugins/otptoken.py
index 56b8c91..39012e2 100644
--- a/ipaserver/plugins/otptoken.py
+++ b/ipaserver/plugins/otptoken.py
@@ -79,10 +79,6 @@ class OTPTokenKey(Bytes):
password = True
- kwargs = Bytes.kwargs + (
- ('confirm', bool, True),
- )
-
def _convert_scalar(self, value, index=None):
if isinstance(value, (tuple, list)) and len(value) == 2:
(p1, p2) = value
--
2.7.4
--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code