()
| 9226 | |
| 9227 | #[test] |
| 9228 | fn read_gcloud_adc_malformed_json_errors() { |
| 9229 | let _lock = TEST_ENV_LOCK |
| 9230 | .lock() |
| 9231 | .unwrap_or_else(std::sync::PoisonError::into_inner); |
| 9232 | let tmp = tempfile::NamedTempFile::new().expect("tempfile"); |
| 9233 | Write::write_all(&mut tmp.as_file(), b"not valid json at all {{{{") |
| 9234 | .expect("write tempfile"); |
| 9235 | let _guard = EnvVarGuard::set( |
| 9236 | "GOOGLE_APPLICATION_CREDENTIALS", |
| 9237 | tmp.path().to_str().expect("tempfile path"), |
| 9238 | ); |
| 9239 | let result = super::read_gcloud_adc(); |
| 9240 | assert!( |
| 9241 | result.is_err(), |
| 9242 | "malformed JSON should produce an error, got: {result:?}" |
| 9243 | ); |
| 9244 | let err = result.unwrap_err(); |
| 9245 | let msg = format!("{err}"); |
| 9246 | assert!( |
| 9247 | msg.contains("parse") |
| 9248 | || msg.contains("JSON") |
| 9249 | || msg.contains("json") |
| 9250 | || msg.contains("invalid") |
| 9251 | || msg.contains("failed"), |
| 9252 | "error message should mention parse/JSON failure, got: {msg}" |
| 9253 | ); |
| 9254 | } |
| 9255 | |
| 9256 | #[test] |
| 9257 | fn empty_provider_credentials_allow_oauth2_refresh_token() { |
nothing calls this directly
no test coverage detected