mirror of
https://github.com/lldap/lldap.git
synced 2026-07-25 17:58:44 +00:00
meta: Fix cargo clippy failures (format strings)
This commit is contained in:
committed by
nitnelave
parent
53e62ecf5a
commit
87e9311a44
@@ -199,8 +199,7 @@ where
|
||||
warn!("Error sending email: {:#?}", e);
|
||||
info!("Reset token: {}", token);
|
||||
return Err(TcpError::InternalServerError(format!(
|
||||
"Could not send email: {}",
|
||||
e
|
||||
"Could not send email: {e}"
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
@@ -254,7 +253,7 @@ where
|
||||
Cookie::build("token", token.as_str())
|
||||
.max_age(5.minutes())
|
||||
// Cookie is only valid to reset the password.
|
||||
.path(format!("{}auth", path))
|
||||
.path(format!("{path}auth"))
|
||||
.http_only(true)
|
||||
.same_site(SameSite::Strict)
|
||||
.finish(),
|
||||
@@ -310,7 +309,7 @@ where
|
||||
.cookie(
|
||||
Cookie::build("refresh_token", "")
|
||||
.max_age(0.days())
|
||||
.path(format!("{}auth", path))
|
||||
.path(format!("{path}auth"))
|
||||
.http_only(true)
|
||||
.same_site(SameSite::Strict)
|
||||
.finish(),
|
||||
@@ -381,7 +380,7 @@ where
|
||||
.cookie(
|
||||
Cookie::build("refresh_token", refresh_token_plus_name.clone())
|
||||
.max_age(max_age.num_days().days())
|
||||
.path(format!("{}auth", path))
|
||||
.path(format!("{path}auth"))
|
||||
.http_only(true)
|
||||
.same_site(SameSite::Strict)
|
||||
.finish(),
|
||||
@@ -475,7 +474,7 @@ where
|
||||
inner_payload,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| TcpError::BadRequest(format!("{:#?}", e)))?
|
||||
.map_err(|e| TcpError::BadRequest(format!("{e:#?}")))?
|
||||
.into_inner();
|
||||
let user_id = ®istration_start_request.username;
|
||||
let user_is_admin = data
|
||||
|
||||
@@ -299,14 +299,14 @@ impl PrivateKeyLocationOrFigment {
|
||||
source: Some(figment::Source::Code(_)),
|
||||
..
|
||||
}) => PrivateKeyLocation::Default,
|
||||
other => panic!("Unexpected config location: {:?}", other),
|
||||
other => panic!("Unexpected config location: {other:?}"),
|
||||
}
|
||||
}
|
||||
PrivateKeyLocationOrFigment::PrivateKeyLocation(PrivateKeyLocation::KeyFile(
|
||||
config_location,
|
||||
_,
|
||||
)) => {
|
||||
panic!("Unexpected location: {:?}", config_location)
|
||||
panic!("Unexpected location: {config_location:?}")
|
||||
}
|
||||
PrivateKeyLocationOrFigment::PrivateKeyLocation(location) => location.clone(),
|
||||
}
|
||||
@@ -334,11 +334,11 @@ impl PrivateKeyLocationOrFigment {
|
||||
source: Some(figment::Source::Code(_)),
|
||||
..
|
||||
}) => PrivateKeyLocation::Default,
|
||||
other => panic!("Unexpected config location: {:?}", other),
|
||||
other => panic!("Unexpected config location: {other:?}"),
|
||||
}
|
||||
}
|
||||
PrivateKeyLocationOrFigment::PrivateKeyLocation(PrivateKeyLocation::KeySeed(file)) => {
|
||||
panic!("Unexpected location: {:?}", file)
|
||||
panic!("Unexpected location: {file:?}")
|
||||
}
|
||||
PrivateKeyLocationOrFigment::PrivateKeyLocation(location) => location.clone(),
|
||||
}
|
||||
@@ -373,19 +373,17 @@ fn get_server_setup<L: Into<PrivateKeyLocationOrFigment>>(
|
||||
private_key_location: private_key_location.for_key_seed(),
|
||||
})
|
||||
} else if path.exists() {
|
||||
let bytes = read(file_path).context(format!("Could not read key file `{}`", file_path))?;
|
||||
let bytes = read(file_path).context(format!("Could not read key file `{file_path}`"))?;
|
||||
Ok(ServerSetupConfig {
|
||||
server_setup: ServerSetup::deserialize(&bytes).context(format!(
|
||||
"while parsing the contents of the `{}` file",
|
||||
file_path
|
||||
"while parsing the contents of the `{file_path}` file"
|
||||
))?,
|
||||
private_key_location: private_key_location.for_key_file(file_path),
|
||||
})
|
||||
} else {
|
||||
let server_setup = generate_random_private_key();
|
||||
write_to_readonly_file(path, &server_setup.serialize()).context(format!(
|
||||
"Could not write the generated server setup to file `{}`",
|
||||
file_path,
|
||||
"Could not write the generated server setup to file `{file_path}`",
|
||||
))?;
|
||||
Ok(ServerSetupConfig {
|
||||
server_setup,
|
||||
@@ -596,7 +594,7 @@ where
|
||||
.iter()
|
||||
.filter(|k| !expected_keys.contains(k.as_str()))
|
||||
.for_each(|k| {
|
||||
eprintln!("WARNING: Unknown environment variable: LLDAP_{}", k);
|
||||
eprintln!("WARNING: Unknown environment variable: LLDAP_{k}");
|
||||
});
|
||||
}
|
||||
config.server_setup = Some(get_server_setup(
|
||||
|
||||
@@ -29,7 +29,7 @@ impl std::fmt::Debug for DatabaseUrl {
|
||||
let mut url = self.0.clone();
|
||||
// It can fail for URLs that cannot have a password, like "mailto:bob@example".
|
||||
let _ = url.set_password(Some("***PASSWORD***"));
|
||||
f.write_fmt(format_args!(r#""{}""#, url))
|
||||
f.write_fmt(format_args!(r#""{url}""#))
|
||||
} else {
|
||||
f.write_fmt(format_args!(r#""{}""#, self.0))
|
||||
}
|
||||
@@ -44,7 +44,7 @@ mod tests {
|
||||
fn test_database_url_debug() {
|
||||
let url = DatabaseUrl::from("postgres://user:pass@localhost:5432/dbname");
|
||||
assert_eq!(
|
||||
format!("{:?}", url),
|
||||
format!("{url:?}"),
|
||||
r#""postgres://user:***PASSWORD***@localhost:5432/dbname""#
|
||||
);
|
||||
assert_eq!(
|
||||
|
||||
@@ -71,7 +71,7 @@ where
|
||||
|
||||
#[instrument(level = "info", err)]
|
||||
pub async fn check_ldap(port: u16) -> Result<()> {
|
||||
check_ldap_endpoint(TcpStream::connect(format!("localhost:{}", port)).await?).await
|
||||
check_ldap_endpoint(TcpStream::connect(format!("localhost:{port}")).await?).await
|
||||
}
|
||||
|
||||
fn get_root_certificates() -> rustls::RootCertStore {
|
||||
@@ -152,7 +152,7 @@ pub async fn check_ldaps(ldaps_options: &LdapsOptions) -> Result<()> {
|
||||
|
||||
#[instrument(level = "info", err)]
|
||||
pub async fn check_api(port: u16) -> Result<()> {
|
||||
reqwest::get(format!("http://localhost:{}/health", port))
|
||||
reqwest::get(format!("http://localhost:{port}/health"))
|
||||
.await?
|
||||
.error_for_status()?;
|
||||
info!("Success");
|
||||
|
||||
@@ -132,10 +132,7 @@ fn read_private_key(key_file: &str) -> Result<PrivateKey> {
|
||||
.and_then(|keys| keys.into_iter().next().ok_or_else(|| anyhow!("No EC key")))
|
||||
})
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Cannot read either PKCS1, PKCS8 or EC private key from {}",
|
||||
key_file
|
||||
)
|
||||
format!("Cannot read either PKCS1, PKCS8 or EC private key from {key_file}")
|
||||
})
|
||||
.map(rustls::PrivateKey)
|
||||
}
|
||||
|
||||
+3
-4
@@ -93,15 +93,14 @@ pub async fn send_password_reset_email(
|
||||
.unwrap()
|
||||
.extend(["reset-password", "step2", token]);
|
||||
let body = format!(
|
||||
"Hello {},
|
||||
"Hello {username},
|
||||
This email has been sent to you in order to validate your identity.
|
||||
If you did not initiate the process your credentials might have been
|
||||
compromised. You should reset your password and contact an administrator.
|
||||
|
||||
To reset your password please visit the following URL: {}
|
||||
To reset your password please visit the following URL: {reset_url}
|
||||
|
||||
Please contact an administrator if you did not initiate the process.",
|
||||
username, reset_url
|
||||
Please contact an administrator if you did not initiate the process."
|
||||
);
|
||||
let res = send_email(
|
||||
to,
|
||||
|
||||
+2
-3
@@ -55,8 +55,7 @@ async fn create_admin_user(handler: &SqlBackendHandler, config: &Configuration)
|
||||
.len();
|
||||
assert!(
|
||||
pass_length >= 8,
|
||||
"Minimum password length is 8 characters, got {} characters",
|
||||
pass_length
|
||||
"Minimum password length is 8 characters, got {pass_length} characters"
|
||||
);
|
||||
handler
|
||||
.create_user(CreateUserRequest {
|
||||
@@ -97,7 +96,7 @@ async fn ensure_group_exists(handler: &SqlBackendHandler, group_name: &str) -> R
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.context(format!("while creating {} group", group_name))?;
|
||||
.context(format!("while creating {group_name} group"))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -169,8 +169,7 @@ impl TcpBackendHandler for SqlBackendHandler {
|
||||
.await?;
|
||||
if result.rows_affected == 0 {
|
||||
return Err(DomainError::EntityNotFound(format!(
|
||||
"No such password reset token: '{}'",
|
||||
token
|
||||
"No such password reset token: '{token}'"
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user