Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
rustup toolchain install
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- run: |
cargo clippy -- -Dwarnings
cargo clippy --all-features --workspace --all-targets -- -Dwarnings

lock_machete:
runs-on: ubuntu-24.04
steps:
Expand Down
7 changes: 2 additions & 5 deletions v-api/src/context/magic_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -758,10 +758,7 @@ mod tests {
.complete_login_attempt(TypedUuid::new_v4(), &attempt.nonce_signature)
.await
.unwrap_err();
assert!(match error {
ResourceError::DoesNotExist => true,
_ => false,
});
assert!(matches!(error, ResourceError::DoesNotExist));

let transitioned_attempt = mlink_ctx
.complete_login_attempt(attempt.id, &attempt.nonce_signature)
Expand Down
8 changes: 3 additions & 5 deletions v-api/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![],
Expand All @@ -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]
Expand Down Expand Up @@ -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(),
Expand Down
16 changes: 6 additions & 10 deletions v-api/src/endpoints/api_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,9 +820,7 @@ mod tests {
let mut store = MockApiUserStore::new();
store
.expect_upsert()
.withf(|x: &NewApiUser<VPermission>| {
x.permissions.can(&VPermission::CreateApiUser.into())
})
.withf(|x: &NewApiUser<VPermission>| x.permissions.can(&VPermission::CreateApiUser))
.returning(|user| {
Ok(ApiUserInfo {
user: ApiUser {
Expand All @@ -839,9 +837,7 @@ mod tests {
});
store
.expect_upsert()
.withf(|x: &NewApiUser<VPermission>| {
x.permissions.can(&VPermission::GetApiUsersAll.into())
})
.withf(|x: &NewApiUser<VPermission>| x.permissions.can(&VPermission::GetApiUsersAll))
.returning(|_| Err(StoreError::Unknown));
let mut api_user_provider_store = MockApiUserProviderStore::new();
api_user_provider_store
Expand Down Expand Up @@ -921,7 +917,7 @@ mod tests {
let mut store = MockApiUserStore::new();
store
.expect_upsert()
.withf(move |x: &NewApiUser<VPermission>| &x.id == &success_id)
.withf(move |x: &NewApiUser<VPermission>| x.id == success_id)
.returning(|user| {
Ok(ApiUserInfo {
user: ApiUser {
Expand All @@ -938,7 +934,7 @@ mod tests {
});
store
.expect_upsert()
.withf(move |x: &NewApiUser<VPermission>| &x.id == &failure_id)
.withf(move |x: &NewApiUser<VPermission>| x.id == failure_id)
.returning(|_| Err(StoreError::Unknown));
let mut api_user_provider_store = MockApiUserProviderStore::new();
api_user_provider_store
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion v-api/src/endpoints/login/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions v-api/src/endpoints/login/oauth/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -913,7 +913,7 @@ mod tests {
};

let response = oauth_redirect_response(
&ctx.public_url(),
ctx.public_url(),
&*ctx
.get_oauth_provider(&OAuthProviderName::Google)
.await
Expand Down Expand Up @@ -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()
Expand Down
30 changes: 15 additions & 15 deletions v-model/tests/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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(),
},
)
Expand All @@ -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(),
},
)
Expand All @@ -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(),
Expand All @@ -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
Expand All @@ -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(),
},
)
Expand All @@ -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(),
),
Expand All @@ -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
Expand All @@ -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(),
),
Expand Down
Loading