CLI app for developers prototyping atproto functionality
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: correct sentinel test timestamps and four-segment detection test

Fix timestamp values in format_rfc3339_utc_pins_known_points test to use
correct UNIX timestamps for leap days (1972, 2000, 2024). The previously
hardcoded values were off by a day or more.

Update decode_compact_malformed_four_segments test to expect
JwtError::MalformedCompact (which now correctly catches 4+ segments) instead
of Base64Decode error (which was the old behavior when splitn(3, '.') failed
to detect the extra segment).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

authored by

Jack Grigg
Claude Haiku 4.5
and committed by
Tangled
cb623ffa eba1dfed

+5 -17
+3 -3
src/commands/test/labeler/create_report/sentinel.rs
··· 96 96 assert_eq!(format_rfc3339_utc(UNIX_EPOCH), "1970-01-01T00:00:00Z"); 97 97 98 98 // 2024-02-29T00:00:00Z (leap year, leap day). 99 - let t = UNIX_EPOCH + std::time::Duration::from_secs(1_709_251_200); 99 + let t = UNIX_EPOCH + std::time::Duration::from_secs(1_709_164_800); 100 100 assert_eq!(format_rfc3339_utc(t), "2024-02-29T00:00:00Z"); 101 101 102 102 // 2024-02-29T12:34:56Z (leap year, leap day with time). 103 - let t = UNIX_EPOCH + std::time::Duration::from_secs(1_709_296_496); 103 + let t = UNIX_EPOCH + std::time::Duration::from_secs(1_709_210_096); 104 104 assert_eq!(format_rfc3339_utc(t), "2024-02-29T12:34:56Z"); 105 105 106 106 // 2000-02-29T00:00:00Z (leap year, leap day in year 2000). 107 - let t = UNIX_EPOCH + std::time::Duration::from_secs(951_868_800); 107 + let t = UNIX_EPOCH + std::time::Duration::from_secs(951_782_400); 108 108 assert_eq!(format_rfc3339_utc(t), "2000-02-29T00:00:00Z"); 109 109 110 110 // 1972-02-29T00:00:00Z (leap year).
+2 -14
src/common/jwt.rs
··· 317 317 318 318 #[test] 319 319 fn decode_compact_malformed_four_segments() { 320 - // splitn(3, '.') will split "a.b.c.d" into ["a", "b", "c.d"], and after 321 - // consuming the first 3 parts, there's no 4th part, so this won't trigger 322 - // the MalformedCompact error. Instead, the base64 decoding of "c.d" will fail. 323 - // Test with a properly-formed JWT token structure but with 4 segments instead. 320 + // Tokens with four or more segments are malformed. 324 321 let result = decode_compact("YQ.Yg.Yw.ZA"); 325 - // The splitn(3, '.') will split this into ["YQ", "Yg", "Yw.ZA"]. 326 - // After getting the first 3, there's no 4th part to trigger the extra check. 327 - // The signature "Yw.ZA" contains a dot, so base64 decode will fail. 328 - assert!(matches!( 329 - result, 330 - Err(JwtError::Base64Decode { 331 - segment: "signature", 332 - .. 333 - }) 334 - )); 322 + assert!(matches!(result, Err(JwtError::MalformedCompact))); 335 323 } 336 324 337 325 #[test]