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

sns: add multi-account capability to failing tests #9358

Merged
merged 7 commits into from Oct 20, 2023

Conversation

sannya-singal
Copy link
Contributor

@sannya-singal sannya-singal commented Oct 17, 2023

Motivation

When using values other than 000000000000 for account ID or us-east-1 for region, sns tests should still create the consequent resources in this accounts and region.

Changes

This PR fixes all the failing tests in tests.aws.services.sns.test_sns.py by:

  • removing the use of get_aws_account_id() helper.
  • use moto internals in unsubscribe handler.
  • use parsed arn instead of context arn
  • add test cases to validate subscription_arn
  • add checks to validate subscription_arn in the handler.

See #8204

@sannya-singal sannya-singal marked this pull request as draft October 17, 2023 05:35
@sannya-singal sannya-singal self-assigned this Oct 17, 2023
@sannya-singal sannya-singal added semver: patch Non-breaking changes which can be included in patch releases aws:sns Amazon Simple Notification Service labels Oct 17, 2023
@coveralls
Copy link

coveralls commented Oct 17, 2023

Coverage Status

coverage: 83.0% (+0.01%) from 82.987% when pulling e1b8e65 on sns_multi_accounts into cc1efb8 on master.

@github-actions
Copy link

github-actions bot commented Oct 17, 2023

LocalStack Community integration with Pro

       2 files  ±0         2 suites  ±0   1h 13m 34s ⏱️ - 6m 45s
2 262 tests +8  1 687 ✔️  - 65  575 💤 +74  0  - 1 
2 263 runs  +8  1 687 ✔️  - 65  576 💤 +74  0  - 1 

Results for commit e1b8e65. ± Comparison against base commit cc1efb8.

This pull request removes 8 and adds 16 tests. Note that renamed tests count towards both.
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://allowed-False-False]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://allowed-False-True]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://allowed-True-False]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://allowed-True-True]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://denied-False-False]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://denied-False-True]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://denied-True-False]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://denied-True-True]
tests.aws.scenario.mythical_mysfits.test_mythical_misfits.TestMythicalMisfitsScenario ‑ test_deployed_infra_state
tests.aws.scenario.mythical_mysfits.test_mythical_misfits.TestMythicalMisfitsScenario ‑ test_populate_data
tests.aws.scenario.mythical_mysfits.test_mythical_misfits.TestMythicalMisfitsScenario ‑ test_user_clicks_are_stored
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://allowed-False-UrlType.HOST_BASED]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://allowed-False-UrlType.PATH_BASED]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://allowed-True-UrlType.HOST_BASED]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://allowed-True-UrlType.PATH_BASED]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://denied-False-UrlType.HOST_BASED]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://denied-False-UrlType.PATH_BASED]
tests.aws.services.apigateway.test_apigateway_basic.TestAPIGateway ‑ test_invoke_endpoint_cors_headers[http://denied-True-UrlType.HOST_BASED]
…
This pull request skips 71 tests.
tests.aws.services.lambda_.test_lambda_common.TestLambdaCallingLocalstack ‑ test_calling_localstack_from_lambda[dotnet6]
tests.aws.services.lambda_.test_lambda_common.TestLambdaCallingLocalstack ‑ test_calling_localstack_from_lambda[go1.x]
tests.aws.services.lambda_.test_lambda_common.TestLambdaCallingLocalstack ‑ test_calling_localstack_from_lambda[java11]
tests.aws.services.lambda_.test_lambda_common.TestLambdaCallingLocalstack ‑ test_calling_localstack_from_lambda[java8.al2]
tests.aws.services.lambda_.test_lambda_common.TestLambdaCallingLocalstack ‑ test_calling_localstack_from_lambda[nodejs14.x]
tests.aws.services.lambda_.test_lambda_common.TestLambdaCallingLocalstack ‑ test_calling_localstack_from_lambda[nodejs16.x]
tests.aws.services.lambda_.test_lambda_common.TestLambdaCallingLocalstack ‑ test_calling_localstack_from_lambda[nodejs18.x]
tests.aws.services.lambda_.test_lambda_common.TestLambdaCallingLocalstack ‑ test_calling_localstack_from_lambda[python3.10]
tests.aws.services.lambda_.test_lambda_common.TestLambdaCallingLocalstack ‑ test_calling_localstack_from_lambda[python3.11]
tests.aws.services.lambda_.test_lambda_common.TestLambdaCallingLocalstack ‑ test_calling_localstack_from_lambda[python3.7]
…

♻️ This comment has been updated with latest results.

@sannya-singal sannya-singal changed the title sns: add multi-account capability sns: add multi-account capability to failing tests Oct 18, 2023
@sannya-singal sannya-singal marked this pull request as ready for review October 18, 2023 08:43
Copy link
Contributor

@bentsku bentsku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for tackling this, this put a bug into light with Unsubscribe!
I explained the issue that needs fixing in the comment regarding modifying the test, I'm really sorry that it's a tricky test to validate. I don't think we'll need to change it anyway, the fix will live in Unsubscribe.

tests/aws/services/sns/test_sns.py Outdated Show resolved Hide resolved
@thrau thrau removed their request for review October 18, 2023 23:31
Copy link
Contributor

@bentsku bentsku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for changing and fixing Unsubscribe! It would be nice if we could have an AWS validated test for the exception regarding the ARN, I know we didn't before and we relied on moto, but maybe the exception wasn't right. Would be good to check now that it's our responsibility 😄 after that it'll be good for me!

localstack/services/sns/provider.py Outdated Show resolved Hide resolved
localstack/services/sns/provider.py Show resolved Hide resolved
Copy link
Contributor

@bentsku bentsku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Awesome, thanks a lot, sorry for the requested changes, but this looks awesome now, thanks a lot for fixing an SNS bug 🐛🚀!

@sannya-singal sannya-singal merged commit 05a52a1 into master Oct 20, 2023
27 checks passed
@sannya-singal sannya-singal deleted the sns_multi_accounts branch October 20, 2023 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:sns Amazon Simple Notification Service semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants