Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register disable_signing first to ensure proper usage #7358

Merged
merged 1 commit into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions awscli/customizations/globalargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ def no_sign_request(parsed_args, session, **kwargs):
if not parsed_args.sign_request:
# In order to make signing disabled for all requests
# we need to use botocore's ``disable_signing()`` handler.
session.register(
'choose-signer', disable_signing, unique_id='disable-signing')
# Register this first to override other handlers.
emitter = session.get_component('event_emitter')
emitter.register_first(
'choose-signer', disable_signing, unique_id='disable-signing',
)


def resolve_cli_connect_timeout(parsed_args, session, **kwargs):
Expand Down
13 changes: 12 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import copy
import os
import sys
import unittest

# Both nose and py.test will add the first parent directory it
# encounters that does not have a __init__.py to the sys.path. In
Expand All @@ -27,7 +28,7 @@
import botocore.model
import botocore.serialize
import botocore.validate

from botocore.compat import HAS_CRT

# A shared loader to use for classes in this module. This allows us to
# load models outside of influence of a session and take advantage of
Expand Down Expand Up @@ -323,3 +324,13 @@ def copy(self):

def __repr__(self):
return str(dict(self.items()))


def requires_crt(reason=None):
if reason is None:
reason = "Test requires awscrt to be installed"

def decorator(func):
return unittest.skipIf(not HAS_CRT, reason)(func)

return decorator
3 changes: 3 additions & 0 deletions tests/functional/s3/test_cp_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from awscli.testutils import mock
from awscli.compat import six
from tests.functional.s3 import BaseS3TransferCommandTest
from tests import requires_crt


class BufferedBytesIO(six.BytesIO):
Expand Down Expand Up @@ -1147,6 +1148,7 @@ def test_recursive_copy(self):
]
)

@requires_crt()
def test_accepts_mrap_arns(self):
mrap_arn = (
'arn:aws:s3::123456789012:accesspoint:mfzwi23gnjvgw.mrap'
Expand All @@ -1162,6 +1164,7 @@ def test_accepts_mrap_arns(self):
]
)

@requires_crt()
def test_accepts_mrap_arns_with_slash(self):
mrap_arn = (
'arn:aws:s3::123456789012:accesspoint/mfzwi23gnjvgw.mrap'
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/customizations/test_globalargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def test_no_sign_request_if_option_specified(self):
session = mock.Mock()

globalargs.no_sign_request(args, session)
session.register.assert_called_with(
emitter = session.get_component('event_emitter')
emitter.register_first.assert_called_with(
'choose-signer', disable_signing, unique_id='disable-signing')

def test_request_signed_by_default(self):
Expand Down