You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor GS authentication to use default credentials (#514) (#526)
* Refactor GS authentication to use default credentials (#514)
* Refactor authentication to use default credentials for Google Cloud Storage client
This enables federated identity
Updates HISTORY.md
* Keeps same functionality for API whilst enhancing the env var alternative
* Simplifies credential handling logic, and updates docstring
* Updates HISTORY.md
---------
Co-authored-by: ljyanesm <[email protected]>
* bonus: test fixes and docs
* Mock default auth
* fix history
---------
Co-authored-by: Luis Yanes <[email protected]>
Co-authored-by: ljyanesm <[email protected]>
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+143Lines changed: 143 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,6 +110,149 @@ When the tests finish, if it is using a live server, the test files will be dele
110
110
111
111
If you want to speed up your testing during development, you may comment out some of the rigs in [`conftest.py`](tests/conftest.py). Don't commit this change, and make sure you run against all the rigs before submitting a PR.
112
112
113
+
### Test Fixtures and Rigs
114
+
115
+
The test suite uses a comprehensive set of fixtures and test rigs to ensure consistent behavior across all cloud providers. Here's a detailed overview of the available fixtures and their properties:
116
+
117
+
#### Core Fixtures
118
+
119
+
**`assets_dir`** - Path to the test assets directory containing sample files and directories used across all tests.
120
+
121
+
**`live_server`** - Boolean indicating whether to use live cloud servers (controlled by `USE_LIVE_CLOUD=1` environment variable).
122
+
123
+
**`wait_for_mkdir`** - Fixture that patches `os.mkdir` to wait for directory creation, useful for tests that are sometimes flaky due to filesystem timing.
124
+
125
+
#### Cloud Provider Test Rigs
126
+
127
+
The `CloudProviderTestRig` class is the foundation for all cloud provider testing. Each rig provides:
128
+
129
+
-**`path_class`**: The CloudPath subclass for the provider (e.g., `S3Path`, `AzureBlobPath`)
130
+
-**`client_class`**: The Client subclass for the provider (e.g., `S3Client`, `AzureBlobClient`)
131
+
-**`drive`**: The bucket/container name for the provider
132
+
-**`test_dir`**: Unique test directory name generated from session UUID, module name, and function name
133
+
-**`live_server`**: Whether the rig uses live cloud servers
-**`mock_adls_gen2.py`**: Mock Azure Data Lake Storage Gen2 client
191
+
-**`mock_gs.py`**: Mock Google Cloud Storage client
192
+
-**`mock_s3.py`**: Mock AWS S3 client
193
+
-**`utils.py`**: Utility functions for mock clients (e.g., `delete_empty_parents_up_to_root`)
194
+
195
+
#### Test Assets
196
+
197
+
Located in `tests/assets/`, the test assets provide a consistent set of files and directories:
198
+
199
+
```
200
+
tests/assets/
201
+
├── dir_0/
202
+
│ ├── file0_0.txt
203
+
│ ├── file0_1.txt
204
+
│ └── file0_2.txt
205
+
└── dir_1/
206
+
├── file_1_0.txt
207
+
└── dir_1_0/
208
+
└── file_1_0_0.txt
209
+
```
210
+
211
+
These assets are automatically copied to each test rig's directory and provide a predictable file structure for testing file operations, directory traversal, and other functionality.
212
+
213
+
#### Utility Fixtures
214
+
215
+
**`utilities_dir`**: Path to test utilities directory containing SSL certificates for HTTPS testing.
216
+
217
+
**`_sync_filesystem()`**: Utility function that forces filesystem synchronization to stabilize tests, especially important on Windows where `os.sync()` is not available.
218
+
219
+
#### Environment Variables for Live Testing
220
+
221
+
When `USE_LIVE_CLOUD=1` is set, the following environment variables control live cloud testing:
For provider-specific tests, you can check rig properties:
245
+
246
+
```python
247
+
deftest_azure_specific_feature(azure_rig):
248
+
if azure_rig.is_adls_gen2:
249
+
# Skip or test ADLS Gen2 specific behavior
250
+
pass
251
+
else:
252
+
# Test Azure Blob Storage specific behavior
253
+
pass
254
+
```
255
+
113
256
### Authoring tests
114
257
115
258
We want our test suite coverage to be comprehensive, so PRs need to add tests if they add new functionality. If you are adding a new feature, you will need to add tests for it. If you are changing an existing feature, you will need to update the tests to match the new behavior.
Copy file name to clipboardExpand all lines: HISTORY.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,13 @@
1
1
# cloudpathlib Changelog
2
2
3
+
## UNRELEASED
4
+
5
+
- Fixed issue with GS credentials, using default auth enables a wider set of authentication methods in GS (Issue [#390](https://github.com/drivendataorg/cloudpathlib/issues/390), PR [#514](https://github.com/drivendataorg/cloudpathlib/pull/514), thanks @ljyanesm)
6
+
- Added support for http(s) urls with `HttpClient`, `HttpPath`, `HttpsClient`, and `HttpsPath`. (Issue [#455](https://github.com/drivendataorg/cloudpathlib/issues/455), PR [#468](https://github.com/drivendataorg/cloudpathlib/pull/468))
7
+
3
8
## v0.21.1 (2025-05-14)
4
9
5
10
- Fixed `rmtree` fail on Azure with no `hns` and more than 256 blobs to drop (Issue [#509](https://github.com/drivendataorg/cloudpathlib/issues/509), PR [#508](https://github.com/drivendataorg/cloudpathlib/pull/508), thanks @alikefia)
6
-
- Added support for http(s) urls with `HttpClient`, `HttpPath`, `HttpsClient`, and `HttpsPath`. (Issue [#455](https://github.com/drivendataorg/cloudpathlib/issues/455), PR [#468](https://github.com/drivendataorg/cloudpathlib/pull/468))
0 commit comments