Mercurial > crates > nonstick
changeset 167:0cabe7b94a4f
Check for old_authtok in change_authtok to emulate real behavior.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Tue, 15 Jul 2025 00:39:08 -0400 |
parents | 2f5913131295 |
children | 6642e89d29a2 |
files | testharness/src/bin/testharness.rs testharness/src/lib.rs |
diffstat | 2 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/testharness/src/bin/testharness.rs Tue Jul 15 00:32:24 2025 -0400 +++ b/testharness/src/bin/testharness.rs Tue Jul 15 00:39:08 2025 -0400 @@ -43,12 +43,16 @@ Exchange::MaskedPrompt(p) => { let answer = if self.changing_password.get() { let prompts = self.change_prompt_count.get(); + eprintln!("CHANGING PASSWORD PROMPT {prompts}"); + eprintln!("-> {p:?}"); self.change_prompt_count.set(prompts + 1); match prompts { - 0 => "mistake", - 1 => "mismatch", - 2 => "acceptable", - 3 => "acceptable", + 0 => "old token!", + 1 => "mistake", + 2 => "mismatch", + 3 => "old token!", + 4 => "acceptable", + 5 => "acceptable", _ => panic!("unexpected number of prompts!"), } } else if self.wrong_password {
--- a/testharness/src/lib.rs Tue Jul 15 00:32:24 2025 -0400 +++ b/testharness/src/lib.rs Tue Jul 15 00:39:08 2025 -0400 @@ -88,6 +88,9 @@ ) -> nonstick::Result<()> { match action { AuthtokAction::PreliminaryCheck => { + if handle.old_authtok(None)?.as_bytes() != b"old token!" { + return Err(ErrorCode::AuthenticationError); + } let password = handle.authtok(None)?; if password.as_bytes() != b"acceptable" { return Err(ErrorCode::PermissionDenied);