Skip to content

Commit

Permalink
fix: acceptance tests
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Theuermann <[email protected]>
  • Loading branch information
mati007thm committed Dec 16, 2024
1 parent 1894e49 commit eb8a052
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions internal/provider/integration_msdefender_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,65 +17,65 @@ 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
},
})
}

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"
}
}
`, 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
Expand All @@ -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
}
Expand Down

0 comments on commit eb8a052

Please sign in to comment.