Skip to content
This repository has been archived by the owner on Jun 14, 2021. It is now read-only.

Commit

Permalink
Write tests around network zones
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumew committed Jul 24, 2019
1 parent d98abd8 commit c676326
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 8 deletions.
16 changes: 8 additions & 8 deletions 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" ]
}
name = "testAcc_replace_with_uuid Dynamic"
type = "DYNAMIC"
dynamic_locations = ["US", "AF-BGL"]
}
12 changes: 12 additions & 0 deletions 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"]
}
50 changes: 50 additions & 0 deletions 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"),
),
},
},
})
}

0 comments on commit c676326

Please sign in to comment.