|
5 | 5 | import os |
6 | 6 | import re |
7 | 7 | import shlex |
| 8 | +import time |
8 | 9 | import uuid |
9 | 10 | from itertools import groupby |
10 | 11 | from textwrap import dedent |
@@ -1129,46 +1130,54 @@ def vfido_passkey_add_register( |
1129 | 1130 |
|
1130 | 1131 | client.host.conn.exec(["kinit", f"{self.host.adminuser}@{self.host.realm}"], input=self.host.adminpw) |
1131 | 1132 |
|
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 | + }} |
1139 | 1151 |
|
1140 | | - if {{ ($pin ne "empty") }} {{ |
1141 | 1152 | 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}} |
1145 | 1156 | }} |
1146 | 1157 |
|
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 |
1160 | | -
|
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 | | - }} |
| 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 | + }} |
| 1166 | + expect -i $ID_reg eof |
| 1167 | + expect -i $ID_touch eof |
| 1168 | + """, |
| 1169 | + raise_on_error=False, |
| 1170 | + ) |
1166 | 1171 |
|
1167 | | - expect -i $ID_reg eof |
1168 | | - expect -i $ID_touch eof |
1169 | | - """, |
1170 | | - raise_on_error=True, |
1171 | | - ) |
| 1172 | + retry = 0 |
| 1173 | + max_retries = 5 |
| 1174 | + result = run_expect() |
| 1175 | + while result.rc != 0: |
| 1176 | + if retry == max_retries: |
| 1177 | + raise AssertionError("Unable to register passkey for IPA user") |
| 1178 | + result = run_expect() |
| 1179 | + retry += 1 |
| 1180 | + time.sleep(1) |
1172 | 1181 |
|
1173 | 1182 | return result.stdout_lines[-1].strip() |
1174 | 1183 |
|
|
0 commit comments