rustls upgrade: supply correct client in test cases

This commit is contained in:
Lewin Bormann
2022-04-18 18:39:57 -07:00
parent 32b6d8fa63
commit 378dca1148
3 changed files with 9 additions and 8 deletions

View File

@@ -28,7 +28,7 @@ required-features = ["hyper-rustls", "service_account"]
[features]
default = ["hyper-rustls", "service_account"]
service_account = ["rustls", "rustls-pemfile"]
service_account = ["hyper-rustls", "rustls", "rustls-pemfile"]
[dependencies]
anyhow = "1.0.38"

View File

@@ -325,14 +325,14 @@ impl ApplicationDefaultCredentialsAuthenticator {
pub async fn builder(
opts: ApplicationDefaultCredentialsFlowOpts,
) -> ApplicationDefaultCredentialsTypes<DefaultHyperClient> {
Self::with_client(DefaultHyperClient, opts).await
Self::with_client(opts, DefaultHyperClient).await
}
/// Use the builder pattern to deduce which model of authenticator should be used and allow providing a hyper client
#[cfg(feature = "service_account")]
pub async fn with_client<C>(
client: C,
opts: ApplicationDefaultCredentialsFlowOpts,
client: C,
) -> ApplicationDefaultCredentialsTypes<C>
where
C: HyperClientBuilder,

View File

@@ -44,7 +44,7 @@ async fn create_device_flow_auth(server: &Server) -> DefaultAuthenticator {
}
}
DeviceFlowAuthenticator::builder(app_secret)
DeviceFlowAuthenticator::with_client(app_secret, DefaultHyperClient.build_test_hyper_client())
.flow_delegate(Box::new(FD))
.device_code_url(server.url_str("/code"))
.build()
@@ -215,8 +215,9 @@ async fn create_installed_flow_auth(
}
}
let mut builder = InstalledFlowAuthenticator::builder(app_secret, method)
.flow_delegate(Box::new(FD(DefaultHyperClient.build_test_hyper_client())));
let client = DefaultHyperClient.build_test_hyper_client();
let mut builder = InstalledFlowAuthenticator::with_client(app_secret, method, client.clone())
.flow_delegate(Box::new(FD(client)));
builder = if let Some(filename) = filename {
builder.persist_tokens_to_disk(filename)
@@ -326,7 +327,7 @@ async fn create_service_account_auth(server: &Server) -> DefaultAuthenticator {
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/yup-test-sa-1%40yup-test-243420.iam.gserviceaccount.com"
});
ServiceAccountAuthenticator::builder(key)
ServiceAccountAuthenticator::with_client(key, DefaultHyperClient.build_test_hyper_client())
.build()
.await
.unwrap()
@@ -622,7 +623,7 @@ async fn test_default_application_credentials_from_metadata_server() {
let opts = ApplicationDefaultCredentialsFlowOpts {
metadata_url: Some(server.url("/token").to_string()),
};
let authenticator = match ApplicationDefaultCredentialsAuthenticator::builder(opts).await {
let authenticator = match ApplicationDefaultCredentialsAuthenticator::with_client(opts, DefaultHyperClient.build_test_hyper_client()).await {
ApplicationDefaultCredentialsTypes::InstanceMetadata(auth) => auth.build().await.unwrap(),
_ => panic!("We are not testing service account adc model"),
};