Skip to content

Commit

Permalink
authentication: add no pin for passkey
Browse files Browse the repository at this point in the history
Signed-off-by: Madhuri Upadhye <[email protected]>
  • Loading branch information
madhuriupadhye committed Jul 8, 2024
1 parent 153acbc commit 0bdd6ea
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions sssd_test_framework/utils/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def password_expired(self, username: str, password: str, new_password: str) -> b
return result.rc == 0

def passkey_with_output(
self, username: str, *, pin: str | int, device: str, ioctl: str, script: str, command: str = "exit 0"
self, username: str, *, device: str, ioctl: str, script: str, pin: str | int | None = None, command: str = "exit 0"
) -> tuple[int, int, str, str]:
"""
Call ``su - $username`` and authenticate the user with passkey.
Expand Down Expand Up @@ -422,6 +422,7 @@ def passkey_with_output(
set timeout {DEFAULT_AUTHENTICATION_TIMEOUT}
set prompt "\n.*\[#\$>\] $"
set command "{command}"
set pin "{pin}"
spawn "{playback_umockdev}"
Expand All @@ -430,11 +431,14 @@ def passkey_with_output(
timeout {{exitmsg "Unexpected output" 201}}
eof {{exitmsg "Unexpected end of file" 202}}
}}
expect {{
"Enter PIN:*" {{send -- "{pin}\r"}}
timeout {{exitmsg "Unexpected output" 201}}
eof {{exitmsg "Unexpected end of file" 202}}
if {{$pin eq "" }} {{
expect {{
"Enter PIN:*" {{send -- "{pin}\r"}}
timeout {{exitmsg "Unexpected output" 201}}
eof {{exitmsg "Unexpected end of file" 202}}
}}
eof {{exitmsg "Password authentication successful without PIN" 0}}
}}
expect {{
Expand Down Expand Up @@ -465,7 +469,7 @@ def passkey_with_output(
return result.rc, cmdrc, stdout, result.stderr

def passkey(
self, username: str, *, pin: str | int, device: str, ioctl: str, script: str, command: str = "exit 0"
self, username: str, *, pin: str | int = "exit 0", device: str, ioctl: str, script: str, command: str = "exit 0"
) -> bool:
"""
Call ``su - $username`` and authenticate the user with passkey.
Expand Down

0 comments on commit 0bdd6ea

Please sign in to comment.