-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enhaced acceptance test coverage
- Loading branch information
Showing
33 changed files
with
553 additions
and
171 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
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
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
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 |
---|---|---|
@@ -1,50 +1,53 @@ | ||
package zpa | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
var enrollementCertNames = []string{ | ||
"Root", "Client", "Connector", "Service Edge", | ||
} | ||
|
||
func TestAccDataSourceEnrollmentCert_Basic(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCheckDataSourceEnrollmentCertConfig_basic, | ||
Config: testAccCheckDataSourceEnrollmentCert_basic(), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccDataSourceEnrollmentCertCheck("data.zpa_enrollment_cert.root"), | ||
testAccDataSourceEnrollmentCertCheck("data.zpa_enrollment_cert.client"), | ||
testAccDataSourceEnrollmentCertCheck("data.zpa_enrollment_cert.connector"), | ||
testAccDataSourceEnrollmentCertCheck("data.zpa_enrollment_cert.service_edge"), | ||
generateEnrollmentCertChecks()..., | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceEnrollmentCertCheck(name string) resource.TestCheckFunc { | ||
return resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(name, "id"), | ||
resource.TestCheckResourceAttrSet(name, "name"), | ||
) | ||
} | ||
|
||
var testAccCheckDataSourceEnrollmentCertConfig_basic = ` | ||
data "zpa_enrollment_cert" "root" { | ||
name = "Root" | ||
func generateEnrollmentCertChecks() []resource.TestCheckFunc { | ||
var checks []resource.TestCheckFunc | ||
for _, name := range enrollementCertNames { | ||
resourceName := createValidResourceName(name) | ||
checkName := fmt.Sprintf("data.zpa_enrollment_cert.%s", resourceName) | ||
checks = append(checks, resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(checkName, "id"), | ||
resource.TestCheckResourceAttrSet(checkName, "name"), | ||
)) | ||
} | ||
return checks | ||
} | ||
|
||
data "zpa_enrollment_cert" "client" { | ||
name = "Client" | ||
func testAccCheckDataSourceEnrollmentCert_basic() string { | ||
var configs string | ||
for _, name := range enrollementCertNames { | ||
resourceName := createValidResourceName(name) | ||
configs += fmt.Sprintf(` | ||
data "zpa_enrollment_cert" "%s" { | ||
name = "%s" | ||
} | ||
data "zpa_enrollment_cert" "connector" { | ||
name = "Connector" | ||
} | ||
data "zpa_enrollment_cert" "service_edge" { | ||
name = "Service Edge" | ||
`, resourceName, name) | ||
} | ||
return configs | ||
} | ||
` |
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,69 +1,53 @@ | ||
package zpa | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
var lssConfigLogTypeFormatsNames = []string{ | ||
"zpn_ast_comprehensive_stats", "zpn_auth_log", "zpn_pbroker_comprehensive_stats", "zpn_ast_auth_log", "zpn_audit_log", | ||
"zpn_trans_log", "zpn_http_trans_log", "zpn_waf_http_exchanges_log", | ||
} | ||
|
||
func TestAccDataSourceLSSLogTypeFormats_Basic(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCheckDataSourceLSSLogTypeFormats_basic, | ||
Config: testAccCheckDataSourceLSSLogTypeFormats_basic(), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccDataSourceLSSLogTypeFormatsCheck("data.zpa_lss_config_log_type_formats.zpn_ast_comprehensive_stats"), | ||
testAccDataSourceLSSLogTypeFormatsCheck("data.zpa_lss_config_log_type_formats.zpn_auth_log"), | ||
testAccDataSourceLSSLogTypeFormatsCheck("data.zpa_lss_config_log_type_formats.zpn_pbroker_comprehensive_stats"), | ||
testAccDataSourceLSSLogTypeFormatsCheck("data.zpa_lss_config_log_type_formats.zpn_ast_auth_log"), | ||
testAccDataSourceLSSLogTypeFormatsCheck("data.zpa_lss_config_log_type_formats.zpn_audit_log"), | ||
testAccDataSourceLSSLogTypeFormatsCheck("data.zpa_lss_config_log_type_formats.zpn_trans_log"), | ||
testAccDataSourceLSSLogTypeFormatsCheck("data.zpa_lss_config_log_type_formats.zpn_http_trans_log"), | ||
testAccDataSourceLSSLogTypeFormatsCheck("data.zpa_lss_config_log_type_formats.zpn_waf_http_exchanges_log"), | ||
generateLSSConfigLogTypeFormatChecks()..., | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceLSSLogTypeFormatsCheck(log_type string) resource.TestCheckFunc { | ||
return resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(log_type, "log_type"), | ||
) | ||
} | ||
|
||
var testAccCheckDataSourceLSSLogTypeFormats_basic = ` | ||
data "zpa_lss_config_log_type_formats" "zpn_ast_comprehensive_stats" { | ||
log_type = "zpn_ast_comprehensive_stats" | ||
} | ||
data "zpa_lss_config_log_type_formats" "zpn_auth_log" { | ||
log_type = "zpn_auth_log" | ||
} | ||
data "zpa_lss_config_log_type_formats" "zpn_pbroker_comprehensive_stats" { | ||
log_type = "zpn_pbroker_comprehensive_stats" | ||
func generateLSSConfigLogTypeFormatChecks() []resource.TestCheckFunc { | ||
var checks []resource.TestCheckFunc | ||
for _, log_type := range lssConfigLogTypeFormatsNames { | ||
resourceName := createValidResourceName(log_type) | ||
checkName := fmt.Sprintf("data.zpa_lss_config_log_type_formats.%s", resourceName) | ||
checks = append(checks, resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(checkName, "log_type"), | ||
)) | ||
} | ||
return checks | ||
} | ||
|
||
data "zpa_lss_config_log_type_formats" "zpn_ast_auth_log" { | ||
log_type = "zpn_ast_auth_log" | ||
func testAccCheckDataSourceLSSLogTypeFormats_basic() string { | ||
var configs string | ||
for _, log_type := range lssConfigLogTypeFormatsNames { | ||
resourceName := createValidResourceName(log_type) | ||
configs += fmt.Sprintf(` | ||
data "zpa_lss_config_log_type_formats" "%s" { | ||
log_type = "%s" | ||
} | ||
data "zpa_lss_config_log_type_formats" "zpn_audit_log" { | ||
log_type = "zpn_audit_log" | ||
} | ||
data "zpa_lss_config_log_type_formats" "zpn_trans_log" { | ||
log_type = "zpn_trans_log" | ||
} | ||
data "zpa_lss_config_log_type_formats" "zpn_http_trans_log" { | ||
log_type = "zpn_http_trans_log" | ||
} | ||
data "zpa_lss_config_log_type_formats" "zpn_waf_http_exchanges_log" { | ||
log_type = "zpn_waf_http_exchanges_log" | ||
`, resourceName, log_type) | ||
} | ||
return configs | ||
} | ||
` |
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
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 @@ | ||
package zpa | ||
|
||
/* | ||
import ( | ||
"strconv" | ||
"testing" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/zscaler/terraform-provider-zpa/v3/zpa/common/resourcetype" | ||
"github.com/zscaler/terraform-provider-zpa/v3/zpa/common/testing/method" | ||
"github.com/zscaler/terraform-provider-zpa/v3/zpa/common/testing/variable" | ||
) | ||
func TestAccDataSourceMicrotenant_Basic(t *testing.T) { | ||
resourceTypeAndName, dataSourceTypeAndName, generatedName := method.GenerateRandomSourcesTypeAndName(resourcetype.ZPAMicrotenant) | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckMicroTenantDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCheckMicrotenantConfigure(resourceTypeAndName, generatedName, variable.MicrotenantDescription, variable.MicrotenantCriteriaAttribute, variable.MicrotenantEnabled), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "id", resourceTypeAndName, "id"), | ||
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "name", resourceTypeAndName, "name"), | ||
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "description", resourceTypeAndName, "description"), | ||
resource.TestCheckResourceAttr(resourceTypeAndName, "enabled", strconv.FormatBool(variable.MicrotenantEnabled)), | ||
resource.TestCheckResourceAttr(resourceTypeAndName, "criteria_attribute", variable.MicrotenantCriteriaAttribute), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
*/ |
Oops, something went wrong.