Skip to content

Commit

Permalink
Fix: Enable azure agentless test (#671)
Browse files Browse the repository at this point in the history
* Fix: Enable azure agentless test

Signed-off-by: Lei Jin <[email protected]>

* fix: Fix the azure agentless example

Signed-off-by: Lei Jin <[email protected]>

---------

Signed-off-by: Lei Jin <[email protected]>
  • Loading branch information
leijin-lw authored Nov 5, 2024
1 parent 87bbc18 commit 7d086fb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ variable "integration_level" {

variable "blob_container_name" {
type = string
default = "blob-container-name"
default = "terraform-provider-test"
}

variable "scanning_subscription_id" {
Expand All @@ -37,12 +37,12 @@ variable "scanning_subscription_id" {

variable "scanning_resource_group_name" {
type = string
default = "AWLS-kilby-test"
default = "agentless-canary-scanned-group"
}

variable "storage_account_url" {
type = string
default = "https://aoztest.blob.core.windows.net/"
default = "https://asidekicktest3954.blob.core.windows.net/"
}

variable "tenant_id" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
package integration

//import (
// "fmt"
// "testing"
//
// "github.com/gruntwork-io/terratest/modules/terraform"
// "github.com/stretchr/testify/assert"
//)
import (
"fmt"
"testing"

"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
)

// TestIntegrationAzureAgentlessScanningCreate applies integration terraform:
// => '../examples/resource_lacework_integration_azure_agentless_scanning'
//
// It uses the go-sdk to verify the created integration,
// applies an update with new integration name and destroys it
//func TestIntegrationAzureAgentlessScanningCreate(t *testing.T) {
// credential, err := azureLoadDefaultCredentials()
// integration_name := "Azure Agentless Scanning Example Integration Test"
// update_integration_name := fmt.Sprintf("%s Updated", integration_name)
// if assert.Nil(t, err, "this test requires you to set AZURE_CREDENTIALS environment variable") {
// terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{
// TerraformDir: "../examples/resource_lacework_integration_azure_agentless_scanning",
// Vars: map[string]interface{}{
// "integration_name": integration_name,
// "client_id": credential.ClientID,
// "client_secret": credential.ClientSecret,
// },
// EnvVars: map[string]string{
// "LW_API_TOKEN": LwApiToken,
// },
// })
// defer terraform.Destroy(t, terraformOptions)
//
// // Create new Azure Agentless Scanning integration
// create := terraform.InitAndApplyAndIdempotent(t, terraformOptions)
// createData := GetAzureAgentlessScanningResponse(create)
// assert.Equal(t, integration_name, createData.Data.Name)
//
// // Update Azure integration
// terraformOptions.Vars["integration_name"] = update_integration_name
//
// update := terraform.InitAndApplyAndIdempotent(t, terraformOptions)
// updateData := GetAzureAgentlessScanningResponse(update)
// assert.Equal(t, update_integration_name, updateData.Data.Name)
// }
//}
func TestIntegrationAzureAgentlessScanningCreate(t *testing.T) {
credential, err := azureLoadDefaultCredentials()
integration_name := "Azure Agentless Scanning Example Integration Test"
update_integration_name := fmt.Sprintf("%s Updated", integration_name)
if assert.Nil(t, err, "this test requires you to set AZURE_CREDENTIALS environment variable") {
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{
TerraformDir: "../examples/resource_lacework_integration_azure_agentless_scanning",
Vars: map[string]interface{}{
"integration_name": integration_name,
"client_id": credential.ClientID,
"client_secret": credential.ClientSecret,
},
EnvVars: map[string]string{
"LW_API_TOKEN": LwApiToken,
},
})
defer terraform.Destroy(t, terraformOptions)

// Create new Azure Agentless Scanning integration
create := terraform.InitAndApplyAndIdempotent(t, terraformOptions)
createData := GetAzureAgentlessScanningResponse(create)
assert.Equal(t, integration_name, createData.Data.Name)

// Update Azure integration
terraformOptions.Vars["integration_name"] = update_integration_name

update := terraform.InitAndApplyAndIdempotent(t, terraformOptions)
updateData := GetAzureAgentlessScanningResponse(update)
assert.Equal(t, update_integration_name, updateData.Data.Name)
}
}

0 comments on commit 7d086fb

Please sign in to comment.