403b09
From c7b4c108ddd76d5ac02e2242a7eccb3acf3efce5 Mon Sep 17 00:00:00 2001
403b09
From: Jan Cholasta <jcholast@redhat.com>
403b09
Date: Mon, 8 Aug 2016 13:09:39 +0200
403b09
Subject: [PATCH] parameters: move the `confirm` kwarg to Param
403b09
403b09
Whether a parameter is treated like password is determined by the
403b09
`password` class attribute defined in the Param class. Whether the CLI will
403b09
asks for confirmation of a password parameter depends on the value of the
403b09
`confirm` kwarg of the Password class.
403b09
403b09
Move the `confirm` kwarg from the Password class to the Param class, so
403b09
that it can be used by any Param subclass which has the `password` class
403b09
attribute set to True.
403b09
403b09
This fixes confirmation of the --key option of otptoken-add, which is a
403b09
Bytes subclass with `password` set to True.
403b09
403b09
https://fedorahosted.org/freeipa/ticket/6174
403b09
403b09
Reviewed-By: Martin Basti <mbasti@redhat.com>
403b09
Reviewed-By: David Kupka <dkupka@redhat.com>
403b09
---
403b09
 ipaclient/remote_plugins/schema.py | 2 +-
403b09
 ipalib/parameters.py               | 6 ++----
403b09
 ipaserver/plugins/otptoken.py      | 4 ----
403b09
 3 files changed, 3 insertions(+), 9 deletions(-)
403b09
403b09
diff --git a/ipaclient/remote_plugins/schema.py b/ipaclient/remote_plugins/schema.py
403b09
index cd1d5d607978899254325f634ccec91d2c92f59b..0301e54127dc236ebc14e1409484626f1427800d 100644
403b09
--- a/ipaclient/remote_plugins/schema.py
403b09
+++ b/ipaclient/remote_plugins/schema.py
403b09
@@ -155,7 +155,7 @@ class _SchemaPlugin(object):
403b09
             elif key in ('cli_metavar',
403b09
                          'cli_name'):
403b09
                 kwargs[key] = str(value)
403b09
-            elif key == 'confirm' and issubclass(cls, Password):
403b09
+            elif key == 'confirm':
403b09
                 kwargs[key] = value
403b09
             elif key == 'default':
403b09
                 default = value
403b09
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
403b09
index 1581b7dcac5259e5c4a127e2a38e13335002b204..6917c8d4fc117b47bddc11fbf3ea379e3c537ea4 100644
403b09
--- a/ipalib/parameters.py
403b09
+++ b/ipalib/parameters.py
403b09
@@ -377,6 +377,7 @@ class Param(ReadOnly):
403b09
         parameter is not `required`
403b09
       - sortorder: used to sort a list of parameters for Command. See
403b09
         `Command.finalize()` for further information
403b09
+      - confirm: if password, ask for confirmation
403b09
     """
403b09
 
403b09
     # This is a dummy type so that most of the functionality of Param can be
403b09
@@ -418,6 +419,7 @@ class Param(ReadOnly):
403b09
         ('cli_metavar', str, None),
403b09
         ('no_convert', bool, False),
403b09
         ('deprecated', bool, False),
403b09
+        ('confirm', bool, True),
403b09
 
403b09
         # The 'default' kwarg gets appended in Param.__init__():
403b09
         # ('default', self.type, None),
403b09
@@ -1511,10 +1513,6 @@ class Password(Str):
403b09
 
403b09
     password = True
403b09
 
403b09
-    kwargs = Str.kwargs + (
403b09
-        ('confirm', bool, True),
403b09
-    )
403b09
-
403b09
     def _convert_scalar(self, value, index=None):
403b09
         if isinstance(value, (tuple, list)) and len(value) == 2:
403b09
             (p1, p2) = value
403b09
diff --git a/ipaserver/plugins/otptoken.py b/ipaserver/plugins/otptoken.py
403b09
index 56b8c911b3492de9342946cd3e47681e99a5abef..39012e2f9106c33c520e19f14331fc440333015a 100644
403b09
--- a/ipaserver/plugins/otptoken.py
403b09
+++ b/ipaserver/plugins/otptoken.py
403b09
@@ -79,10 +79,6 @@ class OTPTokenKey(Bytes):
403b09
 
403b09
     password = True
403b09
 
403b09
-    kwargs = Bytes.kwargs + (
403b09
-        ('confirm', bool, True),
403b09
-    )
403b09
-
403b09
     def _convert_scalar(self, value, index=None):
403b09
         if isinstance(value, (tuple, list)) and len(value) == 2:
403b09
             (p1, p2) = value
403b09
-- 
403b09
2.7.4
403b09