test(storage): add comprehensive file operation tests#130
Merged
Conversation
…googleapis-storage-sign
…ons` This commit introduces two new properties to `StorageOptions`: - `credentials`: Allows passing service account credentials directly as an object. - `keyFilename`: Allows specifying a path to a service account JSON key file. This provides more explicit ways to configure authentication, alongside the existing `authClient` option and Application Default Credentials (ADC). The authentication client initialization logic has been updated to prioritize credentials in the following order: `authClient`, `credentials`, `keyFilename`, and finally ADC.
…tream validation - Refactor HmacKey tests to allow null and empty projectId, and verify correct metadata assignment - Update error expectations to use ArgumentError and consistent error messages - Enhance hash_stream_validator tests to use stream.drain and explicit error assertions - Wrap integration and endpoint tests in runZoned to isolate environment variables
…googleapis-storage-sign
…ionality - Add `storage_example.dart` demonstrating basic usage and signed URL generation - Update `main.dart` to include storage example - Add end-to-end tests for signed URL upload, download, and expiration in `file_integration_test.dart` - Update integration tests to use production bucket name
- Implement Storage service with singleton pattern and FirebaseApp integration - Add support for Firebase Storage emulator via FIREBASE_STORAGE_EMULATOR_HOST - Introduce EmulatorClient to handle emulator authentication - Update environment utilities for Storage emulator detection and configuration - Enhance Service class to manage emulator and production clients, including proper termination - Refactor storage example to use new Storage service API - Update exports and imports for new storage structure - Add emulator configuration to run_with_emulator.sh - Improve resumable upload handling for emulator compatibility
Adds a new `Storage` service to the Firebase Admin SDK. This service provides an interface to Google Cloud Storage. Key features: - Integration with the Firebase Storage emulator via `FIREBASE_STORAGE_EMULATOR_HOST`. - `app.storage()` method to access the storage service. - Unit and integration tests for the new service.
…irebase_admin into admin-storage-wrapper
…e emulator bucket test docs
…s class - Replace custom Credentials class with GoogleCredential from googleapis_auth_utils - Update StorageOptions to accept GoogleCredential directly - Remove keyFilename and related logic in favor of unified credential handling - Refactor integration and unit tests to use GoogleCredential.fromServiceAccount - Update imports to use package aliases for clarity - Increase delay in integration tests to improve consistency
…AccountParams method
…irebase_admin into admin-storage-wrapper
Adds a full suite of unit tests for the `File` class, covering core operations, metadata handling, and access control. This includes tests for: - `getMetadata` - `setMetadata` - `delete` - `exists` - `get` - `copy` - `move` - `rename` - `makePublic` - `makePrivate` - `publicUrl` - `getSignedUrl` The tests use a mock-based setup to verify API interactions, option passing (like `userProject` and preconditions), and correct handling of both success and error responses from the underlying storage API.
Coverage Report✅ Coverage 63.61% meets 40% threshold Total Coverage: 63.61% Package Breakdown
Minimum threshold: 40% |
Introduces `StorageHttpClient`, a custom `http.BaseClient` that directs traffic to one of two underlying clients based on the request URL. This change is necessary because: - OAuth and token requests require automatic decompression to handle JSON responses. - Google Cloud Storage API requests need decompression disabled to allow for manual data integrity checks (like CRC32C). The new client is now used as the base client for authentication and subsequent API calls.
…ms and gzip decompression
- Add integration tests for `makePublic`, `makePrivate`, `publicUrl`, and `get` methods on `BucketFile`
- Add comprehensive unit tests for `createWriteStream` covering:
- Resumable and simple upload configurations
- Content-type detection and manual overrides
- Gzip compression logic (auto-detection and explicit settings)
- Precondition and validation options (CRC32C, MD5)
- Metadata and ACL handling (`private`, `public`, `predefinedAcl`)
- HTTP-level behavior including progress reporting, metadata updates, and error handling
- Improve test coverage for upload URI handling and project-based billing options
…ptionKey, and createResumableUpload methods
…admin-storage-wrapper
…, and cloud tasks - Introduce Environment class for type-safe emulator host retrieval - Refactor storage, auth, and cloud tasks clients to use Environment methods - Update tests to use Environment constants for emulator host
…ebase_admin into storage-file-test
Ehesp
reviewed
Jan 28, 2026
packages/googleapis_storage/lib/src/internal/storage_http_client.dart
Outdated
Show resolved
Hide resolved
…ploads - Implement File.generateSignedPostPolicyV2 and File.generateSignedPostPolicyV4 methods - Add types for signed POST policy options and outputs - Provide argument validation and error handling for policy generation - Add integration and unit tests for signed POST policy methods
…tore, isPublic, and getExpirationDate methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds comprehensive integration and unit tests for
BucketFileoperationsChanges
StorageHttpClientthat routes requests based on compression needs:createWriteStream)