Skip to content

Comments

test(block/gs): run pre-signed URL test with fake-gcs-server#9988

Merged
skshetry merged 1 commit intomasterfrom
saugat/gs-presigned-url-unit-test
Feb 9, 2026
Merged

test(block/gs): run pre-signed URL test with fake-gcs-server#9988
skshetry merged 1 commit intomasterfrom
saugat/gs-presigned-url-unit-test

Conversation

@skshetry
Copy link
Contributor

@skshetry skshetry commented Jan 16, 2026

Closes #6347

Change Description

Background

This PR enables pre-signed URL tests to run with fake-gcs-server. Previously, these tests were skipped when no credentials were set.

To make this work, explicit signing credentials (GoogleAccessID and PrivateKey) are passed to the adapter. This workaround is necessary because:

  1. fake-gcs-server doesn't validate signatures (fsouza/fake-gcs-server#381)
  2. However, Google's SDK requires either credentials or explicit PrivateKey and GoogleAccessID to sign URLs.
  3. There's an open feature request to support emulators, but this likely can't be resolved without a private key for local signing.
    storage: signed url with STORAGE_EMULATOR_HOST get no credentials error googleapis/google-cloud-go#8634

Also adds nowFactory injection for deterministic tests, following the same pattern used in the Azure adapter.

Alternatives considered

  • Separate credentials for signing only: This approach works (similar to fsspec/gcsfs#613), but would require creating two different clients which complicates things even more.
  • Setting credentials only for signed URL tests: Some APIs end up hitting the original endpoint to fetch tokens and fail.

I'm happy to close this if the workaround feels too complicated.

Testing Details

Pre-signed URL tests now run with fake-gcs-server instead of being skipped.

Breaking Change?

No. The changes only affect test configurations.

Additional info

Related:

Add `nowFactory` injection and explicit signing credentials to enable
proper testing of GetPreSignedURL with `fake-gcs-server`. This follows
the same pattern used in the Azure adapter.

- Add WithNowFactory option to mock time.Now() for deterministic tests
- Add WithPresignedCredentials option for fake-gcs-server signing
- Remove "no credentials found" test skip workaround
- Include test RSA private key for URL signing
@skshetry skshetry marked this pull request as draft January 16, 2026 12:40
@github-actions github-actions bot added area/testing Improvements or additions to tests area/block-adapter labels Jan 16, 2026
@skshetry skshetry added exclude-changelog PR description should not be included in next release changelog minor-change Used for PRs that don't require issue attached labels Jan 16, 2026
@skshetry skshetry marked this pull request as ready for review February 5, 2026 06:33
@skshetry skshetry requested a review from a team February 5, 2026 06:33
@skshetry skshetry self-assigned this Feb 5, 2026
Copy link
Contributor

@itaigilo itaigilo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, very nice.

nowFactory func() time.Time
// presignedGoogleAccessID and presignedPrivateKey are used for testing with fake-gcs-server
// which requires explicit signing credentials since the test client has no credentials
presignedGoogleAccessID string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I don't think you should name vars with Google in a gs package,
I think that presignedAccessID should be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SignedURLOptions in google sdk has Google in the name, so here we are only adding a prefix presigned to those options.

// Use explicit signing credentials if provided (for testing with fake-gcs-server)
if a.presignedGoogleAccessID != "" && len(a.presignedPrivateKey) > 0 {
opts.GoogleAccessID = a.presignedGoogleAccessID
opts.PrivateKey = a.presignedPrivateKey
}

@skshetry skshetry merged commit 65c45ca into master Feb 9, 2026
93 of 97 checks passed
@skshetry skshetry deleted the saugat/gs-presigned-url-unit-test branch February 9, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/block-adapter area/testing Improvements or additions to tests claude-code-assisted exclude-changelog PR description should not be included in next release changelog minor-change Used for PRs that don't require issue attached

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report pre-signed URL expiry on Azure, GCS

2 participants