Skip to content

Commit

Permalink
v2.5.0 (#147)
Browse files Browse the repository at this point in the history
v2.5.0 terraform changes
  • Loading branch information
chkp-adambar authored Jun 15, 2023
1 parent 9e56a0f commit 64c72cc
Show file tree
Hide file tree
Showing 104 changed files with 5,876 additions and 50 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 2.5.0 (June 13, 2023)

FEATURES
* **New Resource:** `resouce_checkpoint_management_service_gtp`
* **New Resource:** `resouce_checkpoint_management_smart_task`
* **New Resource:** `resouce_checkpoint_management_server_certificate`
* **New Data Source:** `data_source_checkpoint_management_threat_rule_exception_rulebase`
* **New Data Source:** `data_source_checkpoint_management_smart_task`
* **New Data Source:** `data_source_checkpoint_management_service_gtp`
* **New Data Source:** `data_source_checkpoint_management_server_certificate`

BUG FIXES
* Fix issue in `fetch_policy` field in the read function of `checkpoint_management_simple_cluster` resource and data source.
* Fix issue in `applied_threat_rules` field in `checkpoint_management_exception_group` update function.
* Add the `ignore_warnings` and `ignore_errors` flags to multiple resources if they were missing.

## 2.4.0 (May 4, 2023)

ENHANCEMENTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func TestAccDataSourceCheckpointManagementCheckpointHost_basic(t *testing.T) {
}

func testAccDataSourceManagementCheckpointHostConfig(name string, ipv4Address string) string {
return fmt.Sprintf(`
resource "checkpoint_management_checkpoint_host" "checkpoint_host" {
name = "%s"
ipv4_address = "%s"
}
return fmt.Sprintf(
`resource "checkpoint_management_checkpoint_host" "checkpoint_host" {
name = "%s"
ipv4_address = "%s"
}
data "checkpoint_management_checkpoint_host" "data_checkpoint_host" {
name = "${checkpoint_management_checkpoint_host.checkpoint_host.name}"
Expand Down
97 changes: 97 additions & 0 deletions checkpoint/data_source_checkpoint_management_server_certificate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package checkpoint

import (
"fmt"
checkpoint "github.com/CheckPointSW/cp-mgmt-api-go-sdk/APIFiles"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"log"
)

func dataSourceManagementServerCertificate() *schema.Resource {
return &schema.Resource{

Read: dataSourceManagementServerCertificateRead,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Object name.",
},
"uid": {
Type: schema.TypeString,
Optional: true,
Description: "Object name.",
},
"subject": {
Type: schema.TypeString,
Computed: true,
Description: "Certificate's subject.",
},
"valid_from": {
Type: schema.TypeString,
Computed: true,
Description: "Server certificate valid from date.",
},
"valid_to": {
Type: schema.TypeString,
Computed: true,
Description: "Server certificate valid up to date.",
},
"comments": {
Type: schema.TypeString,
Computed: true,
Description: "Server certificate comments.",
},
},
}
}
func dataSourceManagementServerCertificateRead(d *schema.ResourceData, m interface{}) error {

client := m.(*checkpoint.ApiClient)

name := d.Get("name").(string)
uid := d.Get("uid").(string)

payload := make(map[string]interface{})

if name != "" {
payload["name"] = name
} else if uid != "" {
payload["uid"] = uid
}
showServerCertificateRes, err := client.ApiCall("show-server-certificate", payload, client.GetSessionID(), true, client.IsProxyUsed())
if err != nil {
return fmt.Errorf(err.Error())
}
if !showServerCertificateRes.Success {
fmt.Errorf(showServerCertificateRes.ErrorMsg)
}

serverCertificate := showServerCertificateRes.GetData()

log.Println("Read ServerCertificate - Show JSON ", serverCertificate)

if v := serverCertificate["uid"]; v != nil {
_ = d.Set("uid", v)
d.SetId(v.(string))
}

if v := serverCertificate["name"]; v != nil {
_ = d.Set("name", v)
}

if v := serverCertificate["subject"]; v != nil {
_ = d.Set("subject", v)
}
if v := serverCertificate["valid-from"]; v != nil {
_ = d.Set("valid_from", v)
}
if v := serverCertificate["valid-to"]; v != nil {
_ = d.Set("valid_to", v)
}
if v := serverCertificate["comments"]; v != nil {
_ = d.Set("comments", v)
}

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package checkpoint

import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"os"
"testing"
)

func TestAccDataSourceCheckpointManagementServerCertificate_basic(t *testing.T) {

objName := "tfTestManagementDataServerCertificate" + acctest.RandString(6)
resourceName := "checkpoint_management_server_certificate.cert1"
dataSourceName := "data.checkpoint_management_server_certificate.data"

base64_cert := "MIIKSAIBAzCCCg4GCSqGSIb3DQEHAaCCCf8Eggn7MIIJ9zCCBI8GCSqGSIb3DQEHBqCCBIAwggR8AgEAMIIEdQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQILAfxjBi7DTQCAggAgIIESKgKoClNx4YyTQr7xfIgSBSDs0It2vVsLubNFJpbQXzJUu2WaPQPbqV3wISpWCa/auLYC9OWpTI89HFt30rVAdWCFVoty7jI6L8HjTYa8fTGyqW7PyfoGyZclmz6totsmeVWc8i7wnl9Hk8NZpLWuixNoSLQUqBoloyZENll3i3/Z+/6mDlYkRmpCMQA2YLQm1yc/3n7Fq6grBJDro0tIIoAwIzgCdoKqIMwlDNA9c0eaHeXsP4k9WfJQbK6AyLTvHbrrNrgUyEDJQI6BCkeQwkBW2zRUHoe7s1DSQ5Rwft4koIaDcGovLES5g1gnXzmMr4/23+rf4/EZszB0QvlYvZIKLQ8O2ofvZ/HK+59fxlhKEiEkW2yhezDGR9s6hZnzZ8vMutisQJ8MO0m9iKVD5AAtif/32iy5+TVIQfqgER+DYVGOuk15YF2VcZGRlQ8pSvBXIkMMUDRqjFxQfKYIMlyk6RuSSgmIn+EIA9GfaBmEGy2xJYvw6IkUJ+xoR+SYeLYiMw+HkzI+cCOKF7fKPXlOCVvnESEeKwJ4inSxiI2GQG01aN/GNdsx/EM1Xi2LSHfzhG9URIOhjuJIQZn2Z7f3fpTxpWWCpEEVjcQZhoR0KX0DJ/gIx/iY8UsbNo58FTq5AwMFY6m8hxlHOorqh0MSE/x8LKq0v7JKIxQwrdkyUlVUqdaGreW5MgRdjqOrxQx53nLPdQelKWbR8Gn4KkwFcYCAB1VAe944zqq6YKL4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ccw08xy5Iwnww4v5Cz5bcNyRLFOU2/bfn7SC5mcQ/Tw5ZKOQVRn88G78amMPHNRqX4RzPtIwmK+B3zPJX0MHrY3w5hzPZ0UCtR2YsbYLeqsYP6b+RBLSV3wtkUZ9PgbMeu7zXSE0z1svGpjF7yWpnP47ilbxwe1YXL5+CuqN6iHFfyaP1JPYILmHdw0gzgyOdo1y4rUXgCeiCyH4vJVLts8ERKpXZDMCUmujb306IOD9haFXdQHV5XlQurtw+JC7ySe9bVMrzYJv5/oPioOXMnLPI2OXYbACwlQ/UHgl5LmDlsxeairdfYTdAxajFEMB0GCSqGSIb3DQEJFDEQHg4AbQB5AGEAbABpAGEAczAjBgkqhkiG9w0BCRUxFgQU7cUIcmKuQKAMfwbKiKzQozUsyHwwMTAhMAkGBSsOAwIaBQAEFEFoI0QTIv2s2lR8PxS8xfiT5S06BAjANT3YLoakoAICCAA="
base64_pass := "bXlfcGFzc3dvcmQ="

context := os.Getenv("CHECKPOINT_CONTEXT")
if context != "web_api" {
t.Skip("Skipping management test")
}
resource.Test(t, resource.TestCase{

PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceServerCertificateConfig(objName, base64_cert, base64_pass),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "name", resourceName, "name")),
},
},
})
}

func testAccDataSourceServerCertificateConfig(name string, base64Cert string, base64Pass string) string {
return fmt.Sprintf(
`
resource "checkpoint_management_server_certificate" "cert1" {
name = "%s"
base64_certificate = "%s"
base64_password = "%s"
}
data "checkpoint_management_server_certificate" "data" {
name = "${checkpoint_management_server_certificate.cert1.name}"
}
`, name, base64Cert, base64Pass)
}
Loading

0 comments on commit 64c72cc

Please sign in to comment.