Skip to content

Commit 77ca8c5

Browse files
author
Mohammod Al Amin Ashik
committed
fix: apply cargo fmt to credential_store tests
1 parent 450014d commit 77ca8c5

1 file changed

Lines changed: 37 additions & 28 deletions

File tree

crates/mcpmux-gateway/src/pool/credential_store.rs

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,11 @@ mod tests {
311311

312312
#[async_trait]
313313
impl CredentialRepository for MockCredentialRepo {
314-
async fn get(&self, _space_id: &Uuid, _server_id: &str) -> anyhow::Result<Option<Credential>> {
314+
async fn get(
315+
&self,
316+
_space_id: &Uuid,
317+
_server_id: &str,
318+
) -> anyhow::Result<Option<Credential>> {
315319
Ok(self.credential.read().await.clone())
316320
}
317321

@@ -355,7 +359,11 @@ mod tests {
355359

356360
#[async_trait]
357361
impl OutboundOAuthRepository for MockOAuthRepo {
358-
async fn get(&self, _space_id: &Uuid, _server_id: &str) -> anyhow::Result<Option<OutboundOAuthRegistration>> {
362+
async fn get(
363+
&self,
364+
_space_id: &Uuid,
365+
_server_id: &str,
366+
) -> anyhow::Result<Option<OutboundOAuthRegistration>> {
359367
Ok(self.registration.read().await.clone())
360368
}
361369

@@ -369,7 +377,10 @@ mod tests {
369377
Ok(())
370378
}
371379

372-
async fn list_for_space(&self, _space_id: &Uuid) -> anyhow::Result<Vec<OutboundOAuthRegistration>> {
380+
async fn list_for_space(
381+
&self,
382+
_space_id: &Uuid,
383+
) -> anyhow::Result<Vec<OutboundOAuthRegistration>> {
373384
Ok(vec![])
374385
}
375386
}
@@ -428,19 +439,14 @@ mod tests {
428439
};
429440
cred_repo.set(credential).await;
430441

431-
let store = DatabaseCredentialStore::new(
432-
space_id,
433-
server_id,
434-
server_url,
435-
cred_repo,
436-
oauth_repo,
437-
);
442+
let store =
443+
DatabaseCredentialStore::new(space_id, server_id, server_url, cred_repo, oauth_repo);
438444

439445
// First load - should have ~10 seconds
440446
let stored1 = store.load().await.unwrap().unwrap();
441447
let token1 = stored1.token_response.as_ref().unwrap();
442448
let expires_in_1 = token1.expires_in().unwrap();
443-
449+
444450
assert!(expires_in_1.as_secs() >= 9 && expires_in_1.as_secs() <= 10);
445451

446452
// Wait 2 seconds
@@ -450,16 +456,21 @@ mod tests {
450456
let stored2 = store.load().await.unwrap().unwrap();
451457
let token2 = stored2.token_response.as_ref().unwrap();
452458
let expires_in_2 = token2.expires_in().unwrap();
453-
459+
454460
// This is the critical assertion: expires_in should decrease because it's recalculated
455-
assert!(expires_in_2.as_secs() >= 7 && expires_in_2.as_secs() <= 8,
461+
assert!(
462+
expires_in_2.as_secs() >= 7 && expires_in_2.as_secs() <= 8,
456463
"Expected expires_in to decrease from ~10s to ~8s, but got {} seconds",
457-
expires_in_2.as_secs());
458-
464+
expires_in_2.as_secs()
465+
);
466+
459467
// Verify it actually decreased
460-
assert!(expires_in_2 < expires_in_1,
468+
assert!(
469+
expires_in_2 < expires_in_1,
461470
"expires_in should decrease on subsequent loads (was {}, now {})",
462-
expires_in_1.as_secs(), expires_in_2.as_secs());
471+
expires_in_1.as_secs(),
472+
expires_in_2.as_secs()
473+
);
463474
}
464475

465476
#[tokio::test]
@@ -500,22 +511,20 @@ mod tests {
500511
};
501512
cred_repo.set(credential).await;
502513

503-
let store = DatabaseCredentialStore::new(
504-
space_id,
505-
server_id,
506-
server_url,
507-
cred_repo,
508-
oauth_repo,
509-
);
514+
let store =
515+
DatabaseCredentialStore::new(space_id, server_id, server_url, cred_repo, oauth_repo);
510516

511517
// Load should return token with expires_in = 0 (expired)
512518
let stored = store.load().await.unwrap().unwrap();
513519
let token = stored.token_response.as_ref().unwrap();
514520
let expires_in = token.expires_in().unwrap();
515-
516-
assert_eq!(expires_in.as_secs(), 0,
521+
522+
assert_eq!(
523+
expires_in.as_secs(),
524+
0,
517525
"Expired token should have expires_in = 0, got {} seconds",
518-
expires_in.as_secs());
526+
expires_in.as_secs()
527+
);
519528
}
520529

521530
#[tokio::test]
@@ -542,7 +551,7 @@ mod tests {
542551
Some("new_refresh".to_string()),
543552
Some(std::time::Duration::from_secs(3600)),
544553
);
545-
554+
546555
let credentials = StoredCredentials {
547556
client_id: "new-client-id".to_string(),
548557
token_response: Some(token_response),

0 commit comments

Comments
 (0)