From e2aaaaa98431be52d4c2609c88bb615bf3fba96f Mon Sep 17 00:00:00 2001 From: Bohdan Kuzema Date: Thu, 7 Nov 2019 15:43:13 +0200 Subject: [PATCH 1/5] [iss-167] X-RAY creates new session, added empty creds for botocore version before `signature_version=UNSIGNED` --- aws_xray_sdk/core/sampling/connector.py | 3 ++- tests/test_recorder.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/aws_xray_sdk/core/sampling/connector.py b/aws_xray_sdk/core/sampling/connector.py index 7c3bad5a..b8e288fe 100644 --- a/aws_xray_sdk/core/sampling/connector.py +++ b/aws_xray_sdk/core/sampling/connector.py @@ -160,5 +160,6 @@ def _create_xray_client(self, ip='127.0.0.1', port='2000'): url = 'http://%s:%s' % (ip, port) return session.create_client('xray', endpoint_url=url, region_name='us-west-2', - config=Config(signature_version=UNSIGNED) + config=Config(signature_version=UNSIGNED), + aws_access_key_id='', aws_secret_access_key='' ) diff --git a/tests/test_recorder.py b/tests/test_recorder.py index 76c9415c..f2b6aa74 100644 --- a/tests/test_recorder.py +++ b/tests/test_recorder.py @@ -1,4 +1,5 @@ import platform +from unittest.mock import patch import pytest @@ -10,7 +11,9 @@ from aws_xray_sdk.core.models.subsegment import Subsegment from aws_xray_sdk.core.models.dummy_entities import DummySegment, DummySubsegment -xray_recorder = get_new_stubbed_recorder() +with patch("aws_xray_sdk.core.sampling.connector.botocore.session.Session.get_credentials") as get_credentials: + xray_recorder = get_new_stubbed_recorder() + assert not get_credentials.called @pytest.fixture(autouse=True) From 4009c6b0093f1e9636dbb2831d57afa29351c582 Mon Sep 17 00:00:00 2001 From: Bohdan Kuzema Date: Thu, 7 Nov 2019 16:55:45 +0200 Subject: [PATCH 2/5] [iss-167] X-RAY creates new session, added empty creds for botocore version before `signature_version=UNSIGNED` --- setup.py | 4 ++++ tests/test_recorder.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fbd4fa69..e160fadf 100644 --- a/setup.py +++ b/setup.py @@ -49,6 +49,10 @@ 'botocore>=1.11.3', ], + tests_require=[ + 'mock;python_version<"3.3"', + ], + keywords='aws xray sdk', packages=find_packages(exclude=['tests*']), diff --git a/tests/test_recorder.py b/tests/test_recorder.py index f2b6aa74..dbbcbd11 100644 --- a/tests/test_recorder.py +++ b/tests/test_recorder.py @@ -1,5 +1,8 @@ import platform -from unittest.mock import patch +try: + from unittest.mock import patch +except ImportError: + from mock import patch import pytest From 52eb3037b1e500b0f0c08f6adeb94e6aed7dd20f Mon Sep 17 00:00:00 2001 From: Bohdan Kuzema Date: Thu, 7 Nov 2019 17:10:58 +0200 Subject: [PATCH 3/5] [iss-167] X-RAY creates new session, added empty creds for botocore version before `signature_version=UNSIGNED` --- setup.py | 4 ---- tox.ini | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/setup.py b/setup.py index e160fadf..fbd4fa69 100644 --- a/setup.py +++ b/setup.py @@ -49,10 +49,6 @@ 'botocore>=1.11.3', ], - tests_require=[ - 'mock;python_version<"3.3"', - ], - keywords='aws xray sdk', packages=find_packages(exclude=['tests*']), diff --git a/tox.ini b/tox.ini index 9bcd2223..8141f4e7 100644 --- a/tox.ini +++ b/tox.ini @@ -27,6 +27,7 @@ deps = # Python2 only deps py{27}: enum34 + py{27}: mock # Python3.5+ only deps py{35,36,37}: aiohttp >= 3.0.0 From 8036f49604076684e2f0dec9787fbacb3a868aee Mon Sep 17 00:00:00 2001 From: Bohdan Kuzema Date: Thu, 21 Nov 2019 17:40:11 +0200 Subject: [PATCH 4/5] [iss-167] X-RAY creates new session, added empty creds for botocore version before `signature_version=UNSIGNED` --- tests/test_recorder.py | 11 +++-------- tox.ini | 1 - 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/test_recorder.py b/tests/test_recorder.py index dbbcbd11..9cfe687f 100644 --- a/tests/test_recorder.py +++ b/tests/test_recorder.py @@ -1,8 +1,4 @@ import platform -try: - from unittest.mock import patch -except ImportError: - from mock import patch import pytest @@ -14,16 +10,15 @@ from aws_xray_sdk.core.models.subsegment import Subsegment from aws_xray_sdk.core.models.dummy_entities import DummySegment, DummySubsegment -with patch("aws_xray_sdk.core.sampling.connector.botocore.session.Session.get_credentials") as get_credentials: - xray_recorder = get_new_stubbed_recorder() - assert not get_credentials.called +xray_recorder = get_new_stubbed_recorder() @pytest.fixture(autouse=True) -def construct_ctx(): +def construct_ctx(monkeypatch): """ Clean up context storage before and after each test run. """ + monkeypatch.delattr("botocore.session.Session.get_credentials") xray_recorder.configure(sampling=False) xray_recorder.clear_trace_entities() yield diff --git a/tox.ini b/tox.ini index 8141f4e7..9bcd2223 100644 --- a/tox.ini +++ b/tox.ini @@ -27,7 +27,6 @@ deps = # Python2 only deps py{27}: enum34 - py{27}: mock # Python3.5+ only deps py{35,36,37}: aiohttp >= 3.0.0 From 2efe37dcbc04222e1538971f646351164657a7ee Mon Sep 17 00:00:00 2001 From: polamayster Date: Thu, 21 Nov 2019 17:40:11 +0200 Subject: [PATCH 5/5] [iss-167] X-RAY creates new session, added empty creds for botocore version before `signature_version=UNSIGNED` --- tests/test_recorder.py | 11 +++-------- tox.ini | 1 - 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/test_recorder.py b/tests/test_recorder.py index dbbcbd11..9cfe687f 100644 --- a/tests/test_recorder.py +++ b/tests/test_recorder.py @@ -1,8 +1,4 @@ import platform -try: - from unittest.mock import patch -except ImportError: - from mock import patch import pytest @@ -14,16 +10,15 @@ from aws_xray_sdk.core.models.subsegment import Subsegment from aws_xray_sdk.core.models.dummy_entities import DummySegment, DummySubsegment -with patch("aws_xray_sdk.core.sampling.connector.botocore.session.Session.get_credentials") as get_credentials: - xray_recorder = get_new_stubbed_recorder() - assert not get_credentials.called +xray_recorder = get_new_stubbed_recorder() @pytest.fixture(autouse=True) -def construct_ctx(): +def construct_ctx(monkeypatch): """ Clean up context storage before and after each test run. """ + monkeypatch.delattr("botocore.session.Session.get_credentials") xray_recorder.configure(sampling=False) xray_recorder.clear_trace_entities() yield diff --git a/tox.ini b/tox.ini index 8141f4e7..9bcd2223 100644 --- a/tox.ini +++ b/tox.ini @@ -27,7 +27,6 @@ deps = # Python2 only deps py{27}: enum34 - py{27}: mock # Python3.5+ only deps py{35,36,37}: aiohttp >= 3.0.0