Skip to content

s3: Add missing port in signed hostname - #2222

Merged
micafer merged 5 commits into
apache:trunkfrom
progval:sign-port
Nov 17, 2026
Merged

micafer merged 5 commits into
apache:trunkfrom
progval:sign-port

Conversation

@progval

@progval progval commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

s3: Add missing port in signed hostname

Description

It is required when using a non-default port

Status

done

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

@micafer micafer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix!

The change looks correct: non-default ports need to be included in the Host header used for AWS Signature V4 signing.

Could you please add a regression test for get_object_cdn_url() that verifies the host value passed to _get_signature()?

Ideally, the test should cover both HTTP and HTTPS, with default and non-default ports (80, 443, 9000, and 9443).

Since this change affects signature generation, having automated coverage would help prevent regressions.

Plase also add the entry in the CHANGES file.

@progval

progval commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Could you please add a regression test for get_object_cdn_url() that verifies the host value passed to _get_signature()?

Thanks! I didn't know how to test it, but looking at the arguments of _get_signature worked nicely.

Done

Please also add the entry in the CHANGES file.

Done

PROJECT_ID_HEADER = "x-goog-project-id"

def __init__(self, user_id, key, secure=True, auth_type=None, credential_file=None, **kwargs):
def __init__(self, user_id, key, *args, auth_type=None, credential_file=None, **kwargs):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had to change this to match its superclass, otherwise host would be passed as a positional arg and interpreted as auth_type.

@micafer micafer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@micafer
micafer enabled auto-merge November 17, 2026 07:11
@codecov-commenter

codecov-commenter commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.67%. Comparing base (8a0ef62) to head (bbe40d4).
⚠️ Report is 6 commits behind head on trunk.

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk    #2222      +/-   ##
==========================================
+ Coverage   83.66%   83.67%   +0.01%     
==========================================
  Files         352      352              
  Lines       82445    82487      +42     
  Branches     8890     8901      +11     
==========================================
+ Hits        68974    69015      +41     
- Misses      10591    10592       +1     
  Partials     2880     2880              
Files with missing lines Coverage Δ
libcloud/storage/drivers/google_storage.py 91.03% <100.00%> (ø)
libcloud/storage/drivers/s3.py 89.75% <100.00%> (+0.03%) ⬆️
libcloud/test/storage/test_s3.py 94.66% <100.00%> (+0.13%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Removed unused import of pytest from test_s3.py
@micafer
micafer merged commit 4e06395 into apache:trunk Nov 17, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants