Skip to content

Commit

Permalink
New Resources: wiz_integration_servicenow (#94)
Browse files Browse the repository at this point in the history
New Resources: wiz_integration_servicenow (#94)
  • Loading branch information
gramsa49 authored Apr 24, 2023
1 parent b04725b commit c99f7ef
Show file tree
Hide file tree
Showing 9 changed files with 468 additions and 4 deletions.
53 changes: 53 additions & 0 deletions docs/resources/integration_servicenow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "wiz_integration_servicenow Resource - terraform-provider-wiz"
subcategory: ""
description: |-
Integrations are reusable, generic connections between Wiz and third-party platforms like Slack, Google Chat, and Jira that allow data from Wiz to be passed to your preferred tool.
---

# wiz_integration_servicenow (Resource)

Integrations are reusable, generic connections between Wiz and third-party platforms like Slack, Google Chat, and Jira that allow data from Wiz to be passed to your preferred tool.

## Example Usage

```terraform
resource "wiz_integration_servicenow" "default" {
name = "default"
servicenow_url = var.servicename_url
servicenow_username = var.servicenow_username
servicenow_password = var.servicenow_password
scope = "All Resources, Restrict this Integration to global roles only"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name of the integration.
- `servicenow_password` (String, Sensitive) ServiceNow password. (default: none, environment variable: WIZ_INTEGRATION_SERVICENOW_PASSWORD)
- `servicenow_url` (String) ServiceNow URL. (default: none, environment variable: WIZ_INTEGRATION_SERVICENOW_URL)
- `servicenow_username` (String) Email of a ServiceNow user with permissions to create tickets. (default: none, environment variable: WIZ_INTEGRATION_SERVICENOW_USERNAME)

### Optional

- `project_id` (String) The project this action is scoped to.
- `scope` (String) Scoping to a selected Project makes this Integration accessible only to users with global roles or Project-scoped access to the selected Project. Other users will not be able to see it, use it, or view its results. Integrations restricted to global roles cannot be seen or used by users with Project-scoped roles.
- Allowed values:
- Selected Project
- All Resources
- All Resources, Restrict this Integration to global roles only

- Defaults to `All Resources, Restrict this Integration to global roles only`.
- `servicenow_client_id` (String) ServiceNow OAuth Client ID. (default: none, environment variable: WIZ_INTEGRATION_SERVICENOW_CLIENT_ID)
- `servicenow_client_secret` (String, Sensitive) ServiceNow OAuth Client Secret. (default: none, environment variable: WIZ_INTEGRATION_SERVICENOW_CLIENT_SECRET)

### Read-Only

- `created_at` (String) Identifies the date and time when the object was created.
- `id` (String) Identifier for this object.


7 changes: 7 additions & 0 deletions examples/resources/wiz_integration_servicenow/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "wiz_integration_servicenow" "default" {
name = "default"
servicenow_url = var.servicename_url
servicenow_username = var.servicenow_username
servicenow_password = var.servicenow_password
scope = "All Resources, Restrict this Integration to global roles only"
}
24 changes: 24 additions & 0 deletions internal/acceptance/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,27 @@ func testAccPreCheck(t *testing.T) {
t.Fatal("WIZ_AUTH_CLIENT_SECRET must be set for acceptance tests")
}
}

func testAccPreCheckIntegrationServiceNow(t *testing.T) {
// You can add code here to run prior to any test case execution, for example assertions
// about the appropriate environment variables being set are common to see in a pre-check
// function.
if v := os.Getenv("WIZ_URL"); v == "" {
t.Fatal("WIZ_URL must be set for acceptance tests")
}
if v := os.Getenv("WIZ_AUTH_CLIENT_ID"); v == "" {
t.Fatal("WIZ_AUTH_CLIENT_ID must be set for acceptance tests")
}
if v := os.Getenv("WIZ_AUTH_CLIENT_SECRET"); v == "" {
t.Fatal("WIZ_AUTH_CLIENT_SECRET must be set for acceptance tests")
}
if v := os.Getenv("WIZ_INTEGRATION_SERVICENOW_URL"); v == "" {
t.Fatal("WIZ_INTEGRATION_SERVICENOW_URL must be set for wiz_integration_servicenow acceptance tests")
}
if v := os.Getenv("WIZ_INTEGRATION_SERVICENOW_USERNAME"); v == "" {
t.Fatal("WIZ_INTEGRATION_SERVICENOW_USERNAME must be set for wiz_integration_servicenow acceptance tests")
}
if v := os.Getenv("WIZ_INTEGRATION_SERVICENOW_PASSWORD"); v == "" {
t.Fatal("WIZ_INTEGRATION_SERVICENOW_PASSWORD must be set for wiz_integration_servicenow acceptance tests")
}
}
55 changes: 55 additions & 0 deletions internal/acceptance/resource_integration_servicenow_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package acceptance

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

func TestAccResourceWizIntegrationServiceNow_basic(t *testing.T) {
rName := acctest.RandomWithPrefix(ResourcePrefix)

resource.UnitTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheckIntegrationServiceNow(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testResourceWizIntegrationServiceNowBasic(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"wiz_integration_servicenow.foo",
"name",
rName,
),
resource.TestCheckResourceAttr(
"wiz_integration_servicenow.foo",
"servicenow_url",
os.Getenv("WIZ_INTEGRATION_SERVICENOW_URL"),
),
resource.TestCheckResourceAttr(
"wiz_integration_servicenow.foo",
"servicenow_username",
os.Getenv("WIZ_INTEGRATION_SERVICENOW_USERNAME"),
),
resource.TestCheckResourceAttr(
"wiz_integration_servicenow.foo",
"scope",
"All Resources, Restrict this Integration to global roles only",
),
),
},
},
})
}

func testResourceWizIntegrationServiceNowBasic(rName string) string {
return fmt.Sprintf(`
resource "wiz_integration_servicenow" "foo" {
name = "%s"
scope = "All Resources, Restrict this Integration to global roles only"
}
`, rName)
}
4 changes: 2 additions & 2 deletions internal/acceptance/resource_saml_idp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestAccResourceWizSAMLIdp_basic(t *testing.T) {
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: TestAccResourceWizSAMLIdp_basic(rName),
Config: testResourceWizSAMLIdpBasic(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"wiz_saml_idp.test",
Expand Down Expand Up @@ -54,7 +54,7 @@ func TestAccResourceWizSAMLIdp_basic(t *testing.T) {
})
}

func TestAccResourceWizSAMLIdp_basic(rName string) string {
func testResourceWizSAMLIdpBasic(rName string) string {
return fmt.Sprintf(`
resource "wiz_saml_idp" "test" {
name = "%s"
Expand Down
5 changes: 5 additions & 0 deletions internal/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,8 @@ var IntegrationScope = []string{
"All Resources",
"All Resources, Restrict this Integration to global roles only",
}

// ProviderServiceNowAuthorizationType is used to infer the type of Authorization struct used in wiz.ServiceNowIntegrationParams
type ProviderServiceNowAuthorizationType struct {
Type string `json:"type"`
}
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ yLyKQXhw2W2Xs0qLeC1etA+jTGDK4UfLeC0SF7FSi8o5LL21L8IzApar2pR/
"wiz_control_associations": resourceWizControlAssociations(),
"wiz_host_config_rule_associations": resourceWizHostConfigRuleAssociations(),
"wiz_integration_aws_sns": resourceWizIntegrationAwsSNS(),
"wiz_integration_servicenow": resourceWizIntegrationServiceNow(),
"wiz_project": resourceWizProject(),
"wiz_saml_idp": resourceWizSAMLIdP(),
"wiz_security_framework": resourceWizSecurityFramework(),
Expand Down
Loading

0 comments on commit c99f7ef

Please sign in to comment.