Commit e096127
authored
fix: fail-fast on missing ECP config file to avoid 30s hang (#17377)
This PR resolves two issues in the `google-auth` package:
First, it adds a fast-fail check for ECP configuration. When the
`GOOGLE_API_CERTIFICATE_CONFIG` environment variable is set but the
configuration file is missing (common on corporate workstations or clean
sandbox test runners), the SDK was falling through to the well-known
SPIFFE path and waiting on a 30-second retry loop. We now check if the
config path is set but missing, and if we are not in a workload
environment (the well-known credentials directory is absent), we
immediately return `None` to fallback to unbound tokens. (Fixes
b/512912028)
Second, it fixes an incorrect mock in `test_mtls.py`.
`test_default_client_encrypted_cert_source` was mocking `open` in the
test namespace instead of the target module namespace. This caused the
test to write actual `cert_path` and `key_path` files to the local disk
during test runs. This is fixed by patching
`google.auth.transport.mtls.open`.
Unit tests have been added to verify the fast-fail behavior, and
existing retry tests have been updated to mock the workload directory.
All tests now pass without writing files to disk.1 parent 3f70b2f commit e096127Copy full SHA for e096127
3 files changed
+44-3Lines changed: 44 additions & 3 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- packages/google-auth
- google/auth
- tests
- transport
Expand file treeCollapse file tree
Open diff view settings
Collapse file
packages/google-auth/google/auth/_agent_identity_utils.py
Copy file name to clipboardExpand all lines: packages/google-auth/google/auth/_agent_identity_utils.py+8Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
89 | 89 | |
90 | 90 | |
91 | 91 | |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
92 | 100 | |
93 | 101 | |
94 | 102 | |
|
Collapse file
packages/google-auth/tests/test_agent_identity_utils.py
Copy file name to clipboardExpand all lines: packages/google-auth/tests/test_agent_identity_utils.py+33-2Lines changed: 33 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
165 | 165 | |
166 | 166 | |
167 | 167 | |
| 168 | + |
168 | 169 | |
169 | | - |
| 170 | + |
170 | 171 | |
171 | 172 | |
172 | 173 | |
173 | 174 | |
174 | 175 | |
175 | 176 | |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | + |
| 181 | + |
| 182 | + |
| 183 | + |
| 184 | + |
176 | 185 | |
177 | 186 | |
178 | 187 | |
179 | 188 | |
180 | 189 | |
181 | 190 | |
182 | 191 | |
| 192 | + |
183 | 193 | |
184 | | - |
| 194 | + |
185 | 195 | |
186 | 196 | |
187 | 197 | |
188 | 198 | |
189 | 199 | |
190 | 200 | |
| 201 | + |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | + |
191 | 209 | |
192 | 210 | |
193 | 211 | |
| ||
198 | 216 | |
199 | 217 | |
200 | 218 | |
| 219 | + |
| 220 | + |
| 221 | + |
| 222 | + |
| 223 | + |
| 224 | + |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | + |
| 229 | + |
| 230 | + |
| 231 | + |
201 | 232 | |
202 | 233 | |
203 | 234 | |
|
Collapse file
packages/google-auth/tests/transport/test_mtls.py
Copy file name to clipboardExpand all lines: packages/google-auth/tests/transport/test_mtls.py+3-1Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
154 | 154 | |
155 | 155 | |
156 | 156 | |
157 | | - |
| 157 | + |
158 | 158 | |
| 159 | + |
| 160 | + |
159 | 161 | |
160 | 162 | |
161 | 163 | |
|
0 commit comments