b3b562
From bd555a05d0598b3ab65a50bcff431c2e00652b87 Mon Sep 17 00:00:00 2001
b3b562
From: Florence Blanc-Renaud <flo@redhat.com>
b3b562
Date: Thu, 29 Sep 2022 16:10:10 +0200
b3b562
Subject: [PATCH] ipatests: python2 does not support f-strings
b3b562
b3b562
Adapt the code in ipatests/test_integration/test_otp.py to python2
b3b562
b3b562
Related: https://pagure.io/freeipa/issue/9248
b3b562
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
b3b562
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
b3b562
---
b3b562
 ipatests/test_integration/test_otp.py | 16 ++++++++++------
b3b562
 1 file changed, 10 insertions(+), 6 deletions(-)
b3b562
b3b562
diff --git a/ipatests/test_integration/test_otp.py b/ipatests/test_integration/test_otp.py
b3b562
index 32b41b79ad8bf44a298b28c259351d5a71a7e9ea..1df4d46a2551835ceb8fea8c70255afcb95b54f3 100644
b3b562
--- a/ipatests/test_integration/test_otp.py
b3b562
+++ b/ipatests/test_integration/test_otp.py
b3b562
@@ -30,6 +30,7 @@ except ImportError:
b3b562
 PASSWORD = "DummyPassword123"
b3b562
 USER = "opttestuser"
b3b562
 ARMOR = "/tmp/armor"
b3b562
+OTP_SYNC_INPUT="{}\n{}\n{}\n"
b3b562
 logger = logging.getLogger(__name__)
b3b562
 
b3b562
 
b3b562
@@ -208,7 +209,8 @@ class TestOTPToken(IntegrationTest):
b3b562
         # Try to sync with a wrong password
b3b562
         result = self.master.run_command(
b3b562
             ["ipa", "otptoken-sync", "--user", USER, otpuid],
b3b562
-            stdin_text=f"invalidpwd\n{otp2}\n{otp3}\n", raiseonerr=False
b3b562
+            stdin_text=OTP_SYNC_INPUT.format("invalidpwd", otp2, otp3),
b3b562
+            raiseonerr=False
b3b562
         )
b3b562
         assert result.returncode == 1
b3b562
         assert "Invalid Credentials!" in result.stderr_text
b3b562
@@ -216,7 +218,7 @@ class TestOTPToken(IntegrationTest):
b3b562
         # Now sync with the right values
b3b562
         self.master.run_command(
b3b562
             ["ipa", "otptoken-sync", "--user", USER, otpuid],
b3b562
-            stdin_text=f"{PASSWORD}\n{otp2}\n{otp3}\n"
b3b562
+            stdin_text=OTP_SYNC_INPUT.format(PASSWORD, otp2, otp3)
b3b562
         )
b3b562
 
b3b562
     def test_otptoken_sync_incorrect_first_value(self, desynchronized_hotp):
b3b562
@@ -230,7 +232,8 @@ class TestOTPToken(IntegrationTest):
b3b562
         # Try to sync with a wrong first value (contains non-digit)
b3b562
         result = self.master.run_command(
b3b562
             ["ipa", "otptoken-sync", "--user", USER, otpuid],
b3b562
-            stdin_text=f"{PASSWORD}\n{otp2}\n{otp3}\n", raiseonerr=False
b3b562
+            stdin_text=OTP_SYNC_INPUT.format(PASSWORD, otp2, otp3),
b3b562
+            raiseonerr=False
b3b562
         )
b3b562
         assert result.returncode == 1
b3b562
         assert "Invalid Credentials!" in result.stderr_text
b3b562
@@ -238,7 +241,7 @@ class TestOTPToken(IntegrationTest):
b3b562
         # Now sync with the right values
b3b562
         self.master.run_command(
b3b562
             ["ipa", "otptoken-sync", "--user", USER, otpuid],
b3b562
-            stdin_text=f"{PASSWORD}\n{otp3}\n{otp4}\n"
b3b562
+            stdin_text=OTP_SYNC_INPUT.format(PASSWORD, otp3, otp4)
b3b562
         )
b3b562
 
b3b562
     def test_otptoken_sync_incorrect_second_value(self, desynchronized_hotp):
b3b562
@@ -250,7 +253,8 @@ class TestOTPToken(IntegrationTest):
b3b562
         # Try to sync with wrong order
b3b562
         result = self.master.run_command(
b3b562
             ["ipa", "otptoken-sync", "--user", USER, otpuid],
b3b562
-            stdin_text=f"{PASSWORD}\n{otp3}\n{otp2}\n", raiseonerr=False
b3b562
+            stdin_text=OTP_SYNC_INPUT.format(PASSWORD, otp3, otp2),
b3b562
+            raiseonerr=False
b3b562
         )
b3b562
         assert result.returncode == 1
b3b562
         assert "Invalid Credentials!" in result.stderr_text
b3b562
@@ -258,7 +262,7 @@ class TestOTPToken(IntegrationTest):
b3b562
         # Now sync with the right order
b3b562
         self.master.run_command(
b3b562
             ["ipa", "otptoken-sync", "--user", USER, otpuid],
b3b562
-            stdin_text=f"{PASSWORD}\n{otp2}\n{otp3}\n"
b3b562
+            stdin_text=OTP_SYNC_INPUT.format(PASSWORD, otp2, otp3)
b3b562
         )
b3b562
 
b3b562
     def test_totp(self):
b3b562
-- 
b3b562
2.37.3
b3b562