@@ -1696,15 +1696,35 @@ mod tests {
16961696 let mut server = mockito:: Server :: new ( ) ;
16971697 // Each mint is good for 5 s — under the leeway, so the next resolve
16981698 // refreshes again rather than reusing it.
1699+ //
1700+ // The first mint rotates the refresh token, and each mock matches on
1701+ // the one it expects to be presented. Without that the two requests
1702+ // are byte-identical (`refresh()` re-sends the stored token, and a
1703+ // response omitting one leaves it unchanged), so which mock answered
1704+ // which refresh would rest on mockito's same-route ordering — and a
1705+ // flip would surface as an unmatched-bearer 501 on `POST /v1/uploads`,
1706+ // reading like the provider broke rather than the harness. Matching on
1707+ // the token also proves the two legs ran against *successive*
1708+ // sessions, not just two canned responses.
16991709 let mint_first = server
17001710 . mock ( "POST" , "/o/token/" )
1711+ . match_body ( mockito:: Matcher :: UrlEncoded (
1712+ "refresh_token" . into ( ) ,
1713+ "refresh-1" . into ( ) ,
1714+ ) )
17011715 . with_status ( 200 )
17021716 . with_header ( "content-type" , "application/json" )
1703- . with_body ( r#"{"access_token":"upload-jwt-1","expires_in":5}"# )
1717+ . with_body (
1718+ r#"{"access_token":"upload-jwt-1","expires_in":5,"refresh_token":"refresh-2"}"# ,
1719+ )
17041720 . expect ( 1 )
17051721 . create ( ) ;
17061722 let mint_second = server
17071723 . mock ( "POST" , "/o/token/" )
1724+ . match_body ( mockito:: Matcher :: UrlEncoded (
1725+ "refresh_token" . into ( ) ,
1726+ "refresh-2" . into ( ) ,
1727+ ) )
17081728 . with_status ( 200 )
17091729 . with_header ( "content-type" , "application/json" )
17101730 . with_body ( r#"{"access_token":"upload-jwt-2","expires_in":5}"# )
0 commit comments