-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(internal) Add validation test coverage (#16)
- Loading branch information
1 parent
a982d1d
commit 850b209
Showing
8 changed files
with
301 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.idea | ||
|
||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# Crash log files | ||
crash.log | ||
|
||
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most | ||
# .tfvars files are managed as part of configuration and so should be included in | ||
# version control. | ||
# | ||
# example.tfvars | ||
terraform.tfvars | ||
*.tfvars | ||
|
||
# Ignore override files as they are usually used to override resources locally and so | ||
# are not checked in | ||
override.tf | ||
override.tf.json | ||
*_override.tf | ||
*_override.tf.json | ||
|
||
.terraform.lock.hcl | ||
.envrc | ||
**/.envrc | ||
|
||
*.patch | ||
|
||
# MacOS | ||
.DS_Store |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
test: | ||
@echo "Functional Tests to be added here." | ||
./functional.sh |
71 changes: 71 additions & 0 deletions
71
test/examples/secure_config_posture_identity_access/organization/main.tf
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,71 @@ | ||
provider "google" { | ||
project = "mytestproject" | ||
region = "us-west1" | ||
} | ||
|
||
module "organization-posture" { | ||
source = "../../../..//modules/services/service-principal" | ||
project_id = "mytestproject" | ||
service_account_name = "sysdig-secure" | ||
is_organizational = true | ||
organization_domain = "mytestorg.com" | ||
} | ||
|
||
terraform { | ||
|
||
required_providers { | ||
sysdig = { | ||
source = "sysdiglabs/sysdig" | ||
version = "~> 1.18.2" | ||
} | ||
} | ||
} | ||
|
||
provider "sysdig" { | ||
sysdig_secure_url = "test_sysdig_secure_endpoint" | ||
sysdig_secure_api_token = "test_sysdig_secure_api_token" | ||
} | ||
|
||
resource "sysdig_secure_cloud_auth_account" "gcp_project_mytestproject" { | ||
enabled = true | ||
provider_id = "mytestproject" | ||
provider_type = "PROVIDER_GCP" | ||
|
||
feature { | ||
|
||
secure_identity_entitlement { | ||
enabled = true | ||
components = ["COMPONENT_SERVICE_PRINCIPAL/secure-posture"] | ||
} | ||
|
||
secure_config_posture { | ||
enabled = true | ||
components = ["COMPONENT_SERVICE_PRINCIPAL/secure-posture"] | ||
} | ||
} | ||
component { | ||
type = "COMPONENT_SERVICE_PRINCIPAL" | ||
instance = "secure-posture" | ||
service_principal_metadata = jsonencode({ | ||
gcp = { | ||
key = module.organization-posture.service_account_key | ||
} | ||
}) | ||
} | ||
component { | ||
type = "COMPONENT_SERVICE_PRINCIPAL" | ||
instance = "secure-onboarding" | ||
service_principal_metadata = jsonencode({ | ||
gcp = { | ||
key = module.organization-posture.service_account_key | ||
} | ||
}) | ||
} | ||
depends_on = [module.organization-posture] | ||
} | ||
|
||
resource "sysdig_secure_organization" "gcp_organization_mytestproject" { | ||
management_account_id = sysdig_secure_cloud_auth_account.gcp_project_mytestproject.id | ||
depends_on = [module.organization-posture] | ||
} | ||
|
54 changes: 54 additions & 0 deletions
54
test/examples/secure_config_posture_identity_access/single/main.tf
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,54 @@ | ||
provider "google" { | ||
project = "mytestproject" | ||
region = "us-west1" | ||
} | ||
|
||
module "project-posture" { | ||
source = "../../../..//modules/services/service-principal" | ||
project_id = "mytestproject" | ||
service_account_name = "sysdig-secure" | ||
} | ||
|
||
terraform { | ||
|
||
required_providers { | ||
sysdig = { | ||
source = "sysdiglabs/sysdig" | ||
version = "~> 1.18.2" | ||
} | ||
} | ||
} | ||
|
||
provider "sysdig" { | ||
sysdig_secure_url = "test_sysdig_secure_endpoint" | ||
sysdig_secure_api_token = "test_sysdig_secure_api_token" | ||
} | ||
|
||
resource "sysdig_secure_cloud_auth_account" "gcp_project_mytestproject" { | ||
enabled = true | ||
provider_id = "mytestproject" | ||
provider_type = "PROVIDER_GCP" | ||
|
||
feature { | ||
|
||
secure_identity_entitlement { | ||
enabled = true | ||
components = ["COMPONENT_SERVICE_PRINCIPAL/secure-posture"] | ||
} | ||
|
||
secure_config_posture { | ||
enabled = true | ||
components = ["COMPONENT_SERVICE_PRINCIPAL/secure-posture"] | ||
} | ||
} | ||
component { | ||
type = "COMPONENT_SERVICE_PRINCIPAL" | ||
instance = "secure-posture" | ||
service_principal_metadata = jsonencode({ | ||
gcp = { | ||
key = module.project-posture.service_account_key | ||
} | ||
}) | ||
} | ||
depends_on = [module.project-posture] | ||
} |
68 changes: 68 additions & 0 deletions
68
test/examples/secure_threat_detection/organization/main.tf
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,68 @@ | ||
provider "google" { | ||
project = "mytestproject" | ||
region = "us-west1" | ||
} | ||
|
||
module "organization-threat-detection" { | ||
source = "../../../..//modules/services/webhook-datasource" | ||
project_id = "mytestproject" | ||
push_endpoint = "test_sysdig_secure_cloudingestion_endpoint" | ||
is_organizational = true | ||
organization_domain = "mytestorg.com" | ||
} | ||
|
||
module "organization-posture" { | ||
source = "../../../..//modules/services/service-principal" | ||
project_id = "mytestproject" | ||
service_account_name = "sysdig-secure" | ||
is_organizational = true | ||
organization_domain = "mytestorg.com" | ||
} | ||
|
||
terraform { | ||
|
||
required_providers { | ||
sysdig = { | ||
source = "sysdiglabs/sysdig" | ||
version = "~> 1.18.2" | ||
} | ||
} | ||
} | ||
|
||
provider "sysdig" { | ||
sysdig_secure_url = "test_sysdig_secure_endpoint" | ||
sysdig_secure_api_token = "test_sysdig_secure_api_token" | ||
} | ||
|
||
resource "sysdig_secure_cloud_auth_account" "gcp_project_mytestproject" { | ||
enabled = true | ||
provider_id = "mytestproject" | ||
provider_type = "PROVIDER_GCP" | ||
|
||
feature { | ||
|
||
secure_threat_detection { | ||
enabled = true | ||
components = ["COMPONENT_WEBHOOK_DATASOURCE/secure-runtime"] | ||
} | ||
} | ||
component { | ||
type = "COMPONENT_WEBHOOK_DATASOURCE" | ||
instance = "secure-runtime" | ||
} | ||
component { | ||
type = "COMPONENT_SERVICE_PRINCIPAL" | ||
instance = "secure-onboarding" | ||
service_principal_metadata = jsonencode({ | ||
gcp = { | ||
key = module.organization-posture.service_account_key | ||
} | ||
}) | ||
} | ||
} | ||
|
||
resource "sysdig_secure_organization" "gcp_organization_mytestproject" { | ||
management_account_id = sysdig_secure_cloud_auth_account.gcp_project_mytestproject.id | ||
depends_on = [module.organization-posture] | ||
} | ||
|
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,44 @@ | ||
provider "google" { | ||
project = "mytestproject" | ||
region = "us-west1" | ||
} | ||
|
||
module "single-project-threat-detection" { | ||
source = "../../../..//modules/services/webhook-datasource" | ||
project_id = "mytestproject" | ||
push_endpoint = "test_sysdig_secure_cloudingestion_endpoint" | ||
} | ||
|
||
terraform { | ||
|
||
required_providers { | ||
sysdig = { | ||
source = "sysdiglabs/sysdig" | ||
version = "~> 1.18.2" | ||
} | ||
} | ||
} | ||
|
||
provider "sysdig" { | ||
sysdig_secure_url = "test_sysdig_secure_endpoint" | ||
sysdig_secure_api_token = "test_sysdig_secure_api_token" | ||
} | ||
|
||
resource "sysdig_secure_cloud_auth_account" "gcp_project_mytestproject" { | ||
enabled = true | ||
provider_id = "mytestproject" | ||
provider_type = "PROVIDER_GCP" | ||
|
||
feature { | ||
|
||
secure_threat_detection { | ||
enabled = true | ||
components = ["COMPONENT_WEBHOOK_DATASOURCE/secure-runtime"] | ||
} | ||
} | ||
component { | ||
type = "COMPONENT_WEBHOOK_DATASOURCE" | ||
instance = "secure-runtime" | ||
} | ||
} | ||
|
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,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
test -n "${EXAMPLES}" || EXAMPLES=$(find examples -type f -name main.tf) | ||
|
||
for example in ${EXAMPLES} ; do | ||
printf "Functional testing - ${example}\n" | ||
example_dir="$(dirname ${example})" | ||
test -d "${example_dir}" || (printf "not an example directory: ${example_dir}\n" ; exit 1) | ||
pushd "${example_dir}" | ||
# run | ||
terraform init | ||
terraform validate | ||
|
||
# cleanup (except configuration file) | ||
git clean -fxde main.tf | ||
popd | ||
done |