diff --git a/crates/domain/src/deserialize.rs b/crates/domain/src/deserialize.rs index 17547f3..d11628e 100644 --- a/crates/domain/src/deserialize.rs +++ b/crates/domain/src/deserialize.rs @@ -12,11 +12,11 @@ pub fn deserialize_attribute_value( let parse_int = |value: &String| -> Result { value .parse::() - .with_context(|| format!("Invalid integer value {}", value)) + .with_context(|| format!("Invalid integer value {value}")) }; let parse_date = |value: &String| -> Result { Ok(chrono::DateTime::parse_from_rfc3339(value) - .with_context(|| format!("Invalid date value {}", value))? + .with_context(|| format!("Invalid date value {value}"))? .naive_utc()) }; let parse_photo = |value: &String| -> Result { diff --git a/crates/domain/src/types.rs b/crates/domain/src/types.rs index acba1d1..df02ce2 100644 --- a/crates/domain/src/types.rs +++ b/crates/domain/src/types.rs @@ -377,7 +377,7 @@ impl std::fmt::Debug for JpegPhoto { encoded.push_str(" ..."); }; f.debug_tuple("JpegPhoto") - .field(&format!("b64[{}]", encoded)) + .field(&format!("b64[{encoded}]")) .finish() } } diff --git a/crates/graphql-server/src/api.rs b/crates/graphql-server/src/api.rs index cff9d16..48ff295 100644 --- a/crates/graphql-server/src/api.rs +++ b/crates/graphql-server/src/api.rs @@ -75,7 +75,7 @@ pub fn export_schema(output_file: Option) -> anyhow::Result<()> { use lldap_sql_backend_handler::SqlBackendHandler; let output = schema::().as_schema_language(); match output_file { - None => println!("{}", output), + None => println!("{output}"), Some(path) => { use std::fs::File; use std::io::prelude::*; diff --git a/crates/ldap/src/core/group.rs b/crates/ldap/src/core/group.rs index 089a807..de28376 100644 --- a/crates/ldap/src/core/group.rs +++ b/crates/ldap/src/core/group.rs @@ -76,7 +76,7 @@ pub fn get_group_attribute( .users .iter() .filter(|u| user_filter.as_ref().map(|f| *u == f).unwrap_or(true)) - .map(|u| format!("uid={},ou=people,{}", u, base_dn_str).into_bytes()) + .map(|u| format!("uid={u},ou=people,{base_dn_str}").into_bytes()) .collect(), GroupFieldType::Uuid => vec![group.uuid.to_string().into_bytes()], GroupFieldType::Attribute(attr, _, _) => get_custom_attribute(&group.attributes, &attr)?, @@ -86,8 +86,7 @@ pub fn get_group_attribute( "+" => return None, "*" => { panic!( - "Matched {}, * should have been expanded into attribute list and * removed", - attribute + "Matched {attribute}, * should have been expanded into attribute list and * removed" ) } _ => { @@ -211,7 +210,7 @@ fn convert_group_filter( .map(GroupRequestFilter::Uuid) .map_err(|e| LdapError { code: LdapResultCode::Other, - message: format!("Invalid UUID: {:#}", e), + message: format!("Invalid UUID: {e:#}"), }), GroupFieldType::Member => Ok(get_user_id_from_distinguished_name_or_plain_name( &value_lc, @@ -290,15 +289,14 @@ fn convert_group_filter( _ => Err(LdapError { code: LdapResultCode::UnwillingToPerform, message: format!( - "Unsupported group attribute for substring filter: \"{}\"", - field + "Unsupported group attribute for substring filter: \"{field}\"" ), }), } } _ => Err(LdapError { code: LdapResultCode::UnwillingToPerform, - message: format!("Unsupported group filter: {:?}", filter), + message: format!("Unsupported group filter: {filter:?}"), }), } } @@ -318,7 +316,7 @@ pub async fn get_groups_list( .await .map_err(|e| LdapError { code: LdapResultCode::Other, - message: format!(r#"Error while listing groups "{}": {:#}"#, base, e), + message: format!(r#"Error while listing groups "{base}": {e:#}"#), }) } diff --git a/crates/ldap/src/core/user.rs b/crates/ldap/src/core/user.rs index e93fc05..b5d000a 100644 --- a/crates/ldap/src/core/user.rs +++ b/crates/ldap/src/core/user.rs @@ -100,8 +100,7 @@ pub fn get_user_attribute( "+" => return None, "*" => { panic!( - "Matched {}, * should have been expanded into attribute list and * removed", - attribute + "Matched {attribute}, * should have been expanded into attribute list and * removed" ) } _ => { @@ -298,10 +297,7 @@ fn convert_user_filter( | UserFieldType::PrimaryField(UserColumn::CreationDate) | UserFieldType::PrimaryField(UserColumn::Uuid) => Err(LdapError { code: LdapResultCode::UnwillingToPerform, - message: format!( - "Unsupported user attribute for substring filter: {:?}", - field - ), + message: format!("Unsupported user attribute for substring filter: {field:?}"), }), UserFieldType::NoMatch => Ok(UserRequestFilter::from(false)), UserFieldType::PrimaryField(UserColumn::Email) => Ok(UserRequestFilter::SubString( @@ -316,7 +312,7 @@ fn convert_user_filter( } _ => Err(LdapError { code: LdapResultCode::UnwillingToPerform, - message: format!("Unsupported user filter: {:?}", filter), + message: format!("Unsupported user filter: {filter:?}"), }), } } @@ -341,7 +337,7 @@ pub async fn get_user_list( .await .map_err(|e| LdapError { code: LdapResultCode::Other, - message: format!(r#"Error while searching user "{}": {:#}"#, base, e), + message: format!(r#"Error while searching user "{base}": {e:#}"#), }) } diff --git a/crates/ldap/src/core/utils.rs b/crates/ldap/src/core/utils.rs index 8744ee1..2862f30 100644 --- a/crates/ldap/src/core/utils.rs +++ b/crates/ldap/src/core/utils.rs @@ -66,10 +66,9 @@ impl UserOrGroupName { UserOrGroupName::InvalidSyntax(err) => return err, UserOrGroupName::UnexpectedFormat | UserOrGroupName::User(_) - | UserOrGroupName::Group(_) => format!( - r#"Unexpected DN format. Got "{}", expected: {}"#, - input, expected_format - ), + | UserOrGroupName::Group(_) => { + format!(r#"Unexpected DN format. Got "{input}", expected: {expected_format}"#) + } }, } } @@ -105,7 +104,7 @@ pub fn get_user_id_from_distinguished_name( ) -> LdapResult { match get_user_or_group_id_from_distinguished_name(dn, base_tree) { UserOrGroupName::User(user_id) => Ok(user_id), - err => Err(err.into_ldap_error(dn, format!(r#""uid=id,ou=people,{}""#, base_dn_str))), + err => Err(err.into_ldap_error(dn, format!(r#""uid=id,ou=people,{base_dn_str}""#))), } } @@ -116,7 +115,7 @@ pub fn get_group_id_from_distinguished_name( ) -> LdapResult { match get_user_or_group_id_from_distinguished_name(dn, base_tree) { UserOrGroupName::Group(group_name) => Ok(group_name), - err => Err(err.into_ldap_error(dn, format!(r#""uid=id,ou=groups,{}""#, base_dn_str))), + err => Err(err.into_ldap_error(dn, format!(r#""uid=id,ou=groups,{base_dn_str}""#))), } } @@ -343,7 +342,7 @@ pub struct ObjectClassList(Vec); // See RFC4512 section 4.2.1 "objectClasses" impl ObjectClassList { pub fn format_for_ldap_schema_description(&self) -> String { - join(self.0.iter().map(|c| format!("'{}'", c)), " ") + join(self.0.iter().map(|c| format!("'{c}'")), " ") } } diff --git a/crates/ldap/src/create.rs b/crates/ldap/src/create.rs index b7d0ef4..a5f577e 100644 --- a/crates/ldap/src/create.rs +++ b/crates/ldap/src/create.rs @@ -33,10 +33,7 @@ pub(crate) async fn create_user_or_group( } err => Err(err.into_ldap_error( &request.dn, - format!( - r#""uid=id,ou=people,{}" or "uid=id,ou=groups,{}""#, - base_dn_str, base_dn_str - ), + format!(r#""uid=id,ou=people,{base_dn_str}" or "uid=id,ou=groups,{base_dn_str}""#), )), } } @@ -73,10 +70,7 @@ async fn create_user( std::str::from_utf8(val) .map_err(|e| LdapError { code: LdapResultCode::ConstraintViolation, - message: format!( - "Attribute value is invalid UTF-8: {:#?} (value {:?})", - e, val - ), + message: format!("Attribute value is invalid UTF-8: {e:#?} (value {val:?})"), }) .map(str::to_owned) } @@ -92,7 +86,7 @@ async fn create_user( value: deserialize::deserialize_attribute_value(&[value], typ, false).map_err(|e| { LdapError { code: LdapResultCode::ConstraintViolation, - message: format!("Invalid attribute value: {}", e), + message: format!("Invalid attribute value: {e}"), } })?, }) @@ -134,7 +128,7 @@ async fn create_user( .await .map_err(|e| LdapError { code: LdapResultCode::OperationsError, - message: format!("Could not create user: {:#?}", e), + message: format!("Could not create user: {e:#?}"), })?; Ok(vec![make_add_response( LdapResultCode::Success, @@ -156,7 +150,7 @@ async fn create_group( .await .map_err(|e| LdapError { code: LdapResultCode::OperationsError, - message: format!("Could not create group: {:#?}", e), + message: format!("Could not create group: {e:#?}"), })?; Ok(vec![make_add_response( LdapResultCode::Success, diff --git a/crates/ldap/src/delete.rs b/crates/ldap/src/delete.rs index c5cd02f..6d1ad31 100644 --- a/crates/ldap/src/delete.rs +++ b/crates/ldap/src/delete.rs @@ -30,10 +30,7 @@ pub(crate) async fn delete_user_or_group( UserOrGroupName::Group(group_name) => delete_group(backend_handler, group_name).await, err => Err(err.into_ldap_error( &request, - format!( - r#""uid=id,ou=people,{}" or "uid=id,ou=groups,{}""#, - base_dn_str, base_dn_str - ), + format!(r#""uid=id,ou=people,{base_dn_str}" or "uid=id,ou=groups,{base_dn_str}""#), )), } } @@ -53,7 +50,7 @@ async fn delete_user( }, e => LdapError { code: LdapResultCode::OperationsError, - message: format!("Error while finding user: {:?}", e), + message: format!("Error while finding user: {e:?}"), }, })?; backend_handler @@ -61,7 +58,7 @@ async fn delete_user( .await .map_err(|e| LdapError { code: LdapResultCode::OperationsError, - message: format!("Error while deleting user: {:?}", e), + message: format!("Error while deleting user: {e:?}"), })?; Ok(vec![make_del_response( LdapResultCode::Success, @@ -79,7 +76,7 @@ async fn delete_group( .await .map_err(|e| LdapError { code: LdapResultCode::OperationsError, - message: format!("Error while finding group: {:?}", e), + message: format!("Error while finding group: {e:?}"), })?; let group_id = groups .iter() @@ -94,7 +91,7 @@ async fn delete_group( .await .map_err(|e| LdapError { code: LdapResultCode::OperationsError, - message: format!("Error while deleting group: {:?}", e), + message: format!("Error while deleting group: {e:?}"), })?; Ok(vec![make_del_response( LdapResultCode::Success, diff --git a/crates/ldap/src/handler.rs b/crates/ldap/src/handler.rs index bde29ef..c8473db 100644 --- a/crates/ldap/src/handler.rs +++ b/crates/ldap/src/handler.rs @@ -100,10 +100,7 @@ impl LdapHandler LdapHandler LdapHandler vec![make_extended_response( LdapResultCode::ProtocolError, - format!("Error while parsing password modify request: {:#?}", e), + format!("Error while parsing password modify request: {e:#?}"), )], }, OID_WHOAMI => { @@ -343,7 +340,7 @@ impl LdapHandler vec![make_extended_response( LdapResultCode::UnwillingToPerform, - format!("Unsupported operation: {:#?}", op), + format!("Unsupported operation: {op:#?}"), )], }) } diff --git a/crates/ldap/src/modify.rs b/crates/ldap/src/modify.rs index 08ec987..545d1bf 100644 --- a/crates/ldap/src/modify.rs +++ b/crates/ldap/src/modify.rs @@ -47,7 +47,7 @@ async fn handle_modify_change( .await .map_err(|e| LdapError { code: LdapResultCode::Other, - message: format!("Error while changing the password: {:#?}", e), + message: format!("Error while changing the password: {e:#?}"), })?; } else { return Err(LdapError { @@ -94,7 +94,7 @@ where .await .map_err(|e| LdapError { code: LdapResultCode::OperationsError, - message: format!("Internal error while requesting user's groups: {:#?}", e), + message: format!("Internal error while requesting user's groups: {e:#?}"), })? .iter() .any(|g| g.display_name == "lldap_admin".into()); @@ -115,7 +115,7 @@ where } Err(e) => Err(LdapError { code: LdapResultCode::InvalidDNSyntax, - message: format!("Invalid username: {}", e), + message: format!("Invalid username: {e}"), }), } } @@ -166,7 +166,7 @@ mod tests { fn make_password_modify_request(target_user: &str) -> LdapModifyRequest { LdapModifyRequest { - dn: format!("uid={},ou=people,dc=example,dc=com", target_user), + dn: format!("uid={target_user},ou=people,dc=example,dc=com"), changes: vec![LdapModify { operation: LdapModifyType::Replace, modification: ldap3_proto::LdapPartialAttribute { @@ -284,7 +284,7 @@ mod tests { let request = { let target_user = "bob"; LdapModifyRequest { - dn: format!("uid={},ou=people,dc=example,dc=com", target_user), + dn: format!("uid={target_user},ou=people,dc=example,dc=com"), changes: vec![LdapModify { operation: LdapModifyType::Replace, modification: ldap3_proto::LdapPartialAttribute { diff --git a/crates/ldap/src/password.rs b/crates/ldap/src/password.rs index b01655f..aa8101b 100644 --- a/crates/ldap/src/password.rs +++ b/crates/ldap/src/password.rs @@ -112,8 +112,7 @@ pub(crate) async fn do_password_modification( .map_err(|e| LdapError { code: LdapResultCode::OperationsError, message: format!( - "Internal error while requesting user's groups: {:#?}", - e + "Internal error while requesting user's groups: {e:#?}" ), })? .iter() @@ -131,7 +130,7 @@ pub(crate) async fn do_password_modification( { Err(LdapError { code: LdapResultCode::Other, - message: format!("Error while changing the password: {:#?}", e), + message: format!("Error while changing the password: {e:#?}"), }) } else { Ok(vec![make_extended_response( @@ -142,7 +141,7 @@ pub(crate) async fn do_password_modification( } Err(e) => Err(LdapError { code: LdapResultCode::InvalidDNSyntax, - message: format!("Invalid username: {}", e), + message: format!("Invalid username: {e}"), }), } } diff --git a/crates/ldap/src/search.rs b/crates/ldap/src/search.rs index c80cc91..305fd17 100644 --- a/crates/ldap/src/search.rs +++ b/crates/ldap/src/search.rs @@ -369,7 +369,7 @@ pub async fn do_search( ) -> LdapResult> { let schema = PublicSchema::from(backend_handler.get_schema().await.map_err(|e| LdapError { code: LdapResultCode::OperationsError, - message: format!("Unable to get schema: {:#}", e), + message: format!("Unable to get schema: {e:#}"), })?); let search_results = do_search_internal(ldap_info, backend_handler, request, &schema).await?; let mut results = match search_results { diff --git a/crates/sql-backend-handler/src/sql_backend_handler.rs b/crates/sql-backend-handler/src/sql_backend_handler.rs index 8e160f7..4835d89 100644 --- a/crates/sql-backend-handler/src/sql_backend_handler.rs +++ b/crates/sql-backend-handler/src/sql_backend_handler.rs @@ -91,7 +91,7 @@ pub mod tests { handler .create_user(CreateUserRequest { user_id: UserId::new(name), - email: format!("{}@bob.bob", name).into(), + email: format!("{name}@bob.bob").into(), display_name: Some("display ".to_string() + name), attributes: vec![ DomainAttribute { diff --git a/crates/sql-backend-handler/src/sql_group_backend_handler.rs b/crates/sql-backend-handler/src/sql_group_backend_handler.rs index 41c1ff2..271b5eb 100644 --- a/crates/sql-backend-handler/src/sql_group_backend_handler.rs +++ b/crates/sql-backend-handler/src/sql_group_backend_handler.rs @@ -164,7 +164,7 @@ impl GroupBackendHandler for SqlBackendHandler { .one(&self.sql_pool) .await? .map(Into::::into) - .ok_or_else(|| DomainError::EntityNotFound(format!("{:?}", group_id)))?; + .ok_or_else(|| DomainError::EntityNotFound(format!("{group_id:?}")))?; let attributes = model::GroupAttributes::find() .filter(model::GroupAttributesColumn::GroupId.eq(group_details.group_id)) .order_by_asc(model::GroupAttributesColumn::AttributeName) @@ -252,8 +252,7 @@ impl GroupBackendHandler for SqlBackendHandler { .await?; if res.rows_affected == 0 { return Err(DomainError::EntityNotFound(format!( - "No such group: '{:?}'", - group_id + "No such group: '{group_id:?}'" ))); } Ok(()) @@ -306,8 +305,7 @@ impl SqlBackendHandler { remove_group_attributes.push(attribute); } else { return Err(DomainError::InternalError(format!( - "Group attribute name {} doesn't exist in the schema, yet was attempted to be removed from the database", - attribute + "Group attribute name {attribute} doesn't exist in the schema, yet was attempted to be removed from the database" ))); } } diff --git a/crates/sql-backend-handler/src/sql_user_backend_handler.rs b/crates/sql-backend-handler/src/sql_user_backend_handler.rs index 21e0ab6..351eb6e 100644 --- a/crates/sql-backend-handler/src/sql_user_backend_handler.rs +++ b/crates/sql-backend-handler/src/sql_user_backend_handler.rs @@ -240,8 +240,7 @@ impl SqlBackendHandler { remove_user_attributes.push(attribute); } else { return Err(DomainError::InternalError(format!( - "User attribute name {} doesn't exist in the schema, yet was attempted to be removed from the database", - attribute + "User attribute name {attribute} doesn't exist in the schema, yet was attempted to be removed from the database" ))); } } @@ -384,8 +383,7 @@ impl UserBackendHandler for SqlBackendHandler { .await?; if res.rows_affected == 0 { return Err(DomainError::EntityNotFound(format!( - "No such user: '{}'", - user_id + "No such user: '{user_id}'" ))); } Ok(()) @@ -408,8 +406,7 @@ impl UserBackendHandler for SqlBackendHandler { .await?; if res.rows_affected == 0 { return Err(DomainError::EntityNotFound(format!( - "No such membership: '{}' -> {:?}", - user_id, group_id + "No such membership: '{user_id}' -> {group_id:?}" ))); } Ok(()) diff --git a/server/src/auth_service.rs b/server/src/auth_service.rs index e3719b4..5bdcbb2 100644 --- a/server/src/auth_service.rs +++ b/server/src/auth_service.rs @@ -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 diff --git a/server/src/configuration.rs b/server/src/configuration.rs index 8f51297..5bfdc74 100644 --- a/server/src/configuration.rs +++ b/server/src/configuration.rs @@ -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>( 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( diff --git a/server/src/database_string.rs b/server/src/database_string.rs index 67b165f..52e6f37 100644 --- a/server/src/database_string.rs +++ b/server/src/database_string.rs @@ -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!( diff --git a/server/src/healthcheck.rs b/server/src/healthcheck.rs index dda0cda..0f25889 100644 --- a/server/src/healthcheck.rs +++ b/server/src/healthcheck.rs @@ -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"); diff --git a/server/src/ldap_server.rs b/server/src/ldap_server.rs index 54233f1..f5bcb20 100644 --- a/server/src/ldap_server.rs +++ b/server/src/ldap_server.rs @@ -132,10 +132,7 @@ fn read_private_key(key_file: &str) -> Result { .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) } diff --git a/server/src/mail.rs b/server/src/mail.rs index 221ead2..f0b2463 100644 --- a/server/src/mail.rs +++ b/server/src/mail.rs @@ -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, diff --git a/server/src/main.rs b/server/src/main.rs index 21a3d59..56e4165 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -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(()) } diff --git a/server/src/sql_tcp_backend_handler.rs b/server/src/sql_tcp_backend_handler.rs index 923e156..834290d 100644 --- a/server/src/sql_tcp_backend_handler.rs +++ b/server/src/sql_tcp_backend_handler.rs @@ -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(()) diff --git a/server/tests/common/env.rs b/server/tests/common/env.rs index a9e0cfc..532594b 100644 --- a/server/tests/common/env.rs +++ b/server/tests/common/env.rs @@ -14,13 +14,13 @@ pub fn database_url() -> String { pub fn ldap_url() -> String { let port = var("LLDAP_LDAP_PORT").ok(); let port = port.unwrap_or("3890".to_string()); - format!("ldap://localhost:{}", port) + format!("ldap://localhost:{port}") } pub fn http_url() -> String { let port = var("LLDAP_HTTP_PORT").ok(); let port = port.unwrap_or("17170".to_string()); - format!("http://localhost:{}", port) + format!("http://localhost:{port}") } pub fn admin_dn() -> String { diff --git a/server/tests/common/fixture.rs b/server/tests/common/fixture.rs index 948b834..90cafdc 100644 --- a/server/tests/common/fixture.rs +++ b/server/tests/common/fixture.rs @@ -102,7 +102,7 @@ impl LLDAPFixture { create_user::Variables { user: create_user::CreateUserInput { id: user.clone(), - email: Some(format!("{}@lldap.test", user)), + email: Some(format!("{user}@lldap.test")), avatar: None, display_name: None, first_name: None, @@ -181,11 +181,11 @@ impl Drop for LLDAPFixture { Signal::SIGTERM, ); if let Err(err) = result { - println!("Failed to send kill signal: {:?}", err); + println!("Failed to send kill signal: {err:?}"); let _ = self .child .kill() - .map_err(|err| println!("Failed to kill LLDAP: {:?}", err)); + .map_err(|err| println!("Failed to kill LLDAP: {err:?}")); return; } @@ -193,10 +193,7 @@ impl Drop for LLDAPFixture { let status = self.child.try_wait(); match status { Err(e) => { - println!( - "Failed to get status while waiting for graceful exit: {}", - e - ); + println!("Failed to get status while waiting for graceful exit: {e}"); break; } Ok(None) => { @@ -204,7 +201,7 @@ impl Drop for LLDAPFixture { } Ok(Some(status)) => { if !status.success() { - println!("LLDAP exited with status {}", status) + println!("LLDAP exited with status {status}") } return; } @@ -215,7 +212,7 @@ impl Drop for LLDAPFixture { let _ = self .child .kill() - .map_err(|err| println!("Failed to kill LLDAP: {:?}", err)); + .map_err(|err| println!("Failed to kill LLDAP: {err:?}")); } } @@ -223,7 +220,7 @@ pub fn new_id(prefix: Option<&str>) -> String { let id = Uuid::new_v4(); let id = format!("{}-lldap-test", id.simple()); match prefix { - Some(prefix) => format!("{}{}", prefix, id), + Some(prefix) => format!("{prefix}{id}"), None => id, } } diff --git a/server/tests/common/graphql.rs b/server/tests/common/graphql.rs index 22083a3..81cc594 100644 --- a/server/tests/common/graphql.rs +++ b/server/tests/common/graphql.rs @@ -103,7 +103,7 @@ where }) }; let url = env::http_url() + "/api/graphql"; - let auth_header = format!("Bearer {}", token); + let auth_header = format!("Bearer {token}"); client .post(url) .header(reqwest::header::AUTHORIZATION, auth_header) diff --git a/server/tests/integrations.rs b/server/tests/integrations.rs index e912f0a..5a89c95 100644 --- a/server/tests/integrations.rs +++ b/server/tests/integrations.rs @@ -31,13 +31,13 @@ fn gitea() { ldap.simple_bind(bind_dn.as_str(), env::admin_password().as_str()) .expect("failed to bind to ldap"); - let user_base = format!("ou=people,{}", base_dn); + let user_base = format!("ou=people,{base_dn}"); let attrs = vec!["uid", "givenName", "sn", "mail", "jpegPhoto"]; let results = ldap .search( user_base.as_str(), Scope::Subtree, - format!("(memberof=cn={},ou=groups,{})", gitea_user_group, base_dn).as_str(), + format!("(memberof=cn={gitea_user_group},ou=groups,{base_dn})").as_str(), attrs, ) .expect("failed to find gitea users") diff --git a/server/tests/ldap.rs b/server/tests/ldap.rs index f624813..9a048f1 100644 --- a/server/tests/ldap.rs +++ b/server/tests/ldap.rs @@ -86,7 +86,7 @@ fn admin_search() { ldap.search( env::base_dn().as_str(), Scope::Subtree, - format!("(&(objectclass=person)(uid={}))", admin_name).as_str(), + format!("(&(objectclass=person)(uid={admin_name}))").as_str(), attrs, ) .expect("failed to find admin"), @@ -97,7 +97,7 @@ fn admin_search() { found_users .get(&admin_name) .unwrap() - .contains(format!("cn={},ou=groups,{}", admin_group_name, base_dn).as_str()) + .contains(format!("cn={admin_group_name},ou=groups,{base_dn}").as_str()) ); ldap.unbind().expect("failed to unbind ldap connection"); }