Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Unquote secret access when calling sqs (#10076)
Tomasz Szymański3ac9714b5063
diff --git a/saleor/plugins/webhook/tasks.py b/saleor/plugins/webhook/tasks.pyindex 835e799a7e..132cf7f400 100644--- a/saleor/plugins/webhook/tasks.py+++ b/saleor/plugins/webhook/tasks.py@@ -4,7 +4,7 @@ from dataclasses import dataclassfrom enum import Enumfrom json import JSONDecodeErrorfrom typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Type-from urllib.parse import urlparse, urlunparse+from urllib.parse import unquote, urlparse, urlunparseimport boto3import requests@@ -228,7 +228,9 @@ def send_webhook_using_aws_sqs(target_url, message, domain, signature, event_typ"sqs",region_name=region,aws_access_key_id=parts.username,- aws_secret_access_key=parts.password,+ aws_secret_access_key=(+ unquote(parts.password) if parts.password else parts.password+ ),)queue_url = urlunparse(("https", parts.hostname, parts.path, parts.params, parts.query, parts.fragment)diff --git a/saleor/plugins/webhook/tests/test_webhook_protocols.py b/saleor/plugins/webhook/tests/test_webhook_protocols.pyindex 594850bfd8..765c2508e7 100644--- a/saleor/plugins/webhook/tests/test_webhook_protocols.py+++ b/saleor/plugins/webhook/tests/test_webhook_protocols.py@@ -71,6 +71,13 @@ def test_trigger_webhooks_with_aws_sqs(mocked_client.send_message.assert_called_once_with(**expected_call_args)+ "secret_key, unquoted_secret",+ [+ ("secret_access", "secret_access"),+ ("secret%2B%2Faccess", "secret+/access"),+ ],+)def test_trigger_webhooks_with_aws_sqs_and_secret_key(webhook,order_with_lines,@@ -78,6 +85,8 @@ def test_trigger_webhooks_with_aws_sqs_and_secret_key(permission_manage_users,permission_manage_products,monkeypatch,+ secret_key,+ unquoted_secret,):mocked_client = MagicMock(spec=AsyncSQSConnection)mocked_client.send_message.return_value = {"example": "response"}@@ -90,14 +99,13 @@ def test_trigger_webhooks_with_aws_sqs_and_secret_key(webhook.app.permissions.add(permission_manage_orders)access_key = "access_key_id"- secret_key = "secret_access"region = "us-east-1"webhook.target_url = (f"awssqs://{access_key}:{secret_key}@sqs.{region}.amazonaws.com/account_id/"f"queue_name")- webhook.secret_key = "secret_key"+ webhook.secret_key = "secret+/access"webhook.save()expected_data = serialize("json", [order_with_lines])@@ -113,7 +121,7 @@ def test_trigger_webhooks_with_aws_sqs_and_secret_key("sqs",region_name=region,aws_access_key_id=access_key,- aws_secret_access_key=secret_key,+ aws_secret_access_key=unquoted_secret,)mocked_client.send_message.assert_called_once_with(QueueUrl="https://sqs.us-east-1.amazonaws.com/account_id/queue_name",