-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: create org specific integration test
- Loading branch information
Showing
5 changed files
with
350 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
integration/resource_lacework_integration_gcp_org_agentless_scanning_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package integration | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/gruntwork-io/terratest/modules/terraform" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIntegrationGcpAgentlessOrgScanningCreateAndUpdate(t *testing.T) { | ||
gcreds, err := googleLoadDefaultCredentials() | ||
integration_name := "GCP Org 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 GOOGLE_CREDENTIALS environment variable") { | ||
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ | ||
TerraformDir: "../examples/resource_lacework_integration_gcp_org_agentless_scanning", | ||
Vars: map[string]interface{}{ | ||
"name": integration_name, | ||
"client_id": gcreds.ClientID, | ||
"client_email": gcreds.ClientEmail, | ||
"private_key_id": gcreds.PrivateKeyID, | ||
"bucket_name": "storage bucket id", | ||
"org_account_mappings": []map[string]interface{}{ | ||
{ | ||
"default_lacework_account": "customerdemo", | ||
"mapping": []map[string]interface{}{ | ||
{ | ||
"lacework_account": "abc", | ||
"gcp_projects": []string{"techally-test"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
EnvVars: map[string]string{ | ||
"TF_VAR_private_key": gcreds.PrivateKey, | ||
"LW_API_TOKEN": LwApiToken, | ||
}, | ||
}) | ||
defer terraform.Destroy(t, terraformOptions) | ||
|
||
// Create new Google Agentless Scanning integration | ||
create := terraform.InitAndApplyAndIdempotent(t, terraformOptions) | ||
createData := GetGcpAgentlessScanningResponse(create) | ||
assert.Equal(t, integration_name, createData.Data.Name) | ||
|
||
// Update Gcp integration | ||
terraformOptions.Vars = map[string]interface{}{ | ||
"name": update_integration_name, | ||
"client_id": gcreds.ClientID, | ||
"client_email": gcreds.ClientEmail, | ||
"private_key_id": gcreds.PrivateKeyID, | ||
"bucket_name": "storage bucket id", | ||
"org_account_mappings": []map[string]interface{}{ | ||
{ | ||
"default_lacework_account": "customerdemo", | ||
"mapping": []map[string]interface{}{ | ||
{ | ||
"lacework_account": "abc", | ||
"gcp_projects": []string{"techally-test"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
update := terraform.ApplyAndIdempotent(t, terraformOptions) | ||
updateData := GetGcpAgentlessScanningResponse(update) | ||
assert.Equal(t, update_integration_name, updateData.Data.Name) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.