From 438323a23e03a4b51f5ca5616af85671a5a6a4c9 Mon Sep 17 00:00:00 2001 From: Aniruddh Munde Date: Tue, 7 Jul 2026 08:17:52 -0700 Subject: [PATCH 1/6] Add warning for using SWA provider without the Azure Platform --- .../AppServiceAuthenticationInformation.cs | 12 +++++-- .../StaticWebAppsAuthentication.cs | 35 +++++++++++++++++++ src/Service/Startup.cs | 25 +++++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs b/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs index bcd836c288..b2ea23fdf1 100644 --- a/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs +++ b/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs @@ -19,14 +19,22 @@ public static class AppServiceAuthenticationInfo /// Environment variable key whose value represents Identity Provider such as "AzureActiveDirectory" /// public const string APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR = "WEBSITE_AUTH_DEFAULT_PROVIDER"; + + // ── AppService messages ────────────────────────────────────────────────────────────────────── /// /// Error message used when AppService Authentication is configured in production mode in a non AppService Environment. /// - public const string APPSERVICE_PROD_MISSING_ENV_CONFIG = "AppService environment not detected while runtime is in production mode."; + public const string APPSERVICE_PROD_MISSING_ENV_CONFIG = + "AppService environment not detected while runtime is in production mode. " + + "The X-MS-CLIENT-PRINCIPAL header is not cryptographically validated by DAB and can be trivially " + + "forged when the service is not hosted behind an Azure App Service EasyAuth proxy. " + + "Set host.mode to 'development' for local testing, or deploy behind Azure App Service."; /// /// Warning message logged when AppService environment not detected (applicable to development mode). /// - public const string APPSERVICE_DEV_MISSING_ENV_CONFIG = "AppService environment not detected, EasyAuth authentication may not behave as expected."; + public const string APPSERVICE_DEV_MISSING_ENV_CONFIG = + "AppService environment not detected. The X-MS-CLIENT-PRINCIPAL header is not cryptographically " + + "validated; EasyAuth authentication may not behave as expected outside an Azure App Service environment."; /// /// Returns a best guess whether AppService is enabled in the environment by checking for diff --git a/src/Core/AuthenticationHelpers/StaticWebAppsAuthentication.cs b/src/Core/AuthenticationHelpers/StaticWebAppsAuthentication.cs index bf123e596d..19fa7af3f3 100644 --- a/src/Core/AuthenticationHelpers/StaticWebAppsAuthentication.cs +++ b/src/Core/AuthenticationHelpers/StaticWebAppsAuthentication.cs @@ -33,6 +33,31 @@ public class StaticWebAppsClientPrincipal public IEnumerable? UserRoles { get; set; } } + /// + /// Environment variable key set by the Azure platform for every App Service and Static Web Apps + /// hosted site. Its presence is the best-effort signal that the runtime is executing behind an + /// Azure-managed proxy that injects and validates the X-MS-CLIENT-PRINCIPAL header. + /// + public const string WEBSITE_SITE_NAME_ENVVAR = "WEBSITE_SITE_NAME"; + + // ── StaticWebApps messages ─────────────────────────────────────────────────────────────────── + /// + /// Error message used when StaticWebApps Authentication is configured in production mode + /// without a detectable Azure-hosted environment. + /// + public const string SWA_PROD_MISSING_ENV_CONFIG = + "StaticWebApps environment not detected while runtime is in production mode. " + + "The X-MS-CLIENT-PRINCIPAL header is not cryptographically validated by DAB and can be trivially " + + "forged when the service is not hosted behind an Azure Static Web Apps proxy. " + + "Set host.mode to 'development' for local testing, or deploy behind Azure Static Web Apps."; + + /// + /// Warning message logged when StaticWebApps environment not detected (applicable to development mode). + /// + public const string SWA_DEV_MISSING_ENV_CONFIG = + "StaticWebApps environment not detected. The X-MS-CLIENT-PRINCIPAL header is not cryptographically " + + "validated; EasyAuth authentication may not behave as expected outside an Azure Static Web Apps environment."; + /// /// Base64 decodes and deserializes the x-ms-client-principal payload containing /// SWA token metadata. @@ -98,4 +123,14 @@ error is NotSupportedException || return identity; } + + /// + /// Returns a best-effort indication that the runtime is executing inside an Azure Static Web Apps + /// environment by checking for the presence of , which is + /// injected by the Azure platform for every SWA-hosted application. + /// + public static bool AreExpectedSWAEnvVarsPresent() + { + return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(WEBSITE_SITE_NAME_ENVVAR)); + } } diff --git a/src/Service/Startup.cs b/src/Service/Startup.cs index 68364b530e..bcbaa235f8 100644 --- a/src/Service/Startup.cs +++ b/src/Service/Startup.cs @@ -1148,11 +1148,36 @@ private void ConfigureAuthentication(IServiceCollection services, RuntimeConfigP EasyAuthType easyAuthType = EnumExtensions.Deserialize(runtimeConfig.Runtime.Host.Authentication.Provider); bool isProductionMode = mode != HostMode.Development; bool appServiceEnvironmentDetected = AppServiceAuthenticationInfo.AreExpectedAppServiceEnvVarsPresent(); + bool swaEnvironmentDetected = StaticWebAppsAuthentication.AreExpectedSWAEnvVarsPresent(); if (easyAuthType == EasyAuthType.AppService && !appServiceEnvironmentDetected) { + if (isProductionMode) + { + // SECURITY: In production the X-MS-CLIENT-PRINCIPAL header is blindly trusted. + // Refuse to start when there is no evidence of an App Service EasyAuth proxy. + throw new DataApiBuilderException( + message: AppServiceAuthenticationInfo.APPSERVICE_PROD_MISSING_ENV_CONFIG, + statusCode: System.Net.HttpStatusCode.ServiceUnavailable, + subStatusCode: DataApiBuilderException.SubStatusCodes.ConfigValidationError); + } + _logBuffer.BufferLog(LogLevel.Warning, AppServiceAuthenticationInfo.APPSERVICE_DEV_MISSING_ENV_CONFIG); } + else if (easyAuthType == EasyAuthType.StaticWebApps && !swaEnvironmentDetected) + { + if (isProductionMode) + { + // SECURITY: In production the X-MS-CLIENT-PRINCIPAL header is blindly trusted. + // Refuse to start when there is no evidence of a Static Web Apps proxy. + throw new DataApiBuilderException( + message: StaticWebAppsAuthentication.SWA_PROD_MISSING_ENV_CONFIG, + statusCode: System.Net.HttpStatusCode.ServiceUnavailable, + subStatusCode: DataApiBuilderException.SubStatusCodes.ConfigValidationError); + } + + _logBuffer.BufferLog(LogLevel.Warning, StaticWebAppsAuthentication.SWA_DEV_MISSING_ENV_CONFIG); + } string defaultScheme = easyAuthType == EasyAuthType.AppService ? EasyAuthAuthenticationDefaults.APPSERVICEAUTHSCHEME From 787a601e613f02974718c04b313b1259cc515f6d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Jul 2026 17:07:25 +0000 Subject: [PATCH 2/6] Add EasyAuth startup env-var coverage for AppService and SWA --- .../Configuration/ConfigurationTests.cs | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Service.Tests/Configuration/ConfigurationTests.cs b/src/Service.Tests/Configuration/ConfigurationTests.cs index 247685793f..22bdd921ed 100644 --- a/src/Service.Tests/Configuration/ConfigurationTests.cs +++ b/src/Service.Tests/Configuration/ConfigurationTests.cs @@ -3934,23 +3934,25 @@ type Planet @model(name:""PlanetAlias"") { /// /// HostMode in Runtime config - Development or Production. /// EasyAuth auth type - AppService or StaticWebApps. - /// Whether to set the AppService host environment variables. + /// Whether to set the AppService host environment variables. + /// Whether to set the Static Web Apps host environment variable. /// Whether an error is expected. [DataTestMethod] [TestCategory(TestCategory.MSSQL)] - [DataRow(HostMode.Development, EasyAuthType.AppService, false, false, DisplayName = "AppService Dev - No EnvVars - No Error")] - [DataRow(HostMode.Development, EasyAuthType.AppService, true, false, DisplayName = "AppService Dev - EnvVars - No Error")] - [DataRow(HostMode.Production, EasyAuthType.AppService, false, false, DisplayName = "AppService Prod - No EnvVars - Error")] - [DataRow(HostMode.Production, EasyAuthType.AppService, true, false, DisplayName = "AppService Prod - EnvVars - Error")] - [DataRow(HostMode.Development, EasyAuthType.StaticWebApps, false, false, DisplayName = "SWA Dev - No EnvVars - No Error")] - [DataRow(HostMode.Development, EasyAuthType.StaticWebApps, true, false, DisplayName = "SWA Dev - EnvVars - No Error")] - [DataRow(HostMode.Production, EasyAuthType.StaticWebApps, false, false, DisplayName = "SWA Prod - No EnvVars - No Error")] - [DataRow(HostMode.Production, EasyAuthType.StaticWebApps, true, false, DisplayName = "SWA Prod - EnvVars - No Error")] - public void TestProductionModeAppServiceEnvironmentCheck(HostMode hostMode, EasyAuthType authType, bool setEnvVars, bool expectError) + [DataRow(HostMode.Development, EasyAuthType.AppService, false, false, false, DisplayName = "AppService Dev - No EnvVars - No Error")] + [DataRow(HostMode.Development, EasyAuthType.AppService, true, false, false, DisplayName = "AppService Dev - EnvVars - No Error")] + [DataRow(HostMode.Production, EasyAuthType.AppService, false, false, true, DisplayName = "AppService Prod - No EnvVars - Error")] + [DataRow(HostMode.Production, EasyAuthType.AppService, true, false, false, DisplayName = "AppService Prod - EnvVars - No Error")] + [DataRow(HostMode.Development, EasyAuthType.StaticWebApps, false, false, false, DisplayName = "SWA Dev - No EnvVars - No Error")] + [DataRow(HostMode.Development, EasyAuthType.StaticWebApps, false, true, false, DisplayName = "SWA Dev - EnvVars - No Error")] + [DataRow(HostMode.Production, EasyAuthType.StaticWebApps, false, false, true, DisplayName = "SWA Prod - No EnvVars - Error")] + [DataRow(HostMode.Production, EasyAuthType.StaticWebApps, false, true, false, DisplayName = "SWA Prod - EnvVars - No Error")] + public void TestProductionModeAppServiceEnvironmentCheck(HostMode hostMode, EasyAuthType authType, bool setAppServiceEnvVars, bool setStaticWebAppsEnvVar, bool expectError) { // Clears or sets App Service Environment Variables based on test input. - Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_ENABLED_ENVVAR, setEnvVars ? "true" : null); - Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR, setEnvVars ? "AzureActiveDirectory" : null); + Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_ENABLED_ENVVAR, setAppServiceEnvVars ? "true" : null); + Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR, setAppServiceEnvVars ? "AzureActiveDirectory" : null); + Environment.SetEnvironmentVariable(StaticWebAppsAuthentication.WEBSITE_SITE_NAME_ENVVAR, setStaticWebAppsEnvVar ? "test-site-name" : null); TestHelper.SetupDatabaseEnvironment(TestCategory.MSSQL); FileSystem fileSystem = new(); @@ -3987,7 +3989,17 @@ public void TestProductionModeAppServiceEnvironmentCheck(HostMode hostMode, Easy catch (DataApiBuilderException ex) { Assert.IsTrue(expectError, message: ex.Message); - Assert.AreEqual(AppServiceAuthenticationInfo.APPSERVICE_PROD_MISSING_ENV_CONFIG, ex.Message); + Assert.AreEqual( + expected: authType == EasyAuthType.AppService + ? AppServiceAuthenticationInfo.APPSERVICE_PROD_MISSING_ENV_CONFIG + : StaticWebAppsAuthentication.SWA_PROD_MISSING_ENV_CONFIG, + actual: ex.Message); + } + finally + { + Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_ENABLED_ENVVAR, null); + Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR, null); + Environment.SetEnvironmentVariable(StaticWebAppsAuthentication.WEBSITE_SITE_NAME_ENVVAR, null); } } From e87067fd5877c444a4d25e3b6d9087034cb963ae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Jul 2026 20:04:19 +0000 Subject: [PATCH 3/6] Set EasyAuth env vars in tests using AppService/SWA providers --- .../Caching/HealthEndpointCachingTests.cs | 6 ++++++ .../Configuration/ConfigurationTests.cs | 7 +++++++ .../Configuration/HealthEndpointRolesTests.cs | 6 ++++++ .../Configuration/HealthEndpointTests.cs | 6 ++++++ src/Service.Tests/SqlTests/SqlTestHelper.cs | 1 + src/Service.Tests/TestHelper.cs | 15 +++++++++++++++ 6 files changed, 41 insertions(+) diff --git a/src/Service.Tests/Caching/HealthEndpointCachingTests.cs b/src/Service.Tests/Caching/HealthEndpointCachingTests.cs index 664e6070e6..f5a4b76c80 100644 --- a/src/Service.Tests/Caching/HealthEndpointCachingTests.cs +++ b/src/Service.Tests/Caching/HealthEndpointCachingTests.cs @@ -22,6 +22,12 @@ public class HealthEndpointCachingTests { private const string CUSTOM_CONFIG_FILENAME = "custom-config.json"; + [TestInitialize] + public void SetupAuthProviderEnvironmentVariables() + { + TestHelper.SetAppServiceEasyAuthEnvironmentVariables(); + } + [TestCleanup] public void CleanupAfterEachTest() { diff --git a/src/Service.Tests/Configuration/ConfigurationTests.cs b/src/Service.Tests/Configuration/ConfigurationTests.cs index 22bdd921ed..8c8ef51311 100644 --- a/src/Service.Tests/Configuration/ConfigurationTests.cs +++ b/src/Service.Tests/Configuration/ConfigurationTests.cs @@ -735,6 +735,13 @@ public void CleanupAfterEachTest() TestHelper.UnsetAllDABEnvironmentVariables(); } + [TestInitialize] + public void SetupAuthProviderEnvironmentVariables() + { + TestHelper.SetAppServiceEasyAuthEnvironmentVariables(); + TestHelper.SetStaticWebAppsEnvironmentVariable(); + } + /// /// When updating config during runtime is possible, then For invalid config the Application continues to /// accept request with status code of 503. diff --git a/src/Service.Tests/Configuration/HealthEndpointRolesTests.cs b/src/Service.Tests/Configuration/HealthEndpointRolesTests.cs index 99f3284a8a..0f08e1c175 100644 --- a/src/Service.Tests/Configuration/HealthEndpointRolesTests.cs +++ b/src/Service.Tests/Configuration/HealthEndpointRolesTests.cs @@ -22,6 +22,12 @@ public class HealthEndpointRolesTests private const string CUSTOM_CONFIG_FILENAME = "custom-config.json"; + [TestInitialize] + public void SetupAuthProviderEnvironmentVariables() + { + TestHelper.SetAppServiceEasyAuthEnvironmentVariables(); + } + [TestCleanup] public void CleanupAfterEachTest() { diff --git a/src/Service.Tests/Configuration/HealthEndpointTests.cs b/src/Service.Tests/Configuration/HealthEndpointTests.cs index b1b21c4307..078b273f2f 100644 --- a/src/Service.Tests/Configuration/HealthEndpointTests.cs +++ b/src/Service.Tests/Configuration/HealthEndpointTests.cs @@ -36,6 +36,12 @@ public class HealthEndpointTests private const string CUSTOM_CONFIG_FILENAME = "custom_config.json"; private const string BASE_DAB_URL = "http://localhost:5000"; + [TestInitialize] + public void SetupAuthProviderEnvironmentVariables() + { + TestHelper.SetAppServiceEasyAuthEnvironmentVariables(); + } + [TestCleanup] public void CleanupAfterEachTest() { diff --git a/src/Service.Tests/SqlTests/SqlTestHelper.cs b/src/Service.Tests/SqlTests/SqlTestHelper.cs index 32041c8fc8..bbcd7e37a7 100644 --- a/src/Service.Tests/SqlTests/SqlTestHelper.cs +++ b/src/Service.Tests/SqlTests/SqlTestHelper.cs @@ -380,6 +380,7 @@ public static RuntimeConfig InitBasicRuntimeConfigWithNoEntity( DatabaseType dbType = DatabaseType.MSSQL, string testCategory = TestCategory.MSSQL) { + TestHelper.SetAppServiceEasyAuthEnvironmentVariables(); DataSource dataSource = new(dbType, GetConnectionStringFromEnvironmentConfig(environment: testCategory), new()); Config.ObjectModel.AuthenticationOptions authenticationOptions = new(Provider: nameof(EasyAuthType.AppService), null); diff --git a/src/Service.Tests/TestHelper.cs b/src/Service.Tests/TestHelper.cs index bb83f6243f..bcb10e5efa 100644 --- a/src/Service.Tests/TestHelper.cs +++ b/src/Service.Tests/TestHelper.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.DataApiBuilder.Config; using Azure.DataApiBuilder.Config.ObjectModel; +using Azure.DataApiBuilder.Core.AuthenticationHelpers; using Azure.DataApiBuilder.Core.Configurations; using Azure.DataApiBuilder.Service.Tests.Configuration; using Humanizer; @@ -29,6 +30,20 @@ public static void UnsetAllDABEnvironmentVariables() Environment.SetEnvironmentVariable(FileSystemRuntimeConfigLoader.RUNTIME_ENVIRONMENT_VAR_NAME, null); Environment.SetEnvironmentVariable(FileSystemRuntimeConfigLoader.ASP_NET_CORE_ENVIRONMENT_VAR_NAME, null); Environment.SetEnvironmentVariable(FileSystemRuntimeConfigLoader.RUNTIME_ENV_CONNECTION_STRING, null); + Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_ENABLED_ENVVAR, null); + Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR, null); + Environment.SetEnvironmentVariable(StaticWebAppsAuthentication.WEBSITE_SITE_NAME_ENVVAR, null); + } + + public static void SetAppServiceEasyAuthEnvironmentVariables() + { + Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_ENABLED_ENVVAR, "true"); + Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR, "AzureActiveDirectory"); + } + + public static void SetStaticWebAppsEnvironmentVariable() + { + Environment.SetEnvironmentVariable(StaticWebAppsAuthentication.WEBSITE_SITE_NAME_ENVVAR, "dab-service-tests"); } /// From 0fbb2319acc5b835730126e5a3b4e0bca7d7d3ef Mon Sep 17 00:00:00 2001 From: Aniruddh Munde Date: Wed, 8 Jul 2026 12:23:46 -0700 Subject: [PATCH 4/6] Remove requirement to have WEBSITE_AUTH_DEFAULT_PROVIDER set --- .../AppServiceAuthenticationInformation.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs b/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs index b2ea23fdf1..74fa32e15c 100644 --- a/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs +++ b/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs @@ -47,14 +47,12 @@ public static class AppServiceAuthenticationInfo /// public static bool AreExpectedAppServiceEnvVarsPresent() { + // WEBSITE_AUTH_ENABLED is the only variable that is reliably injected by the Azure platform + // whenever App Service Authentication (EasyAuth) is enabled, regardless of how many identity + // providers are configured. WEBSITE_AUTH_DEFAULT_PROVIDER is only set when a *single* provider + // is selected; multi-provider configurations leave it unset, so it must not be required here. string? appServiceEnabled = Environment.GetEnvironmentVariable(APPSERVICESAUTH_ENABLED_ENVVAR); - string? appServiceIdentityProvider = Environment.GetEnvironmentVariable(APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR); - - if (string.IsNullOrEmpty(appServiceEnabled) || string.IsNullOrEmpty(appServiceIdentityProvider)) - { - return false; - } - - return appServiceEnabled.Equals(value: "true", comparisonType: StringComparison.OrdinalIgnoreCase); + return appServiceEnabled is not null && + appServiceEnabled.Equals(value: "true", comparisonType: StringComparison.OrdinalIgnoreCase); } } From 29b3f6d1f54392402962cf696a215c45e5071e22 Mon Sep 17 00:00:00 2001 From: Aniruddh Munde Date: Wed, 8 Jul 2026 12:37:32 -0700 Subject: [PATCH 5/6] Remove setting of WEBSITE_AUTH_DEFAULT_PROVIDER --- .../AppServiceAuthenticationInformation.cs | 4 ---- src/Service.Tests/Configuration/ConfigurationTests.cs | 2 -- src/Service.Tests/TestHelper.cs | 2 -- 3 files changed, 8 deletions(-) diff --git a/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs b/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs index 74fa32e15c..0c31391148 100644 --- a/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs +++ b/src/Core/AuthenticationHelpers/AppServiceAuthenticationInformation.cs @@ -15,10 +15,6 @@ public static class AppServiceAuthenticationInfo /// Environment variable key whose value represents whether AppService EasyAuth is enabled ("true" or "false"). /// public const string APPSERVICESAUTH_ENABLED_ENVVAR = "WEBSITE_AUTH_ENABLED"; - /// - /// Environment variable key whose value represents Identity Provider such as "AzureActiveDirectory" - /// - public const string APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR = "WEBSITE_AUTH_DEFAULT_PROVIDER"; // ── AppService messages ────────────────────────────────────────────────────────────────────── /// diff --git a/src/Service.Tests/Configuration/ConfigurationTests.cs b/src/Service.Tests/Configuration/ConfigurationTests.cs index 8c8ef51311..8c4774ba5c 100644 --- a/src/Service.Tests/Configuration/ConfigurationTests.cs +++ b/src/Service.Tests/Configuration/ConfigurationTests.cs @@ -3958,7 +3958,6 @@ public void TestProductionModeAppServiceEnvironmentCheck(HostMode hostMode, Easy { // Clears or sets App Service Environment Variables based on test input. Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_ENABLED_ENVVAR, setAppServiceEnvVars ? "true" : null); - Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR, setAppServiceEnvVars ? "AzureActiveDirectory" : null); Environment.SetEnvironmentVariable(StaticWebAppsAuthentication.WEBSITE_SITE_NAME_ENVVAR, setStaticWebAppsEnvVar ? "test-site-name" : null); TestHelper.SetupDatabaseEnvironment(TestCategory.MSSQL); @@ -4005,7 +4004,6 @@ public void TestProductionModeAppServiceEnvironmentCheck(HostMode hostMode, Easy finally { Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_ENABLED_ENVVAR, null); - Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR, null); Environment.SetEnvironmentVariable(StaticWebAppsAuthentication.WEBSITE_SITE_NAME_ENVVAR, null); } } diff --git a/src/Service.Tests/TestHelper.cs b/src/Service.Tests/TestHelper.cs index bcb10e5efa..185f981e64 100644 --- a/src/Service.Tests/TestHelper.cs +++ b/src/Service.Tests/TestHelper.cs @@ -31,14 +31,12 @@ public static void UnsetAllDABEnvironmentVariables() Environment.SetEnvironmentVariable(FileSystemRuntimeConfigLoader.ASP_NET_CORE_ENVIRONMENT_VAR_NAME, null); Environment.SetEnvironmentVariable(FileSystemRuntimeConfigLoader.RUNTIME_ENV_CONNECTION_STRING, null); Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_ENABLED_ENVVAR, null); - Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR, null); Environment.SetEnvironmentVariable(StaticWebAppsAuthentication.WEBSITE_SITE_NAME_ENVVAR, null); } public static void SetAppServiceEasyAuthEnvironmentVariables() { Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_ENABLED_ENVVAR, "true"); - Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_IDENTITYPROVIDER_ENVVAR, "AzureActiveDirectory"); } public static void SetStaticWebAppsEnvironmentVariable() From b69b58c924ee353ba5496a9fb6207cca9193b873 Mon Sep 17 00:00:00 2001 From: Aniruddh Munde Date: Wed, 8 Jul 2026 12:47:45 -0700 Subject: [PATCH 6/6] Rename to singular --- src/Service.Tests/Caching/HealthEndpointCachingTests.cs | 2 +- src/Service.Tests/Configuration/ConfigurationTests.cs | 2 +- src/Service.Tests/Configuration/HealthEndpointRolesTests.cs | 2 +- src/Service.Tests/Configuration/HealthEndpointTests.cs | 2 +- src/Service.Tests/SqlTests/SqlTestHelper.cs | 2 +- src/Service.Tests/TestHelper.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Service.Tests/Caching/HealthEndpointCachingTests.cs b/src/Service.Tests/Caching/HealthEndpointCachingTests.cs index f5a4b76c80..2ca6661fa4 100644 --- a/src/Service.Tests/Caching/HealthEndpointCachingTests.cs +++ b/src/Service.Tests/Caching/HealthEndpointCachingTests.cs @@ -25,7 +25,7 @@ public class HealthEndpointCachingTests [TestInitialize] public void SetupAuthProviderEnvironmentVariables() { - TestHelper.SetAppServiceEasyAuthEnvironmentVariables(); + TestHelper.SetAppServiceEnvironmentVariable(); } [TestCleanup] diff --git a/src/Service.Tests/Configuration/ConfigurationTests.cs b/src/Service.Tests/Configuration/ConfigurationTests.cs index 8c4774ba5c..8764533c14 100644 --- a/src/Service.Tests/Configuration/ConfigurationTests.cs +++ b/src/Service.Tests/Configuration/ConfigurationTests.cs @@ -738,7 +738,7 @@ public void CleanupAfterEachTest() [TestInitialize] public void SetupAuthProviderEnvironmentVariables() { - TestHelper.SetAppServiceEasyAuthEnvironmentVariables(); + TestHelper.SetAppServiceEnvironmentVariable(); TestHelper.SetStaticWebAppsEnvironmentVariable(); } diff --git a/src/Service.Tests/Configuration/HealthEndpointRolesTests.cs b/src/Service.Tests/Configuration/HealthEndpointRolesTests.cs index 0f08e1c175..227167da2b 100644 --- a/src/Service.Tests/Configuration/HealthEndpointRolesTests.cs +++ b/src/Service.Tests/Configuration/HealthEndpointRolesTests.cs @@ -25,7 +25,7 @@ public class HealthEndpointRolesTests [TestInitialize] public void SetupAuthProviderEnvironmentVariables() { - TestHelper.SetAppServiceEasyAuthEnvironmentVariables(); + TestHelper.SetAppServiceEnvironmentVariable(); } [TestCleanup] diff --git a/src/Service.Tests/Configuration/HealthEndpointTests.cs b/src/Service.Tests/Configuration/HealthEndpointTests.cs index 078b273f2f..0ae704a920 100644 --- a/src/Service.Tests/Configuration/HealthEndpointTests.cs +++ b/src/Service.Tests/Configuration/HealthEndpointTests.cs @@ -39,7 +39,7 @@ public class HealthEndpointTests [TestInitialize] public void SetupAuthProviderEnvironmentVariables() { - TestHelper.SetAppServiceEasyAuthEnvironmentVariables(); + TestHelper.SetAppServiceEnvironmentVariable(); } [TestCleanup] diff --git a/src/Service.Tests/SqlTests/SqlTestHelper.cs b/src/Service.Tests/SqlTests/SqlTestHelper.cs index bbcd7e37a7..5aa7cb1fe9 100644 --- a/src/Service.Tests/SqlTests/SqlTestHelper.cs +++ b/src/Service.Tests/SqlTests/SqlTestHelper.cs @@ -380,7 +380,7 @@ public static RuntimeConfig InitBasicRuntimeConfigWithNoEntity( DatabaseType dbType = DatabaseType.MSSQL, string testCategory = TestCategory.MSSQL) { - TestHelper.SetAppServiceEasyAuthEnvironmentVariables(); + TestHelper.SetAppServiceEnvironmentVariable(); DataSource dataSource = new(dbType, GetConnectionStringFromEnvironmentConfig(environment: testCategory), new()); Config.ObjectModel.AuthenticationOptions authenticationOptions = new(Provider: nameof(EasyAuthType.AppService), null); diff --git a/src/Service.Tests/TestHelper.cs b/src/Service.Tests/TestHelper.cs index 185f981e64..21d1c10113 100644 --- a/src/Service.Tests/TestHelper.cs +++ b/src/Service.Tests/TestHelper.cs @@ -34,7 +34,7 @@ public static void UnsetAllDABEnvironmentVariables() Environment.SetEnvironmentVariable(StaticWebAppsAuthentication.WEBSITE_SITE_NAME_ENVVAR, null); } - public static void SetAppServiceEasyAuthEnvironmentVariables() + public static void SetAppServiceEnvironmentVariable() { Environment.SetEnvironmentVariable(AppServiceAuthenticationInfo.APPSERVICESAUTH_ENABLED_ENVVAR, "true"); }