1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
mod credentials;
mod token;

pub use token::TokenManager;

#[cfg(test)]
mod test {
    use super::*;
    #[tokio::test]
    async fn smoke_test() {
        let scopes = ["https://www.googleapis.com/auth/cloud-platform"];
        let mut tm = TokenManager::new(scopes.as_ref()).await.unwrap();
        let now = tokio::time::Instant::now();
        loop {
            let token = tm.token().await.unwrap();
            println!("{}", token);
            assert!(reqwest::get(&format!(
                "https://www.googleapis.com/oauth2/v1/tokeninfo?access_token={}",
                token
            ))
            .await
            .is_ok());
            tokio::time::sleep(tokio::time::Duration::from_secs(360)).await;
            let dur = now.elapsed();
            if dur > tokio::time::Duration::from_secs(3600 * 2) {
                break;
            }
        }
    }
}