Mercurial > lbo > hg > async-google-apis
changeset 149:6d0b3ba8155e
test_integration: Provide client secret
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Tue, 27 Oct 2020 11:19:00 +0100 |
parents | cd12993f4895 |
children | fcf0925a91b6 |
files | test_integration/Cargo.lock test_integration/src/lib.rs |
diffstat | 2 files changed, 37 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/test_integration/Cargo.lock Tue Oct 27 11:05:36 2020 +0100 +++ b/test_integration/Cargo.lock Tue Oct 27 11:19:00 2020 +0100 @@ -1397,9 +1397,9 @@ [[package]] name = "yup-oauth2" -version = "4.1.2" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "749192b9464694a95dbaf0586e845c835b315e38d491aa2766a8477aaadb48ec" +checksum = "92ed435d48d4c834ee654443dd3330399f9656506d7477ec645df58e406a25db" dependencies = [ "base64 0.12.3", "chrono",
--- a/test_integration/src/lib.rs Tue Oct 27 11:05:36 2020 +0100 +++ b/test_integration/src/lib.rs Tue Oct 27 11:19:00 2020 +0100 @@ -1,11 +1,43 @@ mod integration_test_v1_types; +use async_google_apis_common as agac; use integration_test_v1_types as inttest; #[cfg(test)] mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); + use super::*; + use mockito; + use tokio; + + const CLIENT_ID: &str = "myclientid.apps._dev.borgac.net"; + const CLIENT_SECRET: &str = "mysecret"; + const PROJECT_ID: &str = "integration-test-243420"; + const AUTH_PATH: &str = "/oauth2/"; + const TOKEN_PATH: &str = "/token/"; + + fn url_for_path(path: &str) -> String { + if path.starts_with("/") { + return mockito::server_url() + path; + } + return mockito::server_url() + "/" + path; + } + + async fn read_client_secret() -> agac::yup_oauth2::ApplicationSecret { + let mut appsec = agac::yup_oauth2::read_application_secret("client_secret.json") + .await + .unwrap(); + appsec.client_id = CLIENT_ID.into(); + appsec.client_secret = CLIENT_SECRET.into(); + appsec.project_id = Some(PROJECT_ID.into()); + appsec.auth_uri = url_for_path(AUTH_PATH); + appsec.token_uri = url_for_path(TOKEN_PATH); + appsec.auth_provider_x509_cert_url = None; + appsec + } + + #[tokio::test] + async fn it_works() { + println!("{}", mockito::server_url()); + println!("{:?}", read_client_secret().await); } }