Skip to content

Commit 52bb905

Browse files
committed
ipa role update for vfido add register
vfido_passkey_add_register was failing occasionally due to some flakiness in the virtual fido emulation. Adding a retry loop to the function to make it more resilient.
1 parent 6025037 commit 52bb905

File tree

1 file changed

+44
-34
lines changed
  • sssd_test_framework/roles

1 file changed

+44
-34
lines changed

sssd_test_framework/roles/ipa.py

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import re
77
import shlex
8+
import time
89
import uuid
910
from itertools import groupby
1011
from textwrap import dedent
@@ -1129,46 +1130,55 @@ def vfido_passkey_add_register(
11291130

11301131
client.host.conn.exec(["kinit", f"{self.host.adminuser}@{self.host.realm}"], input=self.host.adminpw)
11311132

1132-
result = client.host.conn.expect(
1133-
f"""
1134-
set pin "{pin}"
1135-
set timeout 60
1136-
1137-
spawn ipa user-add-passkey {self.name} --register
1138-
set ID_reg $spawn_id
1133+
def run_expect():
1134+
return client.host.conn.expect(
1135+
f"""
1136+
set pin "{pin}"
1137+
set timeout 60
1138+
spawn ipa user-add-passkey {self.name} --register
1139+
set ID_reg $spawn_id
1140+
1141+
if {{ ($pin ne "empty") }} {{
1142+
expect {{
1143+
-i $ID_reg -re "Enter PIN:*" {{}}
1144+
-i $ID_reg timeout {{puts "expect result: Unexpected output"; exit 201}}
1145+
-i $ID_reg eof {{puts "expect result: Unexpected end of file"; exit 202}}
1146+
}}
1147+
1148+
puts "Entering PIN\n"
1149+
send -i $ID_reg "{pin}\r"
1150+
}}
11391151
1140-
if {{ ($pin ne "empty") }} {{
11411152
expect {{
1142-
-i $ID_reg -re "Enter PIN:*" {{}}
1143-
-i $ID_reg timeout {{puts "expect result: Unexpected output"; exit 201}}
1144-
-i $ID_reg eof {{puts "expect result: Unexpected end of file"; exit 202}}
1153+
-i $ID_reg -re "Please touch the device.*" {{}}
1154+
-i $ID_reg timeout {{puts "expect result: Unexpected output"; exit 203}}
1155+
-i $ID_reg eof {{puts "expect result: Unexpected end of file"; exit 204}}
11451156
}}
11461157
1147-
puts "Entering PIN\n"
1148-
send -i $ID_reg "{pin}\r"
1149-
}}
1150-
1151-
expect {{
1152-
-i $ID_reg -re "Please touch the device.*" {{}}
1153-
-i $ID_reg timeout {{puts "expect result: Unexpected output"; exit 203}}
1154-
-i $ID_reg eof {{puts "expect result: Unexpected end of file"; exit 204}}
1155-
}}
1156-
1157-
puts "Touching device"
1158-
spawn {test_venv_bin}/vfido_touch
1159-
set ID_touch $spawn_id
1158+
puts "Touching device"
1159+
spawn {test_venv_bin}/vfido_touch
1160+
set ID_touch $spawn_id
1161+
expect {{
1162+
-i $ID_reg -re "Added passkey mappings.*" {{}}
1163+
-i $ID_reg timeout {{puts "expect result: Unexpected output"; exit 205}}
1164+
-i $ID_reg eof {{puts "expect result: Unexpected end of file"; exit 206}}
1165+
}}
11601166
1161-
expect {{
1162-
-i $ID_reg -re "Added passkey mappings.*" {{}}
1163-
-i $ID_reg timeout {{puts "expect result: Unexpected output"; exit 205}}
1164-
-i $ID_reg eof {{puts "expect result: Unexpected end of file"; exit 206}}
1165-
}}
1167+
expect -i $ID_reg eof
1168+
expect -i $ID_touch eof
1169+
""",
1170+
raise_on_error=False,
1171+
)
11661172

1167-
expect -i $ID_reg eof
1168-
expect -i $ID_touch eof
1169-
""",
1170-
raise_on_error=True,
1171-
)
1173+
retry = 0
1174+
max_retries = 5
1175+
result = run_expect()
1176+
while result.rc != 0:
1177+
if retry == max_retries:
1178+
raise AssertionError("Unable to register passkey for IPA user")
1179+
result = run_expect()
1180+
retry += 1
1181+
time.sleep(1)
11721182

11731183
return result.stdout_lines[-1].strip()
11741184

0 commit comments

Comments
 (0)