Skip to content

Commit

Permalink
acctest zeroedIpRestrictionHeaders
Browse files Browse the repository at this point in the history
  • Loading branch information
Aris van Ommeren committed Apr 20, 2021
1 parent 01b8202 commit 28c1cb1
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions azurerm/internal/services/web/app_service_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,41 @@ func TestAccAppService_zeroedIpRestriction(t *testing.T) {
})
}

func TestAccAppService_zeroedIpRestrictionHeaders(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_app_service", "test")
r := AppServiceResource{}

data.ResourceTest(t, r, []resource.TestStep{
{
// This configuration includes a single explicit ip_restriction
Config: r.completeIpRestriction(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("site_config.0.ip_restriction.#").HasValue("5"),
check.That(data.ResourceName).Key("site_config.0.ip_restriction.0.headers.#").HasValue("4"),
),
},
{
// This configuration has no site_config blocks at all.
Config: r.basic(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("site_config.0.ip_restriction.#").HasValue("1"),
check.That(data.ResourceName).Key("site_config.0.ip_restriction.0.headers.#").HasValue("4"),
),
},
{
// This configuration explicitly sets ip_restriction.headers to [] using attribute syntax.
Config: r.zeroedIpRestrictionHeaders(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("site_config.0.ip_restriction.#").HasValue("1"),
check.That(data.ResourceName).Key("site_config.0.ip_restriction.0.headers.#").HasValue("0"),
),
},
})
}

func TestAccAppService_manyIpRestrictions(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_app_service", "test")
r := AppServiceResource{}
Expand Down Expand Up @@ -2989,6 +3024,47 @@ resource "azurerm_app_service" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (r AppServiceResource) zeroedIpRestrictionHeaders(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_app_service_plan" "test" {
name = "acctestASP-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku {
tier = "Standard"
size = "S1"
}
}
resource "azurerm_app_service" "test" {
name = "acctestAS-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
app_service_plan_id = azurerm_app_service_plan.test.id
site_config {
ip_restriction {
ip_address = "10.10.10.10/32"
name = "test-restriction"
priority = 123
action = "Allow"
headers = []
}
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (r AppServiceResource) scmUseMainIPRestriction(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down

0 comments on commit 28c1cb1

Please sign in to comment.