Skip to content

Commit

Permalink
Updated tests to make sure that RDS instances without clusters are ch…
Browse files Browse the repository at this point in the history
…ecked for
  • Loading branch information
sethsec committed May 29, 2024
1 parent 91f5f14 commit 0b88bca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 5 additions & 4 deletions aws/databases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ func TestDatabasesCommand(t *testing.T) {
}

expectedResults := []string{
"db1.cluster-123456789012.us-west-2.rds.amazonaws.com",
"db2.cluster-123456789012.us-west-2.rds.amazonaws.com",
"db3.cluster-123456789012.us-west-2.neptune.amazonaws.com",
"db4.cluster-123456789012.us-west-2.docdb.amazonaws.com",
"db1.cluster-123456789012.us-west-2.rds.amazonaws.com", // make sure it includes the Aurora clusters
"db2.cluster-123456789012.us-west-2.rds.amazonaws.com", // make sure it includes the Aurora clusters
"db3.cluster-123456789012.us-west-2.neptune.amazonaws.com", // make sure it includes the Neptune instances
"db4.cluster-123456789012.us-west-2.docdb.amazonaws.com", // make sure it includes the DocumentDB instances
"db1-instances-1.blah.us-west-2.rds.amazonaws.com", // make sure it includes the RDS instances
}

for _, expected := range expectedResults {
Expand Down
8 changes: 8 additions & 0 deletions aws/sdk/rds_mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ func (m *MockedRDSClient) DescribeDBInstances(ctx context.Context, input *rds.De
EngineVersion: aws.String("13.3"),
InstanceCreateTime: aws.Time(time.Now()),
MasterUsername: aws.String("postgres"),
Endpoint: &rdsTypes.Endpoint{
Address: aws.String("db1-instances-1.blah.us-west-2.rds.amazonaws.com"),
Port: aws.Int32(5432),
},
},
{
DBInstanceIdentifier: aws.String("db2"),
Engine: aws.String("postgres"),
EngineVersion: aws.String("13.3"),
InstanceCreateTime: aws.Time(time.Now()),
MasterUsername: aws.String("postgres"),
Endpoint: &rdsTypes.Endpoint{
Address: aws.String("db2-instances-1.blah.us-west-2.rds.amazonaws.com"),
Port: aws.Int32(5432),
},
},
},
}, nil
Expand Down

0 comments on commit 0b88bca

Please sign in to comment.