diff --git a/examples/service_account_impersonation.rs b/examples/service_account_impersonation.rs index b08144463..89eda9cd8 100644 --- a/examples/service_account_impersonation.rs +++ b/examples/service_account_impersonation.rs @@ -2,7 +2,7 @@ use yup_oauth2::{read_authorized_user_secret, ServiceAccountImpersonationAuthent #[tokio::main] async fn main() { - let svc_email = std::env::args().skip(1).next().unwrap(); + let svc_email = std::env::args().nth(1).unwrap(); let home = std::env::var("HOME").unwrap(); let user_secret = read_authorized_user_secret(format!( diff --git a/src/authenticator.rs b/src/authenticator.rs index 5ba159660..6ee1d1207 100644 --- a/src/authenticator.rs +++ b/src/authenticator.rs @@ -283,7 +283,7 @@ impl ServiceAccountAuthenticator { ) -> AuthenticatorBuilder { AuthenticatorBuilder::new( ServiceAccountFlowOpts { - key: service_account::FlowOptsKey::Key(service_account_key), + key: service_account::FlowOptsKey::Key(Box::new(service_account_key)), subject: None, }, client, @@ -477,12 +477,7 @@ impl AccessTokenAuthenticator { access_token: String, client: C, ) -> AuthenticatorBuilder { - AuthenticatorBuilder::new( - AccessTokenFlow { - access_token: access_token, - }, - client, - ) + AuthenticatorBuilder::new(AccessTokenFlow { access_token }, client) } } @@ -878,6 +873,7 @@ mod private { use crate::service_account_impersonator::ServiceAccountImpersonationFlow; use crate::types::{ApplicationSecret, TokenInfo}; + #[allow(clippy::enum_variant_names)] pub enum AuthFlow { DeviceFlow(DeviceFlow), InstalledFlow(InstalledFlow), diff --git a/src/installed.rs b/src/installed.rs index e9e2ba287..83ac7fb84 100644 --- a/src/installed.rs +++ b/src/installed.rs @@ -495,7 +495,7 @@ mod tests { //assert!(response.status().is_success()); } Result::Err(err) => { - assert!(false, "Failed to request from local server: {:?}", err); + panic!("Failed to request from local server: {:?}", err); } } @@ -511,7 +511,7 @@ mod tests { assert!(response.status().is_success()); } Result::Err(err) => { - assert!(false, "Failed to request from local server: {:?}", err); + panic!("Failed to request from local server: {:?}", err); } } diff --git a/src/service_account.rs b/src/service_account.rs index e8b7fbeff..8912d5767 100644 --- a/src/service_account.rs +++ b/src/service_account.rs @@ -41,7 +41,7 @@ fn decode_rsa_key(pem_pkcs8: &str) -> Result { let private_key = rustls_pemfile::pkcs8_private_keys(&mut pem_pkcs8.as_bytes()).next(); match private_key { - Some(Ok(key)) => Ok(PrivateKeyDer::Pkcs8(key.into())), + Some(Ok(key)) => Ok(PrivateKeyDer::Pkcs8(key)), None => Err(io::Error::new( io::ErrorKind::InvalidInput, "Not enough private keys in PEM", @@ -164,7 +164,7 @@ pub(crate) enum FlowOptsKey { /// A path at which the key can be read from disk Path(PathBuf), /// An already initialized key - Key(ServiceAccountKey), + Key(Box), } /// ServiceAccountFlow can fetch oauth tokens using a service account. @@ -178,7 +178,7 @@ impl ServiceAccountFlow { pub(crate) async fn new(opts: ServiceAccountFlowOpts) -> Result { let key = match opts.key { FlowOptsKey::Path(path) => crate::read_service_account_key(path).await?, - FlowOptsKey::Key(key) => key, + FlowOptsKey::Key(key) => *key, }; let signer = JWTSigner::new(&key.private_key)?; @@ -227,7 +227,7 @@ mod tests { use crate::helper::read_service_account_key; // Valid but deactivated key. - const TEST_PRIVATE_KEY_PATH: &'static str = "examples/Sanguine-69411a0c0eea.json"; + const TEST_PRIVATE_KEY_PATH: &str = "examples/Sanguine-69411a0c0eea.json"; // Uncomment this test to verify that we can successfully obtain tokens. // #[tokio::test] @@ -301,7 +301,7 @@ mod tests { let signature = signature.unwrap(); assert_eq!( - signature.split(".").nth(0).unwrap(), + signature.split('.').next().unwrap(), "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9" ); } diff --git a/src/service_account_impersonator.rs b/src/service_account_impersonator.rs index 34fa92235..0273dd346 100644 --- a/src/service_account_impersonator.rs +++ b/src/service_account_impersonator.rs @@ -15,7 +15,7 @@ use crate::{ Error, }; -const IAM_CREDENTIALS_ENDPOINT: &'static str = "https://iamcredentials.googleapis.com"; +const IAM_CREDENTIALS_ENDPOINT: &str = "https://iamcredentials.googleapis.com"; fn uri(email: &str) -> String { format!( diff --git a/src/storage.rs b/src/storage.rs index cdf33f562..7870c8276 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -64,11 +64,7 @@ pub(crate) struct ScopeSet<'a, T> { // Clone to be implemented regardless of whether T is Clone or not. impl<'a, T> Clone for ScopeSet<'a, T> { fn clone(&self) -> Self { - ScopeSet { - hash: self.hash, - filter: self.filter, - scopes: self.scopes, - } + *self } } impl<'a, T> Copy for ScopeSet<'a, T> {} diff --git a/src/types.rs b/src/types.rs index ba84b411d..02e5255d3 100644 --- a/src/types.rs +++ b/src/types.rs @@ -178,7 +178,7 @@ pub struct ConsoleApplicationSecret { pub mod tests { use super::*; - pub const SECRET: &'static str = + pub const SECRET: &str = "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\ \"client_secret\":\"UqkDJd5RFwnHoiG5x5Rub8SI\",\"token_uri\":\"https://accounts.google.\ com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:\ diff --git a/tests/tests.rs b/tests/tests.rs index 1e0f171ef..40a8901cb 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -199,7 +199,7 @@ async fn create_installed_flow_auth( } else { // Parse presented url to obtain redirect_uri with location of local // code-accepting server. - let uri = Uri::from_str(url.as_ref()).unwrap(); + let uri = Uri::from_str(url).unwrap(); let query = uri.query().unwrap(); let parsed = form_urlencoded::parse(query.as_bytes()).into_owned(); let mut rduri = None;