From 6817fce0bc9d14009a1d1dfb9365d991ce6fbc4b Mon Sep 17 00:00:00 2001 From: Glenn Griffin Date: Fri, 29 Nov 2019 15:31:41 -0800 Subject: [PATCH] Extend the refresh tests. Verify that a second refresh can happen after the first. This adds coverage to ensure that a refresh flow keeps the refresh token intact by showing that a second refresh can succeed. --- tests/tests.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/tests.rs b/tests/tests.rs index fe2d6b3..44ff000 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -417,6 +417,28 @@ async fn test_refresh() { assert_eq!("accesstoken2", tok.as_str()); _m.assert(); + let _m = mockito::mock("POST", "/token") + .match_body(mockito::Matcher::Regex( + ".*client_id=9022167.*refresh_token=refreshtoken.*".to_string(), + )) + .with_body( + serde_json::json!({ + "access_token": "accesstoken3", + "token_type": "Bearer", + "expires_in": 59, + }) + .to_string(), + ) + .expect(1) + .create(); + + let tok = auth + .token(&["https://googleapis.com/some/scope"]) + .await + .expect("failed to get token"); + assert_eq!("accesstoken3", tok.as_str()); + _m.assert(); + let _m = mockito::mock("POST", "/token") .match_body(mockito::Matcher::Regex( ".*client_id=9022167.*refresh_token=refreshtoken.*".to_string(),