private static TestAppContextSwitch SetAppConfigSwitch() { var s = new TestAppContextSwitch("Azure.Experimental.EnableActivitySource", "true"); ActivityExtensions.ResetFeatureSwitch(); return(s); }
public void GetConfigValue( [Values("true", "false", null)] string enableSwitch, [Values("true", "false", null)] string enableEnvVar) { TestAppContextSwitch ctx = null; TestEnvVar env = null; try { bool actual; bool expected = enableSwitch switch { "true" => true, "false" => false, _ => bool.TryParse(enableEnvVar, out bool val) && val }; if (enableSwitch != null) { ctx = new TestAppContextSwitch(switchName, enableSwitch); } if (enableEnvVar != null) { env = new TestEnvVar(envVarName, enableEnvVar); } actual = AppContextSwitchHelper.GetConfigValue(switchName, envVarName); Assert.AreEqual(expected, actual); } finally { ctx?.Dispose(); env?.Dispose(); } }
public void CreateClientRespectsCaeConfig( [Values(true, false, null)] bool?setDisableSwitch, [Values(true, false, null)] bool?setDisableEnvVar) { TestAppContextSwitch ctx = null; TestEnvVar env = null; try { if (setDisableSwitch != null) { ctx = new TestAppContextSwitch(IdentityCompatSwitches.DisableCP1ExecutionSwitchName, setDisableSwitch.Value.ToString()); } if (setDisableEnvVar != null) { env = new TestEnvVar(IdentityCompatSwitches.DisableCP1ExecutionEnvVar, setDisableEnvVar.Value.ToString()); } var mock = new MockMsalPublicClient(); mock.PubClientAppFactory = (capabilities) => { bool IsCp1Set = cp1 == string.Join("", capabilities); if (setDisableSwitch.HasValue) { Assert.AreEqual(setDisableSwitch.Value, !IsCp1Set); } else { Assert.AreEqual(setDisableEnvVar.HasValue && setDisableEnvVar.Value, !IsCp1Set); } return(Moq.Mock.Of <IPublicClientApplication>()); }; mock.CallCreateClientAsync(false, default); } finally { ctx?.Dispose(); env?.Dispose(); } }
public async Task CookiesCanBeEnabledUsingSwitch() { using var appContextSwitch = new TestAppContextSwitch("Azure.Core.Pipeline.HttpClientTransport.EnableCookies", "true"); await TestCookiesEnabled(); }