MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / read_gcloud_adc_parses_user_creds

Function read_gcloud_adc_parses_user_creds

crates/openshell-cli/src/run.rs:9179–9200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9177
9178 #[test]
9179 fn read_gcloud_adc_parses_user_creds() {
9180 let _lock = TEST_ENV_LOCK
9181 .lock()
9182 .unwrap_or_else(std::sync::PoisonError::into_inner);
9183 let tmp = tempfile::NamedTempFile::new().expect("tempfile");
9184 let json = serde_json::json!({
9185 "type": "authorized_user",
9186 "client_id": "test-client-id.apps.googleusercontent.com",
9187 "client_secret": "test-client-secret",
9188 "refresh_token": "test-refresh-token"
9189 });
9190 Write::write_all(&mut tmp.as_file(), json.to_string().as_bytes()).expect("write tempfile");
9191 let _guard = EnvVarGuard::set(
9192 "GOOGLE_APPLICATION_CREDENTIALS",
9193 tmp.path().to_str().expect("tempfile path"),
9194 );
9195 let (client_id, client_secret, refresh_token) =
9196 super::read_gcloud_adc().expect("valid ADC should parse");
9197 assert_eq!(client_id, "test-client-id.apps.googleusercontent.com");
9198 assert_eq!(client_secret, "test-client-secret");
9199 assert_eq!(refresh_token, "test-refresh-token");
9200 }
9201
9202 #[test]
9203 fn read_gcloud_adc_uses_cloudsdk_config_fallback() {

Callers

nothing calls this directly

Calls 3

write_allFunction · 0.85
read_gcloud_adcFunction · 0.85
pathMethod · 0.80

Tested by

no test coverage detected