From 249e8f3e612c3bd47b7c4770cc7875c97c428bf7 Mon Sep 17 00:00:00 2001 From: Qingchuan Ma Date: Fri, 23 Sep 2022 10:03:31 -0700 Subject: [PATCH 1/3] Only do logging when it's internal --- .../combination/test_api_with_authorizers.py | 4 ++-- integration/helpers/base_test.py | 24 ++++++++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/integration/combination/test_api_with_authorizers.py b/integration/combination/test_api_with_authorizers.py index a34ef62589..4d44d54124 100644 --- a/integration/combination/test_api_with_authorizers.py +++ b/integration/combination/test_api_with_authorizers.py @@ -436,10 +436,10 @@ def verify_authorized_request( header_value=None, ): if not header_key or not header_value: - response = BaseTest.do_get_request_with_logging(url) + response = self.do_get_request_with_logging(url) else: headers = {header_key: header_value} - response = BaseTest.do_get_request_with_logging(url, headers) + response = self.Test.do_get_request_with_logging(url, headers) status = response.status_code if status != expected_status_code: diff --git a/integration/helpers/base_test.py b/integration/helpers/base_test.py index c741639a93..e4985b93b2 100644 --- a/integration/helpers/base_test.py +++ b/integration/helpers/base_test.py @@ -64,8 +64,12 @@ def s3_bucket(self, get_s3): def case_name(self, request): self.testcase = request.node.name + @pytest.fixture(autouse=True) + def internal_check(self, check_internal): + self.internal = check_internal + @classmethod - @pytest.mark.usefixtures("get_prefix", "get_stage", "check_internal", "parameter_values", "get_s3") + @pytest.mark.usefixtures("get_prefix", "get_stage", "check_internal", "parameter_values", "get_s3", "check_internal") def setUpClass(cls): cls.FUNCTION_OUTPUT = "hello" cls.tests_integ_dir = Path(__file__).resolve().parents[1] @@ -560,10 +564,11 @@ def do_get_request_with_logging(self, url, headers=None): """ response = requests.get(url, headers=headers) if headers else requests.get(url) amazon_headers = RequestUtils(response).get_amazon_headers() - REQUEST_LOGGER.info( - "Request made to " + url, - extra={"test": self.testcase, "status": response.status_code, "headers": amazon_headers}, - ) + if self.internal: + REQUEST_LOGGER.info( + "Request made to " + url, + extra={"test": self.testcase, "status": response.status_code, "headers": amazon_headers}, + ) return response def do_options_request_with_logging(self, url, headers=None): @@ -578,8 +583,9 @@ def do_options_request_with_logging(self, url, headers=None): """ response = requests.options(url, headers=headers) if headers else requests.options(url) amazon_headers = RequestUtils(response).get_amazon_headers() - REQUEST_LOGGER.info( - "Request made to " + url, - extra={"test": self.testcase, "status": response.status_code, "headers": amazon_headers}, - ) + if self.internal: + REQUEST_LOGGER.info( + "Request made to " + url, + extra={"test": self.testcase, "status": response.status_code, "headers": amazon_headers}, + ) return response From 54f3d5e38bd43857f8038a1a8d6069801da46732 Mon Sep 17 00:00:00 2001 From: Qingchuan Ma Date: Fri, 23 Sep 2022 10:23:29 -0700 Subject: [PATCH 2/3] Black reformatting --- integration/helpers/base_test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integration/helpers/base_test.py b/integration/helpers/base_test.py index e4985b93b2..f1015d6b36 100644 --- a/integration/helpers/base_test.py +++ b/integration/helpers/base_test.py @@ -69,7 +69,9 @@ def internal_check(self, check_internal): self.internal = check_internal @classmethod - @pytest.mark.usefixtures("get_prefix", "get_stage", "check_internal", "parameter_values", "get_s3", "check_internal") + @pytest.mark.usefixtures( + "get_prefix", "get_stage", "check_internal", "parameter_values", "get_s3", "check_internal" + ) def setUpClass(cls): cls.FUNCTION_OUTPUT = "hello" cls.tests_integ_dir = Path(__file__).resolve().parents[1] From ccb099cbb3d92112ba642d963458aeaf1895d3e5 Mon Sep 17 00:00:00 2001 From: Qingchuan Ma Date: Fri, 23 Sep 2022 10:26:34 -0700 Subject: [PATCH 3/3] Fix typo --- integration/combination/test_api_with_authorizers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/combination/test_api_with_authorizers.py b/integration/combination/test_api_with_authorizers.py index 4d44d54124..26780c0a70 100644 --- a/integration/combination/test_api_with_authorizers.py +++ b/integration/combination/test_api_with_authorizers.py @@ -439,7 +439,7 @@ def verify_authorized_request( response = self.do_get_request_with_logging(url) else: headers = {header_key: header_value} - response = self.Test.do_get_request_with_logging(url, headers) + response = self.do_get_request_with_logging(url, headers) status = response.status_code if status != expected_status_code: