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