Skip to content

Commit

Permalink
fix: tests and integration state (#186)
Browse files Browse the repository at this point in the history
* fix: tests and integration state

Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com>

* fix: changed trigger action to import

Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com>

---------

Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com>
  • Loading branch information
mati007thm authored Dec 16, 2024
1 parent f14b46c commit b50b561
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions internal/provider/integration_msdefender_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,12 @@ func (r *integrationMsDefenderResource) Create(ctx context.Context, req resource

// trigger integration to gather results quickly after the first setup
// NOTE: we ignore the error since the integration state does not depend on it
_, err = r.client.TriggerAction(ctx, string(integration.Mrn), mondoov1.ActionTypeRunScan)
_, err = r.client.TriggerAction(ctx, string(integration.Mrn), mondoov1.ActionTypeRunImport)
if err != nil {
resp.Diagnostics.
AddWarning("Client Error",
fmt.Sprintf("Unable to trigger integration, got error: %s", err),
)
return
}

// Save space mrn into the Terraform state.
Expand Down
8 changes: 4 additions & 4 deletions internal/provider/integration_msdefender_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ func TestAccMsDefenderIntegrationResource(t *testing.T) {
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", `["ffffffff-ffff-ffff-ffff-ffffffffffff", "ffffffff-ffff-ffff-ffff-ffffffffffff"]`),
resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_allow_list.0", "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", `["ffffffff-ffff-ffff-ffff-ffffffffffff", "ffffffff-ffff-ffff-ffff-ffffffffffff"]`),
resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_deny_list.0", "ffffffff-ffff-ffff-ffff-ffffffffffff"),
resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "credentials.pem_file", "abcd1234567890"),
),
},
Expand All @@ -43,15 +43,15 @@ func TestAccMsDefenderIntegrationResource(t *testing.T) {
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", `["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"]`),
resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_allow_list.0", "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", `["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"]`),
resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "subscription_deny_list.0", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"),
resource.TestCheckResourceAttr("mondoo_integration_msdefender.msdefender_integration", "credentials.pem_file", "abcd1234567890"),
),
},
Expand Down

0 comments on commit b50b561

Please sign in to comment.