Test error when yubikey hardware not present

In order to work with IPA and Yubikey, libyubikey is required.
Before the fix, if yubikey added without having packages, it used to
result in traceback. Now it the exception is handeled properly.
It needs Yubikey hardware to make command successfull. This test
just check of proper error thrown when hardware is not attached.

related ticket : https://pagure.io/freeipa/issue/6979

Signed-off-by: Mohammad Rizwan Yusuf <myusuf@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Mohammad Rizwan Yusuf 2018-08-30 16:07:33 +05:30 committed by Tibor Dudlák
parent 07e6d5148e
commit e7581cc0d8
No known key found for this signature in database
GPG Key ID: 12B8BD343576CDF5

View File

@ -410,6 +410,24 @@ class TestInstallMaster(IntegrationTest):
wsgi_count = cmd.stdout_text.count('wsgi:ipa')
assert constants.WSGI_PROCESSES == wsgi_count
def test_error_for_yubikey(self):
""" Test error when yubikey hardware not present
In order to work with IPA and Yubikey, libyubikey is required.
Before the fix, if yubikey added without having packages, it used to
result in traceback. Now it the exception is handeled properly.
It needs Yubikey hardware to make command successfull. This test
just check of proper error thrown when hardware is not attached.
related ticket : https://pagure.io/freeipa/issue/6979
"""
# try to add yubikey to the user
args = ['ipa', 'otptoken-add-yubikey', '--owner=admin']
cmd = self.master.run_command(args, raiseonerr=False)
assert cmd.returncode != 0
exp_str = ("ipa: ERROR: No YubiKey found")
assert exp_str in cmd.stderr_text
class TestInstallMasterKRA(IntegrationTest):