From 214110bb35fc57775c273d16cd2fa63a3c2932ec Mon Sep 17 00:00:00 2001 From: Jonathan Eskew Date: Mon, 24 Feb 2025 13:12:35 -0500 Subject: [PATCH] Add positive test case --- .../ScenarioTests.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Bicep.Core.IntegrationTests/ScenarioTests.cs b/src/Bicep.Core.IntegrationTests/ScenarioTests.cs index 5643346f127..1e159f681aa 100644 --- a/src/Bicep.Core.IntegrationTests/ScenarioTests.cs +++ b/src/Bicep.Core.IntegrationTests/ScenarioTests.cs @@ -6966,6 +6966,31 @@ public void Modules_with_the_same_name_but_different_scopes_are_permitted() result.ExcludingLinterDiagnostics().Should().NotHaveAnyDiagnostics(); } + // https://github.com/azure/bicep/issues/15325 + [TestMethod] + public void Refinements_are_enforced_on_non_hierarchical_resource_names() + { + var result = CompilationHelper.Compile(""" + resource kv 'Microsoft.KeyVault/vaults@2019-09-01' existing = { + name: 'kv' + + resource secret 'secrets' = { + name: '!@#$' + properties: { + value: 'value' + } + } + } + """); + + result.Should().HaveDiagnostics(new[] + { + ("BCP414", DiagnosticLevel.Warning, "The supplied string does not match the expected pattern of /$^[a-zA-Z0-9-]{3,24}$/."), + ("BCP414", DiagnosticLevel.Warning, "The supplied string does not match the expected pattern of /$^[a-zA-Z0-9-]{1,127}$/."), + }); + } + + // https://github.com/azure/bicep/issues/15325 [TestMethod] public void Refinements_are_not_enforced_on_hierarchical_resource_names() {