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

Test or TestAccResourceMongoDBAtlasDatabaseUser_withAWSIAMType with #432

Merged
merged 2 commits into from
Apr 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions mongodbatlas/resource_mongodbatlas_database_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,47 @@ func TestAccResourceMongoDBAtlasDatabaseUser_withAWSIAMType(t *testing.T) {
})
}

func TestAccResourceMongoDBAtlasDatabaseUser_withAWSIAMType_import(t *testing.T) {
var (
dbUser matlas.DatabaseUser
resourceName = "mongodbatlas_database_user.test"
username = os.Getenv("TEST_DB_USER_IAM_ARN")
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acctest.RandomWithPrefix("test-acc")
)

if username == "" {
username = "arn:aws:iam::358363220050:user/mongodb-aws-iam-auth-test-user"
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy,
Steps: []resource.TestStep{
{
Config: testAccMongoDBAtlasDatabaseUserWithAWSIAMTypeConfig(projectName, orgID, "atlasAdmin", username, "First Key", "First value"),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasDatabaseUserExists(resourceName, &dbUser),
testAccCheckMongoDBAtlasDatabaseUserAttributes(&dbUser, username),
resource.TestCheckResourceAttrSet(resourceName, "project_id"),
resource.TestCheckResourceAttr(resourceName, "username", username),
resource.TestCheckResourceAttr(resourceName, "aws_iam_type", "USER"),
resource.TestCheckResourceAttr(resourceName, "auth_database_name", "$external"),
resource.TestCheckResourceAttr(resourceName, "labels.#", "1"),
),
},
{
ResourceName: resourceName,
ImportStateIdFunc: testAccCheckMongoDBAtlasDatabaseUserImportStateIDFunc(resourceName),
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"password"},
},
},
})
}

func TestAccResourceMongoDBAtlasDatabaseUser_WithLabels(t *testing.T) {
var (
dbUser matlas.DatabaseUser
Expand Down