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

Feat add Aurora DSQL token generator #2929

Merged
merged 10 commits into from
Dec 13, 2024
Merged

Feat add Aurora DSQL token generator #2929

merged 10 commits into from
Dec 13, 2024

Conversation

Madrigal
Copy link
Contributor

@Madrigal Madrigal commented Dec 9, 2024

Add Aurora DSQL token generator.

Followup from #2925

@Madrigal Madrigal requested a review from a team as a code owner December 9, 2024 23:19
{
"id": "96240bbb-6b53-41a0-a5e4-0055b0222be0",
"type": "release",
"description": "Add DSQL Auth Token Generator",
Copy link

Choose a reason for hiding this comment

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

nit

Suggested change
"description": "Add DSQL Auth Token Generator",
"description": "Add Aurora DSQL Auth Token Generator",

.changelog/96240bbb6b5341a0a5e40055b0222be0.json Outdated Show resolved Hide resolved
feature/dsql/token/CHANGELOG.md Outdated Show resolved Hide resolved
)

const (
rdsClusterTokenID = "dsql"
Copy link

Choose a reason for hiding this comment

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

This is actually vendor code

Suggested change
rdsClusterTokenID = "dsql"
vendorCode = "dsql"

func TestGenerateDbConnectAuthToken(t *testing.T) {
cases := map[string]dbTokenTestCase{
"no region": {
endpoint: "https://prod-instance.us-east-1.rds.amazonaws.com:3306",
Copy link

Choose a reason for hiding this comment

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

Aurora DSQLs endpoints dont need to have schema (https / http) and the port information. Also the endpoints are dual stack only. An example format is this.

Suggested change
endpoint: "https://prod-instance.us-east-1.rds.amazonaws.com:3306",
endpoint: "foo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",

Same goes for other examples below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the endpoints to reflect this endpoint. I added them with scheme as well to make sure we handle this case as well and strip the scheme if passed by the developer

feature/dsql/token/auth_token_generator.go Outdated Show resolved Hide resolved
//
// This is the admin user variant, see [GenerateDbConnectAuthToken] for the regular user variant
//
// * endpoint - Endpoint is the hostname and optional port to connect to the database
Copy link

Choose a reason for hiding this comment

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

port is not needed

Suggested change
// * endpoint - Endpoint is the hostname and optional port to connect to the database
// * endpoint - Endpoint is the hostname to connect to the database

feature/dsql/token/auth_token_generator.go Outdated Show resolved Hide resolved
},
"no endpoint": {
region: "us-west-2",
expectedError: "port",
Copy link

Choose a reason for hiding this comment

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

do we validate port? For Aurora DSQL, port is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do not. Good part of these tests are based on what we have for RDS, which has a similar feature https://aws.github.io/aws-sdk-go-v2/docs/sdk-utilities/rds/

The tests are ported from this feature. There, we check the string for an exact match on the error string. Here, we check if an error was thrown, and we just print "expected to get an error X".

I'll change this to be a bit more explicit to say we don't check for port.

feature/dsql/token/auth_token_generator_test.go Outdated Show resolved Hide resolved
.changelog/96240bbb6b5341a0a5e40055b0222be0.json Outdated Show resolved Hide resolved
feature/dsql/auth/auth_token_generator_test.go Outdated Show resolved Hide resolved
expectedError: "endpoint is required",
},
"endpoint with scheme": {
endpoint: "https://oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws:3306",

Choose a reason for hiding this comment

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

Suggested change
endpoint: "https://oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws:3306",
endpoint: "https://foo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",

"endpoint with scheme": {
endpoint: "https://oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws:3306",
region: "us-east-1",
expectedHost: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws:3306",

Choose a reason for hiding this comment

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

Suggested change
expectedHost: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws:3306",
expectedHost: "foo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",

expectedQueryParams: []string{"Action=DbConnect"},
},
"endpoint without scheme": {
endpoint: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws:3306",

Choose a reason for hiding this comment

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

Suggested change
endpoint: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws:3306",
endpoint: "foo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",

"endpoint without scheme": {
endpoint: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws:3306",
region: "us-east-1",
expectedHost: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws:3306",

Choose a reason for hiding this comment

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

Suggested change
expectedHost: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws:3306",
expectedHost: "foo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",

expectedQueryParams: []string{"Action=DbConnect"},
},
"endpoint without port": {
endpoint: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",

Choose a reason for hiding this comment

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

Suggested change
endpoint: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",
endpoint: "foo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",

"endpoint without port": {
endpoint: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",
region: "us-east-1",
expectedHost: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",

Choose a reason for hiding this comment

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

Suggested change
expectedHost: "oo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",
expectedHost: "foo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws",

@@ -0,0 +1,4 @@
# v1.0.0 (2024-12-09)
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to remove this. When make release runs, it'll slurp your .changelog entry and transform it into CHANGELOG.md content (which is expected) - but since you already have the message here it'll be duped:

  1 # v1.0.0 (2024-12-13)
  2 
  3 * **Release**: Add Aurora DSQL Auth Token Generator
  4 
  5 # v1.0.0 (2024-12-09)
  6 
  7 * **Release**: Add Aurora DSQL Auth Token Generator
  8 

@Madrigal Madrigal merged commit 6688b18 into main Dec 13, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants