From b1b51a60848e9252bbdb92e2978f86a5b8b5d550 Mon Sep 17 00:00:00 2001 From: Matthias Theuermann Date: Wed, 11 Dec 2024 10:04:19 +0100 Subject: [PATCH] fix: acceptance tests Signed-off-by: Matthias Theuermann --- internal/provider/gql.go | 2 +- .../integration_msdefender_resource_test.go | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/provider/gql.go b/internal/provider/gql.go index 51d43c6..4302061 100644 --- a/internal/provider/gql.go +++ b/internal/provider/gql.go @@ -649,7 +649,7 @@ type ClientIntegrationConfigurationOptions struct { HostedAwsConfigurationOptions HostedAwsConfigurationOptions `graphql:"... on HostedAwsConfigurationOptions"` ShodanConfigurationOptions ShodanConfigurationOptions `graphql:"... on ShodanConfigurationOptions"` MicrosoftDefenderConfigurationOptionsInput MicrosoftDefenderConfigurationOptionsInput `graphql:"... on MicrosoftDefenderConfigurationOptionsInput"` - EmailConfigurationOptions EmailConfigurationOptions `graphql:"... on EmailConfigurationOptions"` + EmailConfigurationOptions EmailConfigurationOptions `graphql:"... on EmailConfigurationOptions"` GitlabConfigurationOptions GitlabConfigurationOptions `graphql:"... on GitlabConfigurationOptions"` // Add other configuration options here } diff --git a/internal/provider/integration_msdefender_resource_test.go b/internal/provider/integration_msdefender_resource_test.go index 6eed08a..e9a1b24 100644 --- a/internal/provider/integration_msdefender_resource_test.go +++ b/internal/provider/integration_msdefender_resource_test.go @@ -17,42 +17,42 @@ func TestAccMsDefenderIntegrationResource(t *testing.T) { Steps: []resource.TestStep{ // Create and Read testing { - Config: testAccMsDefenderIntegrationResourceConfig(accSpace.ID(), "one", "ffffffff-ffff-ffff-ffff-ffffffffffff", "ffffffff-ffff-ffff-ffff-ffffffffffff", []string{"ffffffff-ffff-ffff-ffff-ffffffffffff", "ffffffff-ffff-ffff-ffff-ffffffffffff"}), + Config: testAccMsDefenderIntegrationResourceConfig(accSpace.ID(), "one", "ffffffff-ffff-ffff-ffff-ffffffffffff", "ffffffff-ffff-ffff-ffff-ffffffffffff", `["ffffffff-ffff-ffff-ffff-ffffffffffff", "ffffffff-ffff-ffff-ffff-ffffffffffff"]`), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "name", "one"), resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "space_id", accSpace.ID()), resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "tenant_id", "ffffffff-ffff-ffff-ffff-ffffffffffff"), resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "client_id", "ffffffff-ffff-ffff-ffff-ffffffffffff"), - resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_allow_list.#", "2"), + resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_allow_list", `["ffffffff-ffff-ffff-ffff-ffffffffffff", "ffffffff-ffff-ffff-ffff-ffffffffffff"]`), ), }, { - Config: testAccMsDefenderIntegrationResourceWithSpaceInProviderConfig(accSpace.ID(), "two", "abcd1234567890", []string{"ffffffff-ffff-ffff-ffff-ffffffffffff", "ffffffff-ffff-ffff-ffff-ffffffffffff"}), + Config: testAccMsDefenderIntegrationResourceWithSpaceInProviderConfig(accSpace.ID(), "two", "abcd1234567890", `["ffffffff-ffff-ffff-ffff-ffffffffffff", "ffffffff-ffff-ffff-ffff-ffffffffffff"]`), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "name", "two"), resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "space_id", accSpace.ID()), - resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_deny_list.#", "2"), - resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "credentials.0.pem_file", "abcd1234567890"), + resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_deny_list", `["ffffffff-ffff-ffff-ffff-ffffffffffff", "ffffffff-ffff-ffff-ffff-ffffffffffff"]`), + resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "credentials.pem_file", "abcd1234567890"), ), }, // Update and Read testing { - Config: testAccMsDefenderIntegrationResourceConfig(accSpace.ID(), "three", "ffffffff-ffff-ffff-ffff-ffffffffff", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", []string{"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}), + Config: testAccMsDefenderIntegrationResourceConfig(accSpace.ID(), "three", "ffffffff-ffff-ffff-ffff-ffffffffff", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", `["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"]`), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "name", "three"), resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "space_id", accSpace.ID()), resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "tenant_id", "ffffffff-ffff-ffff-ffff-ffffffffff"), resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "client_id", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"), - resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_allow_list.#", "2"), + resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_allow_list", `["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"]`), ), }, { - Config: testAccMsDefenderIntegrationResourceWithSpaceInProviderConfig(accSpace.ID(), "four", "abcd1234567890", []string{"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}), + Config: testAccMsDefenderIntegrationResourceWithSpaceInProviderConfig(accSpace.ID(), "four", "abcd1234567890", `["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"]`), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "name", "four"), resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "space_id", accSpace.ID()), - resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_deny_list.#", "2"), - resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "credentials.0.pem_file", "abcd1234567890"), + resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_deny_list", `["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"]`), + resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "credentials.pem_file", "abcd1234567890"), ), }, // Delete testing automatically occurs in TestCase @@ -60,14 +60,14 @@ func TestAccMsDefenderIntegrationResource(t *testing.T) { }) } -func testAccMsDefenderIntegrationResourceConfig(spaceID, intName, tenantID, clientID string, allowList []string) string { +func testAccMsDefenderIntegrationResourceConfig(spaceID, intName, tenantID, clientID, allowList string) string { return fmt.Sprintf(` resource "mondoo_integration_msdefender" "msdefender_integration" { space_id = %[1]q name = %[2]q tenant_id = %[3]q client_id = %[4]q - subscription_allow_list= %[5]q + subscription_allow_list= %[5]s credentials = { pem_file = "abcd1234567890" } @@ -75,7 +75,7 @@ resource "mondoo_integration_msdefender" "msdefender_integration" { `, spaceID, intName, tenantID, clientID, allowList) } -func testAccMsDefenderIntegrationResourceWithSpaceInProviderConfig(spaceID, intName, pemFile string, denyList []string) string { +func testAccMsDefenderIntegrationResourceWithSpaceInProviderConfig(spaceID, intName, pemFile, denyList string) string { return fmt.Sprintf(` provider "mondoo" { space = %[1]q @@ -84,7 +84,7 @@ resource "mondoo_integration_msdefender" "msdefender_integration" { name = %[2]q tenant_id = "ffffffff-ffff-ffff-ffff-ffffffffffff" client_id = "ffffffff-ffff-ffff-ffff-ffffffffffff" - subscription_deny_list = %[3]q + subscription_deny_list = %[3]s credentials = { pem_file = %[4]q }