-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Upgrades
ldap_configuration
and ldap_verify
resources to a…
…uto-generated SDK (#1971) * rename in resources * refactor in tests * run skipped tests * checkExists only with resourceName param * refactor ldap verify tests * mig tests * new SDK in tests * ds, read, import and delete * no delete in ldap verify * create & update * enable skipped tests
- Loading branch information
Showing
16 changed files
with
498 additions
and
498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 16 additions & 42 deletions
58
internal/service/ldapconfiguration/data_source_ldap_configuration_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,42 @@ | ||
package ldapconfiguration_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" | ||
"github.com/spf13/cast" | ||
matlas "go.mongodb.org/atlas/mongodbatlas" | ||
) | ||
|
||
func TestAccLDAPConfigurationDS_basic(t *testing.T) { | ||
var ( | ||
ldapConfiguration matlas.LDAPConfiguration | ||
resourceName = "mongodbatlas_ldap_configuration.test" | ||
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") | ||
hostname = os.Getenv("MONGODB_ATLAS_LDAP_HOSTNAME") | ||
username = os.Getenv("MONGODB_ATLAS_LDAP_USERNAME") | ||
password = os.Getenv("MONGODB_ATLAS_LDAP_PASSWORD") | ||
port = os.Getenv("MONGODB_ATLAS_LDAP_PORT") | ||
authEnabled = true | ||
projectName = acc.RandomProjectName() | ||
dataSourceName = "data.mongodbatlas_ldap_configuration.test" | ||
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") | ||
hostname = os.Getenv("MONGODB_ATLAS_LDAP_HOSTNAME") | ||
username = os.Getenv("MONGODB_ATLAS_LDAP_USERNAME") | ||
password = os.Getenv("MONGODB_ATLAS_LDAP_PASSWORD") | ||
port = os.Getenv("MONGODB_ATLAS_LDAP_PORT") | ||
authEnabled = true | ||
projectName = acc.RandomProjectName() | ||
) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { acc.PreCheckLDAP(t) }, | ||
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, | ||
CheckDestroy: acc.CheckDestroyLDAPConfiguration, | ||
CheckDestroy: checkDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccMongoDBAtlasDataSourceLDAPConfigurationConfig(projectName, orgID, hostname, username, password, authEnabled, cast.ToInt(port)), | ||
Config: configBasic(projectName, orgID, hostname, username, password, authEnabled, cast.ToInt(port)), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckMongoDBAtlasLDAPConfigurationExists(resourceName, &ldapConfiguration), | ||
|
||
resource.TestCheckResourceAttrSet(resourceName, "project_id"), | ||
resource.TestCheckResourceAttrSet(resourceName, "hostname"), | ||
resource.TestCheckResourceAttrSet(resourceName, "bind_username"), | ||
resource.TestCheckResourceAttrSet(resourceName, "authentication_enabled"), | ||
resource.TestCheckResourceAttrSet(resourceName, "port"), | ||
resource.TestCheckResourceAttrSet(dataSourceName, "project_id"), | ||
resource.TestCheckResourceAttr(dataSourceName, "hostname", hostname), | ||
resource.TestCheckResourceAttr(dataSourceName, "bind_username", username), | ||
resource.TestCheckResourceAttr(dataSourceName, "authentication_enabled", strconv.FormatBool(authEnabled)), | ||
resource.TestCheckResourceAttr(dataSourceName, "port", port), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccMongoDBAtlasDataSourceLDAPConfigurationConfig(projectName, orgID, hostname, username, password string, authEnabled bool, port int) string { | ||
return fmt.Sprintf(` | ||
resource "mongodbatlas_project" "test" { | ||
name = "%[1]s" | ||
org_id = "%[2]s" | ||
} | ||
resource "mongodbatlas_ldap_configuration" "test" { | ||
project_id = mongodbatlas_project.test.id | ||
authentication_enabled = %[6]t | ||
hostname = "%[3]s" | ||
port = %[7]d | ||
bind_username = "%[4]s" | ||
bind_password = "%[5]s" | ||
} | ||
data "mongodbatlas_ldap_configuration" "test" { | ||
project_id = mongodbatlas_ldap_configuration.test.id | ||
} | ||
`, projectName, orgID, hostname, username, password, authEnabled, port) | ||
} |
Oops, something went wrong.