s3api: Stop upper-casing request-method for signatures

The AWS behaviour is weird: if I have my client signer always use
the casing that will be sent on the wire, I reliably get back 405s,
but if my client signer always converts to upper-case despite
sending lower-case on the wire, it's roughly a coin toss for whether
I get back a 405 or a 403 (with the string-to-sign indicating that
the server was expecting lower-case). This is true for both v2 and
v4 signatures, both in headers and in query params.

Logically, though, it seems like using what's on the wire *ought* to
be the way to go, and AWS's consistency in that case lends some
credibility.

Unfortunately, that breaks an existing functional test unless awscrt
is installed, as boto3 (or botocore? somebody) will upper-case the
request method by default, but trusts awscrt to handle things if
available. So skip the part of the test that uses a lower-cased
request method if we can't import awscrt.

Change-Id: Ia6cacc51b2744986e703469f9e5215209194de8a
This commit is contained in:
Tim Burke 2024-10-11 16:33:29 -07:00
parent 0fdb93c980
commit b2386b9947
2 changed files with 7 additions and 1 deletions

View File

@ -469,7 +469,7 @@ class SigV4Mixin(object):
#
# 1. Add verb like: GET
cr = [swob.wsgi_to_bytes(self.method.upper())]
cr = [swob.wsgi_to_bytes(self.method)]
# 2. Add path like: /
path = self._canonical_uri()

View File

@ -561,6 +561,12 @@ class TestS3ApiBucket(S3ApiBaseBoto3):
_mangle_req_method)
event_system.register('request-created.s3.CreateBucket',
_mangle_req_controller_method)
try:
import awscrt # noqa: F401
except ImportError:
raise SkipTest('lower-case request methods require awscrt for '
'proper signing (try `pip install awscrt`)')
# the method exists in the controller but deny as MethodNotAllowed
with self.assertRaises(botocore.exceptions.ClientError) as ctx:
self.conn.create_bucket(Bucket='bucket')