Skip to content

Commit c19b359

Browse files
committed
fix: key prefix validation tests
1 parent 3ceac68 commit c19b359

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

crates/api-keys-simplified/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ mod tests {
326326
assert!(KeyPrefix::new("sk").is_ok());
327327
assert!(KeyPrefix::new("api_key").is_ok());
328328
assert!(KeyPrefix::new("").is_err());
329-
assert!(KeyPrefix::new("invalid-prefix").is_err());
329+
assert!(KeyPrefix::new("invalid-prefix").is_ok());
330330
}
331331

332332
#[test]

crates/api-keys-simplified/tests/key_expiry.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ fn test_expired_key_wrong_hash() {
8787
/// Test very short expiry (seconds)
8888
#[test]
8989
fn test_short_expiry() {
90+
const EXPIRY: i64 = 3;
9091
let manager = ApiKeyManagerV0::init_default_config("sk").unwrap();
91-
let expiry = Utc::now() + Duration::seconds(3);
92+
let expiry = Utc::now() + Duration::seconds(EXPIRY);
9293
let key = manager
9394
.generate_with_expiry(Environment::production(), expiry)
9495
.unwrap();
@@ -100,7 +101,7 @@ fn test_short_expiry() {
100101
);
101102

102103
// Wait for expiry
103-
std::thread::sleep(std::time::Duration::from_secs(3));
104+
std::thread::sleep(std::time::Duration::from_secs(EXPIRY as u64 + 1));
104105

105106
// Should now be expired
106107
assert_eq!(

0 commit comments

Comments
 (0)