Skip to content

Commit

Permalink
Remove incorrect validation of app service sticky setting names (#17209)
Browse files Browse the repository at this point in the history
  • Loading branch information
jennings authored Jun 24, 2022
1 parent e036fd3 commit 0cebe71
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 45 deletions.
5 changes: 2 additions & 3 deletions internal/services/appservice/helpers/shared_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strings"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web"
appserviceValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/validate"
networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down Expand Up @@ -1554,7 +1553,7 @@ func StickySettingsSchema() *pluginsdk.Schema {
Optional: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
ValidateFunc: appserviceValidate.AppSettingName,
ValidateFunc: validation.StringIsNotEmpty,
},
AtLeastOneOf: []string{
"sticky_settings.0.app_setting_names",
Expand All @@ -1568,7 +1567,7 @@ func StickySettingsSchema() *pluginsdk.Schema {
Optional: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
ValidateFunc: appserviceValidate.AppSettingName,
ValidateFunc: validation.StringIsNotEmpty,
},
AtLeastOneOf: []string{
"sticky_settings.0.app_setting_names",
Expand Down
20 changes: 0 additions & 20 deletions internal/services/appservice/validate/app_setting_name.go

This file was deleted.

29 changes: 18 additions & 11 deletions internal/services/appservice/windows_function_app_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ func TestAccWindowsFunctionApp_stickySettings(t *testing.T) {
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("app_settings.foo").HasValue("bar"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.0").HasValue("foo"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.0").HasValue("First"),
),
},
Expand All @@ -304,9 +304,9 @@ func TestAccWindowsFunctionApp_stickySettingsUpdate(t *testing.T) {
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("app_settings.foo").HasValue("bar"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.0").HasValue("foo"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.0").HasValue("First"),
),
},
Expand All @@ -328,9 +328,9 @@ func TestAccWindowsFunctionApp_stickySettingsUpdate(t *testing.T) {
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("app_settings.foo").HasValue("bar"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.0").HasValue("foo"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.0").HasValue("First"),
),
},
Expand Down Expand Up @@ -1256,9 +1256,10 @@ resource "azurerm_windows_function_app" "test" {
site_config {}
app_settings = {
foo = "bar"
secret = "sauce"
third = "degree"
foo = "bar"
secret = "sauce"
third = "degree"
"Special chars: !@#$%%^&*()_+-=' \";/?" = "Supported by the Azure portal"
}
connection_string {
Expand All @@ -1279,9 +1280,15 @@ resource "azurerm_windows_function_app" "test" {
type = "PostgreSQL"
}
connection_string {
name = "Special chars: !@#$%%^&*()_+-=' \";/?"
value = "characters-supported-by-the-Azure-portal"
type = "Custom"
}
sticky_settings {
app_setting_names = ["foo", "secret"]
connection_string_names = ["First", "Third"]
app_setting_names = ["foo", "secret", "Special chars: !@#$%%^&*()_+-=' \";/?"]
connection_string_names = ["First", "Third", "Special chars: !@#$%%^&*()_+-=' \";/?"]
}
}
`, r.template(data, SkuStandardPlan), data.RandomInteger)
Expand Down
29 changes: 18 additions & 11 deletions internal/services/appservice/windows_web_app_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -935,9 +935,9 @@ func TestAccWindowsWebApp_stickySettings(t *testing.T) {
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("app_settings.foo").HasValue("bar"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.0").HasValue("foo"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.0").HasValue("First"),
),
},
Expand All @@ -964,9 +964,9 @@ func TestAccWindowsWebApp_stickySettingsUpdate(t *testing.T) {
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("app_settings.foo").HasValue("bar"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.0").HasValue("foo"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.0").HasValue("First"),
),
},
Expand All @@ -988,9 +988,9 @@ func TestAccWindowsWebApp_stickySettingsUpdate(t *testing.T) {
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("app_settings.foo").HasValue("bar"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.app_setting_names.0").HasValue("foo"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("2"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.#").HasValue("3"),
check.That(data.ResourceName).Key("sticky_settings.0.connection_string_names.0").HasValue("First"),
),
},
Expand Down Expand Up @@ -2512,9 +2512,10 @@ resource "azurerm_windows_web_app" "test" {
site_config {}
app_settings = {
foo = "bar"
secret = "sauce"
third = "degree"
foo = "bar"
secret = "sauce"
third = "degree"
"Special chars: !@#$%%^&*()_+-=' \";/?" = "Supported by the Azure portal"
}
connection_string {
Expand All @@ -2535,9 +2536,15 @@ resource "azurerm_windows_web_app" "test" {
type = "PostgreSQL"
}
connection_string {
name = "Special chars: !@#$%%^&*()_+-=' \";/?"
value = "characters-supported-by-the-Azure-portal"
type = "Custom"
}
sticky_settings {
app_setting_names = ["foo", "secret"]
connection_string_names = ["First", "Third"]
app_setting_names = ["foo", "secret", "Special chars: !@#$%%^&*()_+-=' \";/?"]
connection_string_names = ["First", "Third", "Special chars: !@#$%%^&*()_+-=' \";/?"]
}
}
`, r.baseTemplate(data), data.RandomInteger)
Expand Down

0 comments on commit 0cebe71

Please sign in to comment.