mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 12:37:00 +01:00
Add clean ups based on review feedback (#351)
* Add clean ups based on charcols suggestions
This commit is contained in:
parent
8006142c9e
commit
a3d7401d03
|
@ -765,20 +765,19 @@ fn test_server_rest_totp_auth_lifecycle() {
|
|||
.auth_password_totp("demo_account", "sohdi3iuHo6mai7noh0a", totp)
|
||||
.is_ok());
|
||||
|
||||
// Check a bad auth - needs to be second to prevent slocking
|
||||
// Check a bad auth - needs to be second as we are going to trigger the slock.
|
||||
// Get a new connection
|
||||
let mut rsclient_bad = rsclient.new_session().unwrap();
|
||||
assert!(rsclient_bad
|
||||
.auth_password_totp("demo_account", "sohdi3iuHo6mai7noh0a", 0)
|
||||
.is_err());
|
||||
// Delay by one second to allow the account to recover from the softlock.
|
||||
std::thread::sleep(std::time::Duration::from_millis(1100));
|
||||
|
||||
// Remove TOTP on the account.
|
||||
rsclient
|
||||
.idm_account_primary_credential_remove_totp("demo_account")
|
||||
.unwrap(); // the result
|
||||
// Delay by one second to allow the account to recover from the
|
||||
// softlock.
|
||||
std::thread::sleep(std::time::Duration::from_millis(1100));
|
||||
.unwrap();
|
||||
// Check password auth.
|
||||
let mut rsclient_good = rsclient.new_session().unwrap();
|
||||
assert!(rsclient_good
|
||||
|
|
|
@ -307,8 +307,8 @@ impl AccountOpt {
|
|||
}
|
||||
};
|
||||
|
||||
// display the tok.
|
||||
eprintln!("You should scan the follow QR code with your OTP App.");
|
||||
// display the token.
|
||||
eprintln!("Scan the following QR code with your OTP app.");
|
||||
|
||||
let code = match QrCode::new(tok.to_uri().as_str()) {
|
||||
Ok(c) => c,
|
||||
|
@ -324,7 +324,7 @@ impl AccountOpt {
|
|||
.build();
|
||||
eprintln!("{}", image);
|
||||
|
||||
eprintln!("Alternately, you can manually enter the following OTP details:");
|
||||
eprintln!("Alternatively, you can manually enter the following OTP details:");
|
||||
println!("Account Name: {}", tok.accountname);
|
||||
println!("Issuer: {}", tok.issuer);
|
||||
println!("Algorithm: {}", tok.algo.to_string());
|
||||
|
|
|
@ -139,7 +139,13 @@ impl LoginOpt {
|
|||
error!("Error during authentication init phase: Server offered no authentication mechanisms");
|
||||
std::process::exit(1);
|
||||
}
|
||||
1 => unsafe { mechs.get_unchecked(0) },
|
||||
1 =>
|
||||
{
|
||||
#[allow(clippy::expect_used)]
|
||||
mechs
|
||||
.get(0)
|
||||
.expect("can not fail - bounds already checked.")
|
||||
}
|
||||
len => {
|
||||
println!("Please choose how you want to authenticate:");
|
||||
for (i, val) in mechs.iter().enumerate() {
|
||||
|
@ -152,7 +158,10 @@ impl LoginOpt {
|
|||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
unsafe { mechs.get_unchecked(mech_idx as usize) }
|
||||
#[allow(clippy::expect_used)]
|
||||
mechs
|
||||
.get(mech_idx as usize)
|
||||
.expect("can not fail - bounds already checked.")
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -175,7 +184,13 @@ impl LoginOpt {
|
|||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
1 => unsafe { allowed.get_unchecked(0) },
|
||||
1 =>
|
||||
{
|
||||
#[allow(clippy::expect_used)]
|
||||
allowed
|
||||
.get(0)
|
||||
.expect("can not fail - bounds already checked.")
|
||||
}
|
||||
len => {
|
||||
println!("Please choose what credential to provide:");
|
||||
for (i, val) in allowed.iter().enumerate() {
|
||||
|
@ -188,7 +203,10 @@ impl LoginOpt {
|
|||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
unsafe { allowed.get_unchecked(idx as usize) }
|
||||
#[allow(clippy::expect_used)]
|
||||
allowed
|
||||
.get(idx as usize)
|
||||
.expect("can not fail - bounds already checked.")
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ impl Account {
|
|||
Ok(ModifyList::new_purge_and_set("primary_credential", vcred))
|
||||
}
|
||||
None => {
|
||||
// No credential exists, we can't supplementy it.
|
||||
// No credential exists, we can't remove what is not real.
|
||||
Err(OperationError::InvalidState)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue