diff --git a/internal/services/synapse/synapse_sql_pool_resource_test.go b/internal/services/synapse/synapse_sql_pool_resource_test.go index 93d11847e10c..0ca9469eaba0 100644 --- a/internal/services/synapse/synapse_sql_pool_resource_test.go +++ b/internal/services/synapse/synapse_sql_pool_resource_test.go @@ -30,6 +30,21 @@ func TestAccSynapseSqlPool_basic(t *testing.T) { }) } +func TestAccSynapseSqlPool_utf8(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_synapse_sql_pool", "test") + r := SynapseSqlPoolResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.utf8(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccSynapseSqlPool_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_synapse_sql_pool", "test") r := SynapseSqlPoolResource{} @@ -124,6 +139,24 @@ resource "azurerm_synapse_sql_pool" "test" { `, template, data.RandomString) } +func (r SynapseSqlPoolResource) utf8(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_synapse_sql_pool" "test" { + name = "販売管理" + synapse_workspace_id = azurerm_synapse_workspace.test.id + sku_name = "DW100c" + create_mode = "Default" +} +`, template) +} + func (r SynapseSqlPoolResource) requiresImport(data acceptance.TestData) string { config := r.basic(data) return fmt.Sprintf(` diff --git a/internal/services/synapse/validate/sql_pool_name.go b/internal/services/synapse/validate/sql_pool_name.go index b290872b97c6..fa4afdade4f4 100644 --- a/internal/services/synapse/validate/sql_pool_name.go +++ b/internal/services/synapse/validate/sql_pool_name.go @@ -13,10 +13,10 @@ func SqlPoolName(i interface{}, k string) (warnings []string, errors []error) { } // The name attribute rules are : - // 1. can contain only letters, numbers and underscore. - // 2. The value must be between 1 and 15 characters long - - if !regexp.MustCompile(`^[a-zA-Z_\d]{1,15}$`).MatchString(v) { + // 1. can't contain '<,>,*,%,&,:,\,/,?,@,-' or control characters + // 2. can't end with '.' or ' ' + // 3. The value must be between 1 and 60 characters long + if !regexp.MustCompile(`^[^<>*%&:\\\/?@-]{0,59}[^\s.<>*%&:\\\/?@-]$`).MatchString(v) { errors = append(errors, fmt.Errorf("%s can contain only letters, numbers or underscore, The value must be between 1 and 15 characters long", k)) return } diff --git a/internal/services/synapse/validate/sql_pool_name_test.go b/internal/services/synapse/validate/sql_pool_name_test.go index 4a4f5a1e665f..c4af744b1ce6 100644 --- a/internal/services/synapse/validate/sql_pool_name_test.go +++ b/internal/services/synapse/validate/sql_pool_name_test.go @@ -19,19 +19,34 @@ func TestSqlPoolName(t *testing.T) { input: "aBc_123", expected: true, }, + { + // UTF-8 + input: "販売管理", + expected: true, + }, { // can't contain hyphen input: "ab-c", expected: false, }, { - // 15 chars - input: "abcdefghijklmno", + // can't end with . + input: "abc.", + expected: false, + }, + { + // can't end with space + input: "abc ", + expected: false, + }, + { + // 60 chars + input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh", expected: true, }, { - // 16 chars - input: "abcdefghijklmnop", + // 61 chars + input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi", expected: false, }, }