Skip to content

Commit

Permalink
(fix) Added validation to enforce string length (#206)
Browse files Browse the repository at this point in the history
* (fix) Added validation to enforce string length

* (fix) Added validation to enforce string length

* Update to zscaler-sdk-go v1.2.2

* (fix) Added validation to enforce string length
  • Loading branch information
willguibr authored Mar 19, 2023
1 parent a38449c commit 35128f1
Show file tree
Hide file tree
Showing 26 changed files with 441 additions and 137 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 2.5.0 (March, 20 2023)

### Notes

- Release date: **(March, 20 2023)**
- Supported Terraform version: **v1.x**

### Ehancements

- [PR #202](https://github.com/zscaler/terraform-provider-zia/pull/202) ``zia_user_management``: Implemented new attribute ``auth_methods``. The attribute supports the following values: ``BASIC`` and/or ``DIGEST``.
- ``zia_location_management``: Implemented new attribute ``basic_auth_enabled``. The supported values are: ``true`` or ``false``

- [PR #202](https://github.com/zscaler/terraform-provider-zia/pull/202) The provider now supports authentication to Zscaler ``preview`` and ``zscalerten`` clouds.

### Fixes

- [PR #202](https://github.com/zscaler/terraform-provider-zia/pull/202) ``zia_user_management``: Fixed flattening function to expand group attribute values.

## 2.4.6 (March, 6 2023)

### Notes
Expand Down
6 changes: 3 additions & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ build: fmtcheck
build13: GOOS=$(shell go env GOOS)
build13: GOARCH=$(shell go env GOARCH)
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/2.4.6/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/2.5.0/$(GOOS)_$(GOARCH)
else
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/2.4.6/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/2.5.0/$(GOOS)_$(GOARCH)
endif
build13: fmtcheck
go mod tidy && go mod vendor
@echo "==> Installing plugin to $(DESTINATION)"
@mkdir -p $(DESTINATION)
go build -o $(DESTINATION)/terraform-provider-zia_v2.4.6
go build -o $(DESTINATION)/terraform-provider-zia_v2.5.0

test: fmtcheck
go test $(TEST) || exit 1
Expand Down
20 changes: 19 additions & 1 deletion docs/guides/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,28 @@ description: |-
Track all ZIA Terraform provider's releases. New resources, features, and bug fixes will be tracked here.

---
``Last updated: v2.4.5``
``Last updated: v2.5.0``

---

## 2.5.0 (March, 20 2023)

### Notes

- Release date: **(March, 20 2023)**
- Supported Terraform version: **v1.x**

### Ehancements

- [PR #202](https://github.com/zscaler/terraform-provider-zia/pull/202) ``zia_user_management``: Implemented new attribute ``auth_methods``. The attribute supports the following values: ``BASIC`` and/or ``DIGEST``.
- ``zia_location_management``: Implemented new attribute ``basic_auth_enabled``. The supported values are: ``true`` or ``false``

- [PR #202](https://github.com/zscaler/terraform-provider-zia/pull/202) The provider now supports authentication to Zscaler ``preview`` and ``zscalerten`` clouds.

### Fixes

- [PR #202](https://github.com/zscaler/terraform-provider-zia/pull/202) ``zia_user_management``: Fixed flattening function to expand group attribute values.

## 2.4.6 (March, 6 2023)

### Notes
Expand Down
1 change: 1 addition & 0 deletions examples/zia_dlp_notification_templates/basic.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
resource "zia_dlp_notification_templates" "terraform_dlp_template" {
name = "Terraform DLP Template"
attach_content = true
tls_enabled = true
subject = local.subject
plain_text_message = local.msg_plain_text
html_message = local.msg_html
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/hashicorp/terraform-plugin-sdk/v2 v2.25.0
github.com/zscaler/zscaler-sdk-go v1.2.2
github.com/zscaler/zscaler-sdk-go v1.2.4
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY
github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0=
github.com/zscaler/zscaler-sdk-go v1.2.2 h1:PErgYlBBTpxx9Sta8TmcS0BdNf7bp34C2BvR6XMtfkw=
github.com/zscaler/zscaler-sdk-go v1.2.2/go.mod h1:h4cLV1/q579M0juEXKeU1HB1l3RHSuwTxn3xpBLLzjg=
github.com/zscaler/zscaler-sdk-go v1.2.4 h1:Gnl0q9Pe5YuhT3+XGaIfGDfU2wquJMO5tY29W/ehgic=
github.com/zscaler/zscaler-sdk-go v1.2.4/go.mod h1:h4cLV1/q579M0juEXKeU1HB1l3RHSuwTxn3xpBLLzjg=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
Expand Down
1 change: 1 addition & 0 deletions zia/common/resourcetype/resource_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
TrafficForwardingVPNCredentials = "zia_traffic_forwarding_vpn_credentials"
TrafficForwardingLocManagement = "zia_location_management"
DLPDictionaries = "zia_dlp_dictionaries"
DLPNotificationTemplates = "zia_dlp_notification_templates"
DLPWebRules = "zia_dlp_web_rules"
AdminUsers = "zia_admin_users"
Users = "zia_user_management"
Expand Down
6 changes: 6 additions & 0 deletions zia/common/testing/variable/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ const (
DLPDictionaryDescription = "this is an acceptance test"
)

// DLP Dictionaries resource/datasource
const (
DLPNoticationTemplateAttachContent = true
DLPNoticationTemplateTLSEnabled = true
)

// Admin Users
const (
AdminUserLoginName = "testAcc@bd-hashicorp.com"
Expand Down
41 changes: 24 additions & 17 deletions zia/data_source_zia_dlp_notification_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,41 @@ func dataSourceDLPNotificationTemplates() *schema.Resource {
Read: dataSourceDLPNotificationTemplatesRead,
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "The unique identifier for a DLP notification template",
},
"name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The DLP notification template name",
},
"subject": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Description: "The Subject line that is displayed within the DLP notification email",
},
"attach_content": {
Type: schema.TypeBool,
Computed: true,
Type: schema.TypeBool,
Computed: true,
Description: "f set to true, the content that is violation is attached to the DLP notification email",
},
"plain_test_message": {
Type: schema.TypeString,
Computed: true,
"plain_text_message": {
Type: schema.TypeString,
Computed: true,
Description: "The template for the plain text UTF-8 message body that must be displayed in the DLP notification email",
},
"html_message": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Description: "The template for the HTML message body that must be displayed in the DLP notification email",
},
"tls_enabled": {
Type: schema.TypeBool,
Computed: true,
Type: schema.TypeBool,
Computed: true,
Description: "If set to true, TLS will be enabled",
},
},
}
Expand Down
34 changes: 34 additions & 0 deletions zia/data_source_zia_dlp_notification_templates_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package zia

import (
"strconv"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/zscaler/terraform-provider-zia/v2/zia/common/resourcetype"
"github.com/zscaler/terraform-provider-zia/v2/zia/common/testing/method"
"github.com/zscaler/terraform-provider-zia/v2/zia/common/testing/variable"
)

func TestAccDataSourceDLPNotificationTemplates_Basic(t *testing.T) {
resourceTypeAndName, dataSourceTypeAndName, generatedName := method.GenerateRandomSourcesTypeAndName(resourcetype.DLPNotificationTemplates)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDLPNotificationTemplateDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckDLPNotificationTemplateConfigure(resourceTypeAndName, generatedName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "id", resourceTypeAndName, "id"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "name", resourceTypeAndName, "name"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "plain_text_message", resourceTypeAndName, "plain_text_message"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "html_message", resourceTypeAndName, "html_message"),
resource.TestCheckResourceAttr(dataSourceTypeAndName, "attach_content", strconv.FormatBool(variable.DLPNoticationTemplateAttachContent)),
resource.TestCheckResourceAttr(dataSourceTypeAndName, "tls_enabled", strconv.FormatBool(variable.DLPNoticationTemplateTLSEnabled)),
),
},
},
})
}
21 changes: 12 additions & 9 deletions zia/resource_zia_dlp_dictionaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ func resourceDLPDictionaries() *schema.Resource {
Computed: true,
},
"name": {
Type: schema.TypeString,
Optional: true,
Description: "The DLP dictionary's name",
Type: schema.TypeString,
Optional: true,
Description: "The DLP dictionary's name",
ValidateFunc: validation.StringLenBetween(0, 255),
},
"description": {
Type: schema.TypeString,
Optional: true,
Description: "The desciption of the DLP dictionary",
Type: schema.TypeString,
Optional: true,
Description: "The desciption of the DLP dictionary",
ValidateFunc: validation.StringLenBetween(0, 255),
},
"confidence_threshold": {
Type: schema.TypeString,
Expand Down Expand Up @@ -100,9 +102,10 @@ func resourceDLPDictionaries() *schema.Resource {
Description: "The action applied to a DLP dictionary using patterns",
},
"pattern": {
Type: schema.TypeString,
Optional: true,
Description: "DLP dictionary pattern",
Type: schema.TypeString,
Optional: true,
Description: "DLP dictionary pattern",
ValidateFunc: validation.StringLenBetween(0, 128),
},
},
},
Expand Down
42 changes: 26 additions & 16 deletions zia/resource_zia_dlp_notification_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
client "github.com/zscaler/zscaler-sdk-go/zia"
"github.com/zscaler/zscaler-sdk-go/zia/services/dlp_notification_templates"
)
Expand Down Expand Up @@ -39,36 +40,45 @@ func resourceDLPNotificationTemplates() *schema.Resource {

Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Description: "The unique identifier for a DLP notification template",
},
"template_id": {
Type: schema.TypeInt,
Computed: true,
Type: schema.TypeInt,
Computed: true,
Description: "The unique identifier for a DLP notification template",
},
"name": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringLenBetween(0, 255),
Description: "The DLP notification template name",
},
"subject": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Required: true,
Description: "The Subject line that is displayed within the DLP notification email",
},
"attach_content": {
Type: schema.TypeBool,
Optional: true,
Type: schema.TypeBool,
Optional: true,
Description: "f set to true, the content that is violation is attached to the DLP notification email",
},
"plain_text_message": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
Description: "The template for the plain text UTF-8 message body that must be displayed in the DLP notification email",
},
"html_message": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
Description: "The template for the HTML message body that must be displayed in the DLP notification email",
},
"tls_enabled": {
Type: schema.TypeBool,
Optional: true,
Type: schema.TypeBool,
Optional: true,
Description: "If set to true, TLS will be enabled",
},
},
}
Expand Down
Loading

0 comments on commit 35128f1

Please sign in to comment.