Skip to content

Implement host and CN resolution#6802

Merged
dagnir merged 3 commits intofeature/master/sns-message-managerfrom
dongie/sns-host-provider
Mar 18, 2026
Merged

Implement host and CN resolution#6802
dagnir merged 3 commits intofeature/master/sns-message-managerfrom
dongie/sns-host-provider

Conversation

@dagnir
Copy link
Contributor

@dagnir dagnir commented Mar 17, 2026

Motivation and Context

SnsHostProvider implements the logic to determine the SNS endpoint for a given region, as well as the expected common name of a signing certificate used by SNS in that region.

Both pieces of information used to ensure that the certificate we use to verify the message signature is legitimate.

Modifications

Testing

New unit tests.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@dagnir dagnir requested a review from a team as a code owner March 17, 2026 19:29
assertThat(paramsCaptor.getValue().region()).isEqualTo(region);
}

private static Stream<CommonNameTestCase> commonNameTestCases() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ported from the v1 manager tests.

return commonName;
}

private String signingCertCommonNameInternal() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

// opt-in regions
new CommonNameTestCase("me-south-1", "sns-signing.me-south-1.amazonaws.com"),
new CommonNameTestCase("ap-east-1", "sns-signing.ap-east-1.amazonaws.com"),
new CommonNameTestCase("me-south-1", "sns-signing.me-south-1.amazonaws.com"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: seems to be dupilcate test case with line 71

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I double checked the v1 test that I copied this from and it's duplicated there too.

// e.g. 'us-gov-west-3' would match the 'aws-us-gov' partition.
// This will return the 'aws' partition if it fails to match any partition.
PartitionMetadata partitionMetadata = PartitionMetadata.of(region);
return "sns." + partitionMetadata.dnsSuffix();
Copy link
Contributor

@Fred1155 Fred1155 Mar 17, 2026

Choose a reason for hiding this comment

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

If new regions is added and not updated it here (for example we forget), this would silently produce "sns.amazonaws.com". Is this expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by added?

Copy link
Contributor

@Fred1155 Fred1155 Mar 17, 2026

Choose a reason for hiding this comment

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

If a region is added in Region.regions()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the region is in the list, it wouldn't enter this code block, it would go through the switch statement and produce sns.amazonaws.com. That's expected behavior

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. Yeh I meant to ask the behavior in the switch statement, commented on the wrong line number.

}

String regionId = region.id();

Copy link
Contributor

@Fred1155 Fred1155 Mar 17, 2026

Choose a reason for hiding this comment

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

I saw there's a TODO comment in v1:
//TODO SNS team will use a consistent pattern for certificate naming. Then remove the special handling based on region
is it worth to port this TODO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK they have implemented that pattern (same for opt-in regions) so it's not necessary.

SnsHostProvider implements the logic to determine the SNS endpoint for a
given region, as well as the expected common name of a signing
certificate used by SNS in that region.

Both pieces of information used to ensure that the certificate we use to
verify the message signature is legitimate.
@dagnir dagnir force-pushed the dongie/sns-host-provider branch from 32e8f06 to decded3 Compare March 17, 2026 22:06
dagnir added 2 commits March 17, 2026 15:07
Note: This is in codee that will be deleted.
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
34.0% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@dagnir dagnir merged commit e2b9d23 into feature/master/sns-message-manager Mar 18, 2026
26 of 32 checks passed
@dagnir dagnir deleted the dongie/sns-host-provider branch March 18, 2026 17:00
@github-actions
Copy link

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants