Skip to content

Commit

Permalink
update even more tests to use ProviderFactories
Browse files Browse the repository at this point in the history
  • Loading branch information
fairclothjm committed Oct 6, 2023
1 parent ff1a337 commit 420c315
Show file tree
Hide file tree
Showing 124 changed files with 804 additions and 803 deletions.
2 changes: 1 addition & 1 deletion vault/data_identity_oidc_openid_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestDataSourceIdentityOIDCOpenIDConfig(t *testing.T) {
}

resource.Test(t, resource.TestCase{
Providers: testProviders,
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testDataSourceIdentityOIDCOpenIDConfig_config(keyName, clientName, providerName, u.Host),
Expand Down
4 changes: 2 additions & 2 deletions vault/data_source_ad_credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func TestAccDataSourceADAccessCredentials_basic(t *testing.T) {
bindDN, bindPass, url := testutil.GetTestADCreds(t)

resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testAccDataSourceADAccessCredentialsConfig(backend, bindDN, bindPass, url, "bob", "Bob", 60),
Expand Down
12 changes: 6 additions & 6 deletions vault/data_source_approle_auth_backend_role_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ func TestAccAppRoleAuthBackendRoleID_basic(t *testing.T) {
role := acctest.RandomWithPrefix("test-role")

resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
CheckDestroy: testAccCheckAppRoleAuthBackendRoleDestroy,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: testAccCheckAppRoleAuthBackendRoleDestroy,
Steps: []resource.TestStep{
{
Config: testAccAppRoleAuthBackendRoleConfig_basic(backend, role),
Expand Down Expand Up @@ -54,9 +54,9 @@ func TestAccAppRoleAuthBackendRoleID_customID(t *testing.T) {
roleID := acctest.RandomWithPrefix("test-role-id")

resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
CheckDestroy: testAccCheckAppRoleAuthBackendRoleDestroy,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: testAccCheckAppRoleAuthBackendRoleDestroy,
Steps: []resource.TestStep{
{
Config: testAccAppRoleAuthBackendRoleConfig_full(backend, role, roleID),
Expand Down
4 changes: 2 additions & 2 deletions vault/data_source_auth_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
func TestDataSourceAuthBackend(t *testing.T) {
path := acctest.RandomWithPrefix("foo")
r.Test(t, r.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []r.TestStep{
{
Config: testDataSourceAuthBackendBasic_config,
Expand Down
4 changes: 2 additions & 2 deletions vault/data_source_auth_backends_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func TestDataSourceAuthBackends(t *testing.T) {
ds := "data.vault_auth_backends.test"

resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testDataSourceAuthBackendsBasic,
Expand Down
12 changes: 6 additions & 6 deletions vault/data_source_aws_access_credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func TestAccDataSourceAWSAccessCredentials_basic(t *testing.T) {
region := testutil.GetTestAWSRegion(t)

resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testAccDataSourceAWSAccessCredentialsConfig_basic(mountPath, accessKey, secretKey, region),
Expand Down Expand Up @@ -110,8 +110,8 @@ func TestAccDataSourceAWSAccessCredentials_sts(t *testing.T) {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: test.config,
Expand All @@ -137,8 +137,8 @@ func TestAccDataSourceAWSAccessCredentials_sts_ttl(t *testing.T) {
ttl := "18m"

resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testAccDataSourceAWSAccessCredentialsConfig_sts_basic(mountPath, accessKey, secretKey, region),
Expand Down
4 changes: 2 additions & 2 deletions vault/data_source_azure_access_credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func TestAccDataSourceAzureAccessCredentials_basic(t *testing.T) {
mountPath := acctest.RandomWithPrefix("tf-test-azure")
conf := testutil.GetTestAzureConf(t)
resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testAccDataSourceAzureAccessCredentialsConfigBasic(mountPath, conf, 20),
Expand Down
12 changes: 6 additions & 6 deletions vault/data_source_gcp_auth_backend_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func TestAccGCPAuthBackendRoleDataSource_basic(t *testing.T) {
projectId := acctest.RandomWithPrefix("tf-test-gcp-project-id")

resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
CheckDestroy: testGCPAuthBackendRoleDestroy,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: testGCPAuthBackendRoleDestroy,
Steps: []resource.TestStep{
{
Config: testGCPAuthBackendRoleConfig_basic(backend, name, serviceAccount, projectId),
Expand Down Expand Up @@ -66,9 +66,9 @@ func TestAccGCPAuthBackendRoleDataSource_gce(t *testing.T) {

resourceName := "vault_gcp_auth_backend_role.test"
resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
CheckDestroy: testGCPAuthBackendRoleDestroy,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: testGCPAuthBackendRoleDestroy,
Steps: []resource.TestStep{
{
Config: testGCPAuthBackendRoleConfig_gce(backend, name, projectId),
Expand Down
12 changes: 6 additions & 6 deletions vault/data_source_kubernetes_auth_backend_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func TestAccKubernetesAuthBackendConfigDataSource_basic(t *testing.T) {
jwt := kubernetesJWT

resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
CheckDestroy: testAccCheckKubernetesAuthBackendConfigDestroy,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: testAccCheckKubernetesAuthBackendConfigDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesAuthBackendConfigConfig_basic(backend, jwt, kubernetesCAcert),
Expand Down Expand Up @@ -64,9 +64,9 @@ func TestAccKubernetesAuthBackendConfigDataSource_full(t *testing.T) {
disableLocalCaJwt := true

resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
CheckDestroy: testAccCheckKubernetesAuthBackendConfigDestroy,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: testAccCheckKubernetesAuthBackendConfigDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesAuthBackendConfigConfig_full(backend, kubernetesCAcert, jwt, issuer,
Expand Down
15 changes: 8 additions & 7 deletions vault/data_source_kubernetes_auth_backend_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func TestAccKubernetesAuthBackendRoleDataSource_basic(t *testing.T) {
ttl := 3600

resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
CheckDestroy: testAccCheckKubernetesAuthBackendConfigDestroy,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: testAccCheckKubernetesAuthBackendConfigDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesAuthBackendRoleDataSourceConfig_basic(backend, role, "", ttl),
Expand Down Expand Up @@ -95,9 +95,9 @@ func TestAccKubernetesAuthBackendRoleDataSource_full(t *testing.T) {
audience := "vault"

resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
CheckDestroy: testAccCheckKubernetesAuthBackendConfigDestroy,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: testAccCheckKubernetesAuthBackendConfigDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesAuthBackendRoleDataSourceConfig_full(
Expand Down Expand Up @@ -182,7 +182,8 @@ data "vault_kubernetes_auth_backend_role" "role" {
}

func testAccKubernetesAuthBackendRoleDataSourceConfig_full(backend, role, aliasSource string, ttl, maxTTL int,
audience string) string {
audience string,
) string {
return fmt.Sprintf(`
%s
Expand Down
8 changes: 4 additions & 4 deletions vault/data_source_kv_secret_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func TestDataSourceKVV2Secret(t *testing.T) {

resourceName := "data.vault_kv_secret_v2.test"
resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testDataSourceKVV2SecretConfig(mount, name),
Expand Down Expand Up @@ -67,8 +67,8 @@ func TestDataSourceKVV2Secret_deletedSecret(t *testing.T) {
name := acctest.RandomWithPrefix("foo")

resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
PreConfig: func() {
Expand Down
4 changes: 2 additions & 2 deletions vault/data_source_kv_secrets_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func TestDataSourceKVSecretList(t *testing.T) {
datasourceName := "data.vault_kv_secrets_list.test"

resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testDataSourceKVSecretListConfig(mount, s1, s2, false),
Expand Down
4 changes: 2 additions & 2 deletions vault/data_source_kv_secrets_list_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func TestDataSourceKVSecretListV2(t *testing.T) {
datasource2 := "data.vault_kv_secrets_list_v2.test_internal"

resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testDataSourceKVV2SecretListConfig(mount, s1, s2),
Expand Down
4 changes: 2 additions & 2 deletions vault/data_source_policy_document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (

func TestDataSourcePolicyDocument(t *testing.T) {
resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testDataSourcePolicyDocument_config,
Expand Down
2 changes: 1 addition & 1 deletion vault/data_source_raft_autopilot_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
func TestAccDataSourceRaftAutoPilotState(t *testing.T) {
ds := "data.vault_raft_autopilot_state.test"
resource.Test(t, resource.TestCase{
Providers: testProviders,
ProviderFactories: providerFactories,
PreCheck: func() {
testutil.SkipTestEnvSet(t, "SKIP_RAFT_TESTS")
testutil.TestEntPreCheck(t)
Expand Down
4 changes: 2 additions & 2 deletions vault/data_source_transit_decrypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (

func TestDataSourceTransitDecrypt(t *testing.T) {
resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testDataSourceTransitDecrypt_config,
Expand Down
6 changes: 3 additions & 3 deletions vault/import_auth_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
func TestAccAuthBackend_importBasic(t *testing.T) {
path := "github-" + acctest.RandString(10)
resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
CheckDestroy: testAccCheckAuthBackendDestroy,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: testAccCheckAuthBackendDestroy,
Steps: []resource.TestStep{
{
Config: testResourceAuth_initialConfig(path),
Expand Down
8 changes: 4 additions & 4 deletions vault/import_generic_secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func TestAccGenericSecret_importBasic(t *testing.T) {
name := acctest.RandomWithPrefix("test")
path := fmt.Sprintf("%s/%s", mount, name)
resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testResourceGenericSecret_initialConfig(mount, name),
Expand All @@ -46,8 +46,8 @@ func TestAccGenericSecret_importBasicNS(t *testing.T) {
path := fmt.Sprintf("%s/%s", mount, name)
resourceName := "vault_generic_secret.test"
resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestEntPreCheck(t) },
Providers: testProviders,
PreCheck: func() { testutil.TestEntPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testResourceGenericSecret_initialConfigNS(ns, mount, name),
Expand Down
4 changes: 2 additions & 2 deletions vault/import_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
func TestAccPolicy_importBasic(t *testing.T) {
name := "test-" + acctest.RandString(10)
resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testResourcePolicy_initialConfig(name),
Expand Down
12 changes: 6 additions & 6 deletions vault/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func TestTokenReadProviderConfigureWithHeaders(t *testing.T) {
Schema: rootProvider.Schema,
}
resource.Test(t, resource.TestCase{
PreCheck: func() { testutil.TestAccPreCheck(t) },
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testHeaderConfig("auth", "123"),
Expand Down Expand Up @@ -532,8 +532,8 @@ func TestAccTokenName(t *testing.T) {
for _, test := range tests {
t.Run(test.WantTokenName, func(t *testing.T) {
resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
PreConfig: func() {
Expand Down Expand Up @@ -629,8 +629,8 @@ func TestAccChildToken(t *testing.T) {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
PreConfig: func() {
Expand Down
6 changes: 3 additions & 3 deletions vault/resource_ad_secret_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestADSecretBackend(t *testing.T) {
resourceType := "vault_ad_secret_backend"
resourceName := resourceType + ".test"
resource.Test(t, resource.TestCase{
Providers: testProviders,
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
PreventPostDestroyRefresh: true,
CheckDestroy: testCheckMountDestroyed(resourceType, consts.MountTypeAD, consts.FieldBackend),
Expand Down Expand Up @@ -84,8 +84,8 @@ func TestADSecretBackend_remount(t *testing.T) {
bindDN, bindPass, url := testutil.GetTestADCreds(t)

resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testADSecretBackend_initialConfig(backend, bindDN, bindPass, url),
Expand Down
12 changes: 6 additions & 6 deletions vault/resource_ad_secret_library_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func TestAccADSecretBackendLibrary_basic(t *testing.T) {
bindDN, bindPass, url := testutil.GetTestADCreds(t)

resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
CheckDestroy: testAccADSecretBackendLibraryCheckDestroy,
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
CheckDestroy: testAccADSecretBackendLibraryCheckDestroy,
Steps: []resource.TestStep{
{
Config: testADSecretBackendLibraryConfig(backend, bindDN, bindPass, url, "qa", `"Bob","Mary"`, 60, 120, false),
Expand Down Expand Up @@ -54,9 +54,9 @@ func TestAccADSecretBackendLibrary_import(t *testing.T) {
bindDN, bindPass, url := testutil.GetTestADCreds(t)

resource.Test(t, resource.TestCase{
Providers: testProviders,
PreCheck: func() { testutil.TestAccPreCheck(t) },
CheckDestroy: testAccADSecretBackendRoleCheckDestroy,
ProviderFactories: providerFactories,
PreCheck: func() { testutil.TestAccPreCheck(t) },
CheckDestroy: testAccADSecretBackendRoleCheckDestroy,
Steps: []resource.TestStep{
{
Config: testADSecretBackendLibraryConfig(backend, bindDN, bindPass, url, "qa", `"Bob","Mary"`, 60, 120, false),
Expand Down
Loading

0 comments on commit 420c315

Please sign in to comment.