* chore: Update make testacc to use boundary dev Use boundary dev instead of test controller in order to get an enterprise cluster * test: Update tests to use boundary dev cluster - Set up environment variables via loadTestConfig - Update testConfigWithRecovery to use recovery key from config - Update testCOnfigWithoutAMPWCredentials to use boundary dev's auth method * test: Update tests to use their own orgs This is to address some test failures due to conflicts when creating resources within the same org. * test: Enable tests that require boundary-enterprise * chore: Update workflow to use boundary enterprise
93 lines
3.3 KiB
Go
93 lines
3.3 KiB
Go
// Copyright IBM Corp. 2020, 2026
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package provider
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/boundary/testing/vault"
|
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/id"
|
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
const (
|
|
vaultLdapCredResc = "boundary_credential_library_vault_ldap.example"
|
|
vaultLdapCredLibName = "foo"
|
|
vaultLdapCredLibDesc = "the foo"
|
|
vaultLdapCredLibPath = "/ldap/static-cred/foo"
|
|
vaultLdapCredLibStringUpdate = "_random"
|
|
)
|
|
|
|
var vaultLdapCredLibResource = fmt.Sprintf(`
|
|
resource "boundary_credential_library_vault_ldap" "example" {
|
|
name = "%s"
|
|
description = "%s"
|
|
credential_store_id = boundary_credential_store_vault.example.id
|
|
path = "%s"
|
|
}`, vaultLdapCredLibName,
|
|
vaultLdapCredLibDesc,
|
|
vaultLdapCredLibPath)
|
|
|
|
var vaultLdapCredLibResourceUpdate = fmt.Sprintf(`
|
|
resource "boundary_credential_library_vault_ldap" "example" {
|
|
name = "%s"
|
|
description = "%s"
|
|
credential_store_id = boundary_credential_store_vault.example.id
|
|
path = "%s"
|
|
}`, vaultLdapCredLibName+vaultLdapCredLibStringUpdate,
|
|
vaultLdapCredLibDesc+vaultLdapCredLibStringUpdate,
|
|
vaultLdapCredLibPath+vaultLdapCredLibStringUpdate)
|
|
|
|
func TestAccCredentialLibraryVaultLdap(t *testing.T) {
|
|
cfg, err := loadTestConfig()
|
|
require.NoError(t, err)
|
|
suffix := id.UniqueId()
|
|
url := cfg.BoundaryAddr
|
|
|
|
vc := vault.NewTestVaultServer(t)
|
|
_, token := vc.CreateToken(t)
|
|
credStoreRes := vaultCredStoreResource(vc,
|
|
vaultCredStoreName,
|
|
vaultCredStoreDesc,
|
|
vaultCredStoreNamespace,
|
|
"www.original.com",
|
|
token,
|
|
true)
|
|
|
|
var provider *schema.Provider
|
|
resource.Test(t, resource.TestCase{
|
|
IsUnitTest: true,
|
|
ProviderFactories: providerFactories(&provider),
|
|
CheckDestroy: testAccCheckCredentialLibraryVaultResourceDestroy(t, provider, ldapVaultCredentialLibraryType),
|
|
Steps: []resource.TestStep{
|
|
{
|
|
// create
|
|
Config: testConfig(url, fooOrg(suffix), firstProjectFoo, credStoreRes, vaultLdapCredLibResource),
|
|
Check: resource.ComposeTestCheckFunc(
|
|
resource.TestCheckResourceAttr(vaultLdapCredResc, NameKey, vaultLdapCredLibName),
|
|
resource.TestCheckResourceAttr(vaultLdapCredResc, DescriptionKey, vaultLdapCredLibDesc),
|
|
resource.TestCheckResourceAttr(vaultLdapCredResc, credentialLibraryVaultLdapPathKey, vaultLdapCredLibPath),
|
|
|
|
testAccCheckCredentialLibraryResourceExists(provider, vaultLdapCredResc),
|
|
),
|
|
},
|
|
importStep(vaultLdapCredResc),
|
|
{
|
|
// update
|
|
Config: testConfig(url, fooOrg(suffix), firstProjectFoo, credStoreRes, vaultLdapCredLibResourceUpdate),
|
|
Check: resource.ComposeTestCheckFunc(
|
|
resource.TestCheckResourceAttr(vaultLdapCredResc, NameKey, vaultLdapCredLibName+vaultLdapCredLibStringUpdate),
|
|
resource.TestCheckResourceAttr(vaultLdapCredResc, DescriptionKey, vaultLdapCredLibDesc+vaultLdapCredLibStringUpdate),
|
|
resource.TestCheckResourceAttr(vaultLdapCredResc, credentialLibraryVaultLdapPathKey, vaultLdapCredLibPath+vaultLdapCredLibStringUpdate),
|
|
testAccCheckCredentialLibraryResourceExists(provider, vaultLdapCredResc),
|
|
),
|
|
},
|
|
importStep(vaultLdapCredResc),
|
|
},
|
|
})
|
|
}
|