1079a7
From 3baae8d1bd0a0c4c707314524289e86e6ecbc0df Mon Sep 17 00:00:00 2001
1079a7
From: Alexander Bokovoy <abokovoy@redhat.com>
1079a7
Date: Mon, 14 Mar 2022 21:09:36 +0200
1079a7
Subject: [PATCH] test_otp: do not use paramiko unless it is really needed
1079a7
1079a7
paramiko cannot be used in FIPS mode. We have few tests that import
1079a7
generic methods from test_otp (add_token/del_token) and those tests fail
1079a7
in FIPS mode due to unconditional 'import paramiko'.
1079a7
1079a7
Instead, move 'import paramiko' to the ssh_2f() helper which is not used
1079a7
in FIPS mode (the whole SSH 2FA test is skipped then).
1079a7
1079a7
Related: https://pagure.io/freeipa/issue/9119
1079a7
1079a7
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
1079a7
Reviewed-By: Francisco Trivino <ftrivino@redhat.com>
1079a7
---
1079a7
 ipatests/test_integration/test_otp.py | 3 ++-
1079a7
 1 file changed, 2 insertions(+), 1 deletion(-)
1079a7
1079a7
diff --git a/ipatests/test_integration/test_otp.py b/ipatests/test_integration/test_otp.py
1079a7
index bec76d205bf37699483b65ebbc5613cbbb466bb4..04bef4626077e727654898b07a76acab4f1d5971 100644
1079a7
--- a/ipatests/test_integration/test_otp.py
1079a7
+++ b/ipatests/test_integration/test_otp.py
1079a7
@@ -5,7 +5,6 @@
1079a7
 """
1079a7
 import base64
1079a7
 import logging
1079a7
-import paramiko
1079a7
 import pytest
1079a7
 import re
1079a7
 import time
1079a7
@@ -102,6 +101,8 @@ def ssh_2f(hostname, username, answers_dict, port=22):
1079a7
             logger.info(
1079a7
                 "Answer to ssh prompt is: '%s'", answers_dict[prmpt_str])
1079a7
         return resp
1079a7
+
1079a7
+    import paramiko
1079a7
     trans = paramiko.Transport((hostname, port))
1079a7
     trans.connect()
1079a7
     trans.auth_interactive(username, answer_handler)
1079a7
-- 
1079a7
2.34.1
1079a7