diff --git a/examples/okta_network_zone/basic.tf b/examples/okta_network_zone/basic.tf index bf21bc3c..69e267a7 100644 --- a/examples/okta_network_zone/basic.tf +++ b/examples/okta_network_zone/basic.tf @@ -1,12 +1,12 @@ resource "okta_network_zone" "ip_network_zone_example" { - name = "IP Network Zone Example" - type = "IP" - gateways = [ "1.2.3.4/24", "2.3.4.5-2.3.4.15" ] - proxies = [ "2.2.3.4/24", "3.3.4.5-3.3.4.15" ] + name = "testAcc_replace_with_uuid" + type = "IP" + gateways = ["1.2.3.4/24", "2.3.4.5-2.3.4.15"] + proxies = ["2.2.3.4/24", "3.3.4.5-3.3.4.15"] } resource "okta_network_zone" "dynamic_network_zone_example" { - name = "Dynamic Network Zone Example" - type = "DYNAMIC" - dynamic_locations = [ "US", "AF-BGL" ] -} \ No newline at end of file + name = "testAcc_replace_with_uuid Dynamic" + type = "DYNAMIC" + dynamic_locations = ["US", "AF-BGL"] +} diff --git a/examples/okta_network_zone/basic_updated.tf b/examples/okta_network_zone/basic_updated.tf new file mode 100644 index 00000000..8d37d6ef --- /dev/null +++ b/examples/okta_network_zone/basic_updated.tf @@ -0,0 +1,12 @@ +resource "okta_network_zone" "ip_network_zone_example" { + name = "testAcc_replace_with_uuid Updated" + type = "IP" + gateways = ["1.2.3.4/24", "2.3.4.5-2.3.4.10"] + proxies = ["2.2.3.4/24", "3.3.4.5-3.3.4.10"] +} + +resource "okta_network_zone" "dynamic_network_zone_example" { + name = "testAcc_replace_with_uuid Dynamic Updated" + type = "DYNAMIC" + dynamic_locations = ["US", "AF-BGL"] +} diff --git a/okta/resource_network_zone_test.go b/okta/resource_network_zone_test.go index 52964bc4..ef1e73c7 100644 --- a/okta/resource_network_zone_test.go +++ b/okta/resource_network_zone_test.go @@ -1 +1,51 @@ package okta + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccNetworkZone(t *testing.T) { + ri := acctest.RandInt() + mgr := newFixtureManager(networkZone) + config := mgr.GetFixtures("basic.tf", ri, t) + updatedConfig := mgr.GetFixtures("basic_updated.tf", ri, t) + resourceName := fmt.Sprintf("%s.ip_network_zone_example", networkZone) + dynamicResourceName := fmt.Sprintf("%s.dynamic_network_zone_example", networkZone) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "name", fmt.Sprintf("testAcc_%d", ri)), + resource.TestCheckResourceAttr(resourceName, "type", "IP"), + resource.TestCheckResourceAttr(resourceName, "proxies.#", "2"), + resource.TestCheckResourceAttr(resourceName, "gateways.#", "2"), + + resource.TestCheckResourceAttr(dynamicResourceName, "name", fmt.Sprintf("testAcc_%d Dynamic", ri)), + resource.TestCheckResourceAttr(dynamicResourceName, "type", "DYNAMIC"), + resource.TestCheckResourceAttr(dynamicResourceName, "dynamic_locations.#", "2"), + ), + }, + { + Config: updatedConfig, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "name", fmt.Sprintf("testAcc_%d Updated", ri)), + resource.TestCheckResourceAttr(resourceName, "type", "IP"), + resource.TestCheckResourceAttr(resourceName, "proxies.#", "2"), + resource.TestCheckResourceAttr(resourceName, "gateways.#", "2"), + + resource.TestCheckResourceAttr(dynamicResourceName, "name", fmt.Sprintf("testAcc_%d Dynamic Updated", ri)), + resource.TestCheckResourceAttr(dynamicResourceName, "type", "DYNAMIC"), + resource.TestCheckResourceAttr(dynamicResourceName, "dynamic_locations.#", "2"), + ), + }, + }, + }) +}