diff options
| author | Jan Cholasta <jcholast@redhat.com> | 2016-04-13 15:50:57 +0200 |
|---|---|---|
| committer | Jan Cholasta <jcholast@redhat.com> | 2016-05-25 16:06:26 +0200 |
| commit | 4a243536b3200caff80f9f8317892e3b38888edf (patch) | |
| tree | e4ea0de7469ff61c8a022354a21666732c18b10d /ipalib/plugins | |
| parent | be471699b637526ab613eabfe97ce2c4a55f0529 (diff) | |
| download | freeipa-4a243536b3200caff80f9f8317892e3b38888edf.tar.gz freeipa-4a243536b3200caff80f9f8317892e3b38888edf.tar.xz freeipa-4a243536b3200caff80f9f8317892e3b38888edf.zip | |
otptoken_yubikey: fix otptoken_add_yubikey arguments
Copy args, options and output of otptoken_add_yubikey from otptoken_add.
https://fedorahosted.org/freeipa/ticket/4739
Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipalib/plugins')
| -rw-r--r-- | ipalib/plugins/otptoken_yubikey.py | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/ipalib/plugins/otptoken_yubikey.py b/ipalib/plugins/otptoken_yubikey.py index 0cbda1b2e..207d0a6e9 100644 --- a/ipalib/plugins/otptoken_yubikey.py +++ b/ipalib/plugins/otptoken_yubikey.py @@ -17,17 +17,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from ipalib import _, Str, IntEnum -from ipalib.errors import NotFound -from ipalib.plugable import Registry -from ipalib.frontend import Command -from ipalib.plugins.otptoken import otptoken - import os +import six import usb.core import yubico -import six + +from ipalib import _, IntEnum +from ipalib.errors import NotFound +from ipalib.frontend import Command +from ipalib.plugable import Registry if six.PY3: unicode = str @@ -55,35 +54,40 @@ topic = ('otp', _('One time password commands')) class otptoken_add_yubikey(Command): __doc__ = _('Add a new YubiKey OTP token.') - takes_args = ( - Str('ipatokenuniqueid?', - cli_name='id', - label=_('Unique ID'), - primary_key=True, - ), - ) - - takes_options = Command.takes_options + ( + takes_options = ( IntEnum('slot?', cli_name='slot', label=_('YubiKey slot'), values=(1, 2), ), - ) + tuple(x for x in otptoken.takes_params if x.name in ( - 'description', - 'ipatokenowner', - 'ipatokendisabled', - 'ipatokennotbefore', - 'ipatokennotafter', - 'ipatokenotpdigits' - )) - - has_output_params = Command.has_output_params + \ - tuple(x for x in otptoken.takes_params if x.name in ( - 'ipatokenvendor', - 'ipatokenmodel', - 'ipatokenserial', - )) + ) + + def get_args(self): + for arg in self.api.Command.otptoken_add.args(): + yield arg + for arg in super(otptoken_add_yubikey, self).get_args(): + yield arg + + def get_options(self): + for option in self.api.Command.otptoken_add.options(): + if option.name not in ('type', + 'ipatokenvendor', + 'ipatokenmodel', + 'ipatokenserial', + 'ipatokenotpalgorithm', + 'ipatokenhotpcounter', + 'ipatokenotpkey', + 'ipatokentotpclockoffset', + 'ipatokentotptimestep', + 'no_qrcode', + 'qrcode', + 'version'): + yield option + for option in super(otptoken_add_yubikey, self).get_options(): + yield option + + def _iter_output(self): + return self.api.Command.otptoken_add.output() def forward(self, *args, **kwargs): # Open the YubiKey @@ -145,6 +149,4 @@ class otptoken_add_yubikey(Command): # Return which slot was used for writing. answer.get('result', {})['slot'] = kwargs['slot'] - del answer['value'] # Why does this cause an error if omitted? - del answer['summary'] # Why does this cause an error if omitted? return answer |
