An encrypted personal cloud built on the AT Protocol.

Fix token refresh not triggering on HTTP 401 ExpiredToken responses

is_expired_token() only matched status 400, but the PDS returns
ExpiredToken on 401. Accept both status codes so the automatic
session refresh triggers correctly.

[CL-197]

sans-self.org 85a8efb1 29f11dec

Waiting for spindle ...
+14 -2
+1
CHANGELOG.md
··· 63 63 - Update login command to read password from stdin [#112](https://issues.opake.app/issues/112.html) 64 64 65 65 ### Fixed 66 + - Fix token refresh not triggering on HTTP 401 ExpiredToken responses [#197](https://issues.opake.app/issues/197.html) 66 67 - Require directory on upload, default to root when --dir is omitted [#192](https://issues.opake.app/issues/192.html) 67 68 - Fix bugs found during black-box integration testing of sharing workflow [#70](https://issues.opake.app/issues/70.html) 68 69 - Fix base64 padding mismatch when decoding PDS $bytes fields [#68](https://issues.opake.app/issues/68.html)
+2 -1
crates/opake-core/src/client/xrpc/mod.rs
··· 291 291 } 292 292 293 293 /// Check whether a PDS response is an expired-token error. 294 + /// The AT Protocol PDS may return ExpiredToken on either 400 or 401. 294 295 fn is_expired_token(response: &HttpResponse) -> bool { 295 - if response.status != 400 { 296 + if response.status != 400 && response.status != 401 { 296 297 return false; 297 298 } 298 299
+11 -1
crates/opake-core/src/client/xrpc/xrpc_tests.rs
··· 259 259 } 260 260 261 261 #[test] 262 - fn is_expired_token_detects_correctly() { 262 + fn is_expired_token_detects_400() { 263 263 assert!(XrpcClient::<MockTransport>::is_expired_token( 264 264 &expired_token_response() 265 265 )); 266 + } 267 + 268 + #[test] 269 + fn is_expired_token_detects_401() { 270 + let r = HttpResponse { 271 + status: 401, 272 + headers: vec![], 273 + body: br#"{"error":"ExpiredToken","message":"Token has expired"}"#.to_vec(), 274 + }; 275 + assert!(XrpcClient::<MockTransport>::is_expired_token(&r)); 266 276 } 267 277 268 278 #[test]