for #165: update refresh flow test

This commit is contained in:
Lewin Bormann
2022-04-08 23:27:22 -07:00
parent a1250e1728
commit 23c8053d4a

View File

@@ -446,6 +446,8 @@ async fn test_refresh() {
.expect("failed to get token");
assert_eq!("accesstoken3", tok.as_str());
// Refresh fails, but renewing the token succeeds.
// PR #165
server.expect(
Expectation::matching(all_of![
request::method_path("POST", "/token"),
@@ -458,18 +460,26 @@ async fn test_refresh() {
"error": "invalid_request",
}))),
);
server.expect(
Expectation::matching(all_of![
request::method_path("POST", "/token"),
request::body(url_decoded(all_of![
contains(("code", "authorizationcode")),
contains(("client_id", matches("^9022167"))),
]))
])
.respond_with(json_encoded(serde_json::json!({
"access_token": "accesstoken",
"refresh_token": "refreshtoken",
"token_type": "Bearer",
"expires_in": 59,
}))),
);
let tok_err = auth
.token(&["https://googleapis.com/some/scope"])
.await
.expect_err("token refresh succeeded unexpectedly");
match tok_err {
Error::AuthError(AuthError {
error: AuthErrorCode::InvalidRequest,
..
}) => {}
e => panic!("unexpected error on refresh: {:?}", e),
}
.await;
assert!(tok_err.is_ok());
}
#[tokio::test]