func resourceArmNetworkInterfaceIpConfigurationHash(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) buf.WriteString(fmt.Sprintf("%s-", m["name"].(string))) buf.WriteString(fmt.Sprintf("%s-", m["subnet_id"].(string))) if m["private_ip_address"] != nil { buf.WriteString(fmt.Sprintf("%s-", m["private_ip_address"].(string))) } buf.WriteString(fmt.Sprintf("%s-", m["private_ip_address_allocation"].(string))) if m["public_ip_address_id"] != nil { buf.WriteString(fmt.Sprintf("%s-", m["public_ip_address_id"].(string))) } if m["load_balancer_backend_address_pools_ids"] != nil { ids := m["load_balancer_backend_address_pools_ids"].(*schema.Set).List() for _, id := range ids { buf.WriteString(fmt.Sprintf("%d-", schema.HashString(id.(string)))) } } if m["load_balancer_inbound_nat_rules_ids"] != nil { ids := m["load_balancer_inbound_nat_rules_ids"].(*schema.Set).List() for _, id := range ids { buf.WriteString(fmt.Sprintf("%d-", schema.HashString(id.(string)))) } } return hashcode.String(buf.String()) }
func TestAccAzureSecurityGroupRuleBasic(t *testing.T) { name := "azure_security_group_rule.foo" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAzureSecurityGroupRuleDeleted([]string{testAccSecurityGroupName}), Steps: []resource.TestStep{ resource.TestStep{ Config: testAccAzureSecurityGroupRuleBasicConfig, Check: resource.ComposeTestCheckFunc( testAccCheckAzureSecurityGroupRuleExists(name, testAccSecurityGroupName), resource.TestCheckResourceAttr(name, "name", "terraform-secgroup-rule"), resource.TestCheckResourceAttr(name, fmt.Sprintf("security_group_names.%d", schema.HashString(testAccSecurityGroupName)), testAccSecurityGroupName), resource.TestCheckResourceAttr(name, "type", "Inbound"), resource.TestCheckResourceAttr(name, "action", "Deny"), resource.TestCheckResourceAttr(name, "priority", "200"), resource.TestCheckResourceAttr(name, "source_address_prefix", "100.0.0.0/32"), resource.TestCheckResourceAttr(name, "source_port_range", "1000"), resource.TestCheckResourceAttr(name, "destination_address_prefix", "10.0.0.0/32"), resource.TestCheckResourceAttr(name, "destination_port_range", "1000"), resource.TestCheckResourceAttr(name, "protocol", "TCP"), ), }, }, }) }
func TestBigipLtmVS_create(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAcctPreCheck(t) }, Providers: testAccProviders, CheckDestroy: resource.ComposeTestCheckFunc( testCheckVSsDestroyed, testCheckIRulesDestroyed, testCheckPolicyDestroyed, ), Steps: []resource.TestStep{ resource.TestStep{ Config: TEST_VS_RESOURCE, Check: resource.ComposeTestCheckFunc( testCheckVSExists(TEST_VS_NAME, true), resource.TestCheckResourceAttr("bigip_ltm_virtual_server.test-vs", "name", TEST_VS_NAME), resource.TestCheckResourceAttr("bigip_ltm_virtual_server.test-vs", "destination", "10.255.255.254"), resource.TestCheckResourceAttr("bigip_ltm_virtual_server.test-vs", "port", "9999"), resource.TestCheckResourceAttr("bigip_ltm_virtual_server.test-vs", "mask", "255.255.255.255"), resource.TestCheckResourceAttr("bigip_ltm_virtual_server.test-vs", "source_address_translation", "automap"), resource.TestCheckResourceAttr("bigip_ltm_virtual_server.test-vs", "ip_protocol", "tcp"), resource.TestCheckResourceAttr("bigip_ltm_virtual_server.test-vs", fmt.Sprintf("irules.%d", schema.HashString(TEST_IRULE_NAME)), TEST_IRULE_NAME), resource.TestCheckResourceAttr("bigip_ltm_virtual_server.test-vs", fmt.Sprintf("profiles.%d", schema.HashString("/Common/http")), "/Common/http"), resource.TestCheckResourceAttr("bigip_ltm_virtual_server.test-vs", fmt.Sprintf("client_profiles.%d", schema.HashString("/Common/tcp")), "/Common/tcp"), resource.TestCheckResourceAttr("bigip_ltm_virtual_server.test-vs", fmt.Sprintf("server_profiles.%d", schema.HashString("/Common/tcp-lan-optimized")), "/Common/tcp-lan-optimized"), resource.TestCheckResourceAttr("bigip_ltm_virtual_server.test-vs", fmt.Sprintf("policies.%d", schema.HashString(TEST_POLICY_NAME)), TEST_POLICY_NAME), ), }, }, }) }
func TestBigipLtmPolicy_create(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAcctPreCheck(t) }, Providers: testAccProviders, CheckDestroy: resource.ComposeTestCheckFunc( testCheckPolicyDestroyed, testCheckPoolsDestroyed, ), Steps: []resource.TestStep{ resource.TestStep{ Config: TEST_POLICY_RESOURCE, Check: resource.ComposeTestCheckFunc( testCheckPolicyExists(TEST_POLICY_NAME, true), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", "name", TEST_POLICY_NAME), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", fmt.Sprintf("controls.%d", schema.HashString("forwarding")), "forwarding"), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", fmt.Sprintf("requires.%d", schema.HashString("http")), "http"), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", "rule.0.name", TEST_RULE_NAME), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", "rule.0.condition.0.httpUri", "true"), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", "rule.0.condition.0.startsWith", "true"), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", "rule.0.condition.0.values.0", "/foo"), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", "rule.0.condition.0.values.1", "/bar"), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", "rule.0.condition.1.httpMethod", "true"), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", "rule.0.condition.1.values.0", "GET"), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", "rule.0.action.0.forward", "true"), resource.TestCheckResourceAttr("bigip_ltm_policy.test-policy", "rule.0.action.0.pool", TEST_POOL_NAME), ), }, }, }) }
package azure import ( "fmt" "testing" "github.com/Azure/azure-sdk-for-go/management" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" ) var ( testAcctestingSecurityGroup1 = fmt.Sprintf("%s-%d", testAccSecurityGroupName, 1) testAccTestingSecurityGroupHash1 = fmt.Sprintf("%d", schema.HashString(testAcctestingSecurityGroup1)) testAcctestingSecurityGroup2 = fmt.Sprintf("%s-%d", testAccSecurityGroupName, 2) testAccTestingSecurityGroupHash2 = fmt.Sprintf("%d", schema.HashString(testAcctestingSecurityGroup2)) ) func TestAccAzureSecurityGroupRuleBasic(t *testing.T) { name := "azure_security_group_rule.foo" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAzureSecurityGroupRuleDeleted([]string{testAccSecurityGroupName}), Steps: []resource.TestStep{ resource.TestStep{ Config: testAccAzureSecurityGroupRuleBasicConfig,
func stringScopeHashcode(v interface{}) int { v = canonicalizeServiceScope(v.(string)) return schema.HashString(v) }