vendor: update all dependencies
This commit is contained in:
+611
-158
File diff suppressed because it is too large
Load Diff
+2480
-2231
File diff suppressed because it is too large
Load Diff
+8
@@ -459,6 +459,14 @@ type RDSAPI interface {
|
||||
RevokeDBSecurityGroupIngressWithContext(aws.Context, *rds.RevokeDBSecurityGroupIngressInput, ...request.Option) (*rds.RevokeDBSecurityGroupIngressOutput, error)
|
||||
RevokeDBSecurityGroupIngressRequest(*rds.RevokeDBSecurityGroupIngressInput) (*request.Request, *rds.RevokeDBSecurityGroupIngressOutput)
|
||||
|
||||
StartDBInstance(*rds.StartDBInstanceInput) (*rds.StartDBInstanceOutput, error)
|
||||
StartDBInstanceWithContext(aws.Context, *rds.StartDBInstanceInput, ...request.Option) (*rds.StartDBInstanceOutput, error)
|
||||
StartDBInstanceRequest(*rds.StartDBInstanceInput) (*request.Request, *rds.StartDBInstanceOutput)
|
||||
|
||||
StopDBInstance(*rds.StopDBInstanceInput) (*rds.StopDBInstanceOutput, error)
|
||||
StopDBInstanceWithContext(aws.Context, *rds.StopDBInstanceInput, ...request.Option) (*rds.StopDBInstanceOutput, error)
|
||||
StopDBInstanceRequest(*rds.StopDBInstanceInput) (*request.Request, *rds.StopDBInstanceOutput)
|
||||
|
||||
WaitUntilDBInstanceAvailable(*rds.DescribeDBInstancesInput) error
|
||||
WaitUntilDBInstanceAvailableWithContext(aws.Context, *rds.DescribeDBInstancesInput, ...request.WaiterOption) error
|
||||
|
||||
|
||||
+9
-5
@@ -12,11 +12,10 @@ import (
|
||||
// BuildAuthToken will return a authentication token for the database's connect
|
||||
// based on the RDS database endpoint, AWS region, IAM user or role, and AWS credentials.
|
||||
//
|
||||
// Endpoint consists of the scheme, hostname, and port. IE scheme://{hostname}[:port]
|
||||
// of the RDS database. Region is the AWS region the RDS database is in and where
|
||||
// the authentication token will be generated for. DbUser is the IAM user or role
|
||||
// the request will be authenticated for. The creds is the AWS credentials
|
||||
// the authentication token is signed with.
|
||||
// Endpoint consists of the hostname and port, IE hostname:port, of the RDS database.
|
||||
// Region is the AWS region the RDS database is in and where the authentication token
|
||||
// will be generated for. DbUser is the IAM user or role the request will be authenticated
|
||||
// for. The creds is the AWS credentials the authentication token is signed with.
|
||||
//
|
||||
// An error is returned if the authentication token is unable to be signed with
|
||||
// the credentials, or the endpoint is not a valid URL.
|
||||
@@ -38,6 +37,11 @@ import (
|
||||
// See http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html
|
||||
// for more information on using IAM database authentication with RDS.
|
||||
func BuildAuthToken(endpoint, region, dbUser string, creds *credentials.Credentials) (string, error) {
|
||||
// the scheme is arbitrary and is only needed because validation of the URL requires one.
|
||||
if !(strings.HasPrefix(endpoint, "http://") || strings.HasPrefix(endpoint, "https://")) {
|
||||
endpoint = "https://" + endpoint
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("GET", endpoint, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
+25
-7
@@ -10,12 +10,30 @@ import (
|
||||
)
|
||||
|
||||
func TestBuildAuthToken(t *testing.T) {
|
||||
endpoint := "https://prod-instance.us-east-1.rds.amazonaws.com:3306"
|
||||
region := "us-west-2"
|
||||
creds := credentials.NewStaticCredentials("AKID", "SECRET", "SESSION")
|
||||
user := "mysqlUser"
|
||||
cases := []struct {
|
||||
endpoint string
|
||||
region string
|
||||
user string
|
||||
expectedRegex string
|
||||
}{
|
||||
{
|
||||
"https://prod-instance.us-east-1.rds.amazonaws.com:3306",
|
||||
"us-west-2",
|
||||
"mysqlUser",
|
||||
`^prod-instance\.us-east-1\.rds\.amazonaws\.com:3306\?Action=connect.*?DBUser=mysqlUser.*`,
|
||||
},
|
||||
{
|
||||
"prod-instance.us-east-1.rds.amazonaws.com:3306",
|
||||
"us-west-2",
|
||||
"mysqlUser",
|
||||
`^prod-instance\.us-east-1\.rds\.amazonaws\.com:3306\?Action=connect.*?DBUser=mysqlUser.*`,
|
||||
},
|
||||
}
|
||||
|
||||
url, err := rdsutils.BuildAuthToken(endpoint, region, user, creds)
|
||||
assert.NoError(t, err)
|
||||
assert.Regexp(t, `^prod-instance\.us-east-1\.rds\.amazonaws\.com:3306\?Action=connect.*?DBUser=mysqlUser.*`, url)
|
||||
for _, c := range cases {
|
||||
creds := credentials.NewStaticCredentials("AKID", "SECRET", "SESSION")
|
||||
url, err := rdsutils.BuildAuthToken(c.endpoint, c.region, c.user, creds)
|
||||
assert.NoError(t, err)
|
||||
assert.Regexp(t, c.expectedRegex, url)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user