diff --git a/v-api/src/context/magic_link.rs b/v-api/src/context/magic_link.rs index 0d6b4c3..5c27d5c 100644 --- a/v-api/src/context/magic_link.rs +++ b/v-api/src/context/magic_link.rs @@ -731,7 +731,7 @@ mod tests { .expect_transition() .returning(move |id, signature, from, _to| { if &attempt_transition.id == id - && &attempt_transition.nonce_signature == signature + && attempt_transition.nonce_signature == signature && attempt_transition.attempt_state == from { Ok(Some(MagicLinkAttempt { diff --git a/v-api/src/context/mod.rs b/v-api/src/context/mod.rs index 529106b..e95b2b2 100644 --- a/v-api/src/context/mod.rs +++ b/v-api/src/context/mod.rs @@ -991,7 +991,7 @@ mod tests { let provider = ApiUserProvider { id: TypedUuid::new_v4(), - user_id: user_id, + user_id, provider: "test".to_string(), provider_id: "test_id".to_string(), emails: vec![], @@ -1013,9 +1013,7 @@ mod tests { .await .unwrap(); - let jwt = AuthToken::Jwt(Jwt::new(&ctx, &user_token).await.unwrap()); - - jwt + AuthToken::Jwt(Jwt::new(ctx, &user_token).await.unwrap()) } #[tokio::test] @@ -1077,7 +1075,7 @@ mod tests { .returning(move |_, _| { Ok(Some(AccessToken { id: valid_token_id, - user_id: user_id, + user_id, revoked_at: None, created_at: Utc::now(), updated_at: Utc::now(), diff --git a/v-api/src/endpoints/api_user.rs b/v-api/src/endpoints/api_user.rs index 0c566c0..55244e4 100644 --- a/v-api/src/endpoints/api_user.rs +++ b/v-api/src/endpoints/api_user.rs @@ -820,9 +820,7 @@ mod tests { let mut store = MockApiUserStore::new(); store .expect_upsert() - .withf(|x: &NewApiUser| { - x.permissions.can(&VPermission::CreateApiUser.into()) - }) + .withf(|x: &NewApiUser| x.permissions.can(&VPermission::CreateApiUser)) .returning(|user| { Ok(ApiUserInfo { user: ApiUser { @@ -839,9 +837,7 @@ mod tests { }); store .expect_upsert() - .withf(|x: &NewApiUser| { - x.permissions.can(&VPermission::GetApiUsersAll.into()) - }) + .withf(|x: &NewApiUser| x.permissions.can(&VPermission::GetApiUsersAll)) .returning(|_| Err(StoreError::Unknown)); let mut api_user_provider_store = MockApiUserProviderStore::new(); api_user_provider_store @@ -921,7 +917,7 @@ mod tests { let mut store = MockApiUserStore::new(); store .expect_upsert() - .withf(move |x: &NewApiUser| &x.id == &success_id) + .withf(move |x: &NewApiUser| x.id == success_id) .returning(|user| { Ok(ApiUserInfo { user: ApiUser { @@ -938,7 +934,7 @@ mod tests { }); store .expect_upsert() - .withf(move |x: &NewApiUser| &x.id == &failure_id) + .withf(move |x: &NewApiUser| x.id == failure_id) .returning(|_| Err(StoreError::Unknown)); let mut api_user_provider_store = MockApiUserProviderStore::new(); api_user_provider_store @@ -1372,7 +1368,7 @@ mod tests { let mut token_store = MockApiKeyStore::new(); token_store .expect_get() - .with(eq(api_user_token_path.api_key_id.clone()), eq(false)) + .with(eq(api_user_token_path.api_key_id), eq(false)) .returning(move |_, _| Ok(Some(token.clone()))); token_store .expect_get() @@ -1677,7 +1673,7 @@ mod tests { let mut email_store = MockApiUserContactEmailStore::new(); email_store .expect_upsert() - .withf(move |arg| arg.user_id == user.id && arg.email == "user@company".to_string()) + .withf(move |arg| arg.user_id == user.id && arg.email == "user@company") .returning(|new| { Ok(ApiUserContactEmail { id: new.id, diff --git a/v-api/src/endpoints/login/local/mod.rs b/v-api/src/endpoints/login/local/mod.rs index ca07749..122c085 100644 --- a/v-api/src/endpoints/login/local/mod.rs +++ b/v-api/src/endpoints/login/local/mod.rs @@ -55,7 +55,7 @@ where ctx.v_ctx().jwt_signer(), &api_user.user.id, &Claims::new( - &ctx.v_ctx(), + ctx.v_ctx(), None, &api_user.user.id, &api_user_provider.id, diff --git a/v-api/src/endpoints/login/oauth/code.rs b/v-api/src/endpoints/login/oauth/code.rs index 0e59668..6ba1d0d 100644 --- a/v-api/src/endpoints/login/oauth/code.rs +++ b/v-api/src/endpoints/login/oauth/code.rs @@ -813,7 +813,7 @@ mod tests { let ctx = mock_context(Arc::new(MockStorage::new())).await; let client_id = TypedUuid::new_v4(); let key = RawKey::generate::<8>(&Uuid::new_v4()) - .sign(&*ctx.signer()) + .sign(ctx.signer()) .await .unwrap(); let secret_signature = key.signature().to_string(); @@ -913,7 +913,7 @@ mod tests { }; let response = oauth_redirect_response( - &ctx.public_url(), + ctx.public_url(), &*ctx .get_oauth_provider(&OAuthProviderName::Google) .await @@ -1387,7 +1387,7 @@ mod tests { ctx.set_storage(Arc::new(storage)); let invalid_secret = RawKey::generate::<8>(&Uuid::new_v4()) - .sign(&*ctx.signer()) + .sign(ctx.signer()) .await .unwrap() .signature() diff --git a/v-model/tests/postgres.rs b/v-model/tests/postgres.rs index e133f50..c24d6d7 100644 --- a/v-model/tests/postgres.rs +++ b/v-model/tests/postgres.rs @@ -71,7 +71,7 @@ impl TestDb { }; println!("Creating database {}", db.db_name); - let create_result = sql_query(&format!("CREATE DATABASE {}", db.db_name)) + let create_result = sql_query(format!("CREATE DATABASE {}", db.db_name)) .execute(&mut db.conn()) .unwrap(); println!("Created database {:?}", create_result); @@ -100,7 +100,7 @@ impl TestDb { impl Drop for TestDb { fn drop(&mut self) { if self.should_drop { - sql_query(&format!("DROP DATABASE {}", self.db_name)) + sql_query(format!("DROP DATABASE {}", self.db_name)) .execute(&mut self.conn()) .unwrap(); } @@ -133,7 +133,7 @@ async fn test_api_user() { &store, NewApiUser { id: api_user_id, - permissions: vec![TestPermission::CreateApiKey(api_user_id).into()].into(), + permissions: vec![TestPermission::CreateApiKey(api_user_id)].into(), groups: BTreeSet::new(), }, ) @@ -153,7 +153,7 @@ async fn test_api_user() { &store, NewApiUser { id: api_user_id, - permissions: vec![TestPermission::CreateApiKey(api_user_id).into()].into(), + permissions: vec![TestPermission::CreateApiKey(api_user_id)].into(), groups: BTreeSet::new(), }, ) @@ -168,9 +168,9 @@ async fn test_api_user() { NewApiUser { id: api_user_id, permissions: vec![ - TestPermission::CreateApiKey(api_user_id).into(), - TestPermission::GetApiKey(api_user_id).into(), - TestPermission::DeleteApiKey(api_user_id).into(), + TestPermission::CreateApiKey(api_user_id), + TestPermission::GetApiKey(api_user_id), + TestPermission::DeleteApiKey(api_user_id), ] .into(), groups: BTreeSet::new(), @@ -183,13 +183,13 @@ async fn test_api_user() { api_user .user .permissions - .can(&TestPermission::GetApiKey(api_user_id).into()) + .can(&TestPermission::GetApiKey(api_user_id)) ); assert!( api_user .user .permissions - .can(&TestPermission::DeleteApiKey(api_user_id).into()) + .can(&TestPermission::DeleteApiKey(api_user_id)) ); // 5. Create an API token for the user @@ -199,7 +199,7 @@ async fn test_api_user() { id: TypedUuid::new_v4(), user_id: api_user.user.id, key_signature: format!("key-{}", Uuid::new_v4()), - permissions: Some(vec![TestPermission::GetApiKey(api_user_id).into()].into()), + permissions: Some(vec![TestPermission::GetApiKey(api_user_id)].into()), expires_at: Utc::now() + TimeDelta::try_seconds(5 * 60).unwrap(), }, ) @@ -215,8 +215,8 @@ async fn test_api_user() { key_signature: format!("key-{}", Uuid::new_v4()), permissions: Some( vec![ - TestPermission::CreateApiUser.into(), - TestPermission::GetApiKey(api_user_id).into(), + TestPermission::CreateApiUser, + TestPermission::GetApiKey(api_user_id), ] .into(), ), @@ -231,7 +231,7 @@ async fn test_api_user() { .permissions .as_ref() .unwrap() - .can(&TestPermission::CreateApiUser.into()) + .can(&TestPermission::CreateApiUser) ); // 7. Create an API token with excess permissions for the user @@ -243,8 +243,8 @@ async fn test_api_user() { key_signature: format!("key-{}", Uuid::new_v4()), permissions: Some( vec![ - TestPermission::CreateApiUser.into(), - TestPermission::GetApiKey(api_user_id).into(), + TestPermission::CreateApiUser, + TestPermission::GetApiKey(api_user_id), ] .into(), ),