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.
This commit is contained in:
Glenn Griffin
2019-11-29 15:31:41 -08:00
parent 36d186deb4
commit 6817fce0bc

View File

@@ -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(),