-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
use snapshots for SNS tests #6601
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
Changes from 1 commit
3318c00
41d4935
9fe2785
5f6f684
0883522
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,10 @@ def sqs_api(): | |
""" | ||
return [ | ||
TransformerUtility.key_value("ReceiptHandle"), | ||
TransformerUtility.key_value("SenderId"), | ||
# account ID | ||
TransformerUtility.key_value( | ||
"SenderId", value_replacement="111111111111", reference_replacement=False | ||
), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had a similar issue in #6603. It seems related to the the fact that the Any idea what a good pattern is for this @steffyP @dominikschubert ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @thrau: Interesting :) I think a key-value replacement should be fine in that case. We could also include a regex-check to make sure it matches one of the two valid patterns. but seems like a overhead in that case. Only thing that feels a bit hacky here: if we replace it with 1s, one could assume that the region-regex-replacement was used here - which is not the case. @bentsku is there a particular reason why you have chosen this value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #6601 (review) |
||
TransformerUtility.jsonpath("$..MessageAttributes.RequestID.StringValue", "request-id"), | ||
KeyValueBasedTransformer(_resource_name_transformer, "resource"), | ||
] | ||
|
@@ -184,18 +187,15 @@ def sns_api(): | |
:return: array with Transformers, for sns api. | ||
""" | ||
return [ | ||
TransformerUtility.key_value("SequenceNumber"), # this might need to be in SQS | ||
TransformerUtility.key_value( | ||
"Signature", value_replacement="<signature>", reference_replacement=False | ||
), | ||
# maybe need check why hashes are different | ||
TransformerUtility.key_value( | ||
"MD5OfMessageAttributes", | ||
value_replacement="<md5-hash>", | ||
reference_replacement=False, | ||
), | ||
TransformerUtility.key_value("MD5OfBody", "<md5-hash>", reference_replacement=False), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we not maybe leave this in per default? or are you having issues with bodies containing data that is dynamically generated by the tests? (like passing ARNs through a message body). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The MD5 hash almost never matches: the body of the SNS message always contains a timestamp, and a signature. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alright :) i think in that case, having unittests should be fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it could work as well. The issue also that I didn't think about is that in some tests, we have both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see :) yes, sounds good. but I think it would also be fine to cover the md5-checksum in unittests as you suggested before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The md5 is part of SQS, and is covered inside the integration tests there, there shouldn't be any regression on that side. |
||
KeyValueBasedTransformer(_sns_unsubscribe_url_token_transformer, replacement="token"), | ||
KeyValueBasedTransformer( | ||
_sns_pem_file_token_transformer, replacement="signing-cert-file" | ||
_sns_pem_file_token_transformer, | ||
replacement="signing-cert-file", | ||
), | ||
# replaces the domain in "UnsubscribeURL" URL (KeyValue won't work as it replaces reference, and if | ||
# replace_reference is False, then it replaces the whole key | ||
|
@@ -204,13 +204,7 @@ def sns_api(): | |
RegexTransformer( | ||
r"(?<=(?i)UnsubscribeURL[\"|']:\s[\"|'])(https?.*?)(?=/\?Action=Unsubscribe)", | ||
replacement="<unsubscribe-domain>", | ||
) | ||
# TransformerUtility.regex( | ||
# re.compile( | ||
# r"(?<=(?i)UnsubscribeURL[\"|']:\s[\"|'])(https?.*?)(?=/\?Action=Unsubscribe)" | ||
# ), | ||
# replacement="<unsubscribe-domain>", | ||
# ), | ||
), | ||
] | ||
|
||
@staticmethod | ||
|
@@ -245,7 +239,7 @@ def secretsmanager_secret_id_arn(create_secret_res: CreateSecretResponse, index: | |
|
||
def _sns_pem_file_token_transformer(key: str, val: str) -> str: | ||
if isinstance(val, str) and key.lower() == "SigningCertURL".lower(): | ||
pattern = re.compile(r".*SimpleNotificationService-(.*)?\.pem") | ||
pattern = re.compile(r".*SimpleNotificationService-(.*\.pem)") | ||
match = re.match(pattern, val) | ||
if match: | ||
return match.groups()[0] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bentsku: is there a specific reason why you decided to replace the senderId with 1s? IMO it can be a bit misleading, as we also have the regex-replacement for the account-id, and on first sight it will look like the regex-replacement is responsible for this replacement.
Personally, I would prefer if we could use distinct replacements values for transformers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to test it again, but I believe the issue was that locally, the
SenderId
was replaced by 1s, and not in the tests against AWS. I'll check again, could be priorities, I need to check what the response was before transformation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now changed and simply use
reference_replacement=False
instead, as it is enough to not mess with ARN anymore