Example #1
0
 private void GetIds()
 {
     using (var TraceListener = new TraceEventListener())
     {
         using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString))
         {
             connection.Open();
             using (SqlCommand command = new SqlCommand("SELECT * From [Customers]", connection))
             {
                 command.ExecuteNonQuery();
             }
             ids = TraceListener.IDs;
         }
         ids = TraceListener.IDs;
     }
 }
        static DataTestUtility()
        {
            using (StreamReader r = new StreamReader("config.json"))
            {
                string json = r.ReadToEnd();
                Config c    = JsonConvert.DeserializeObject <Config>(json);

                NPConnectionString          = c.NPConnectionString;
                TCPConnectionString         = c.TCPConnectionString;
                TCPConnectionStringHGSVBS   = c.TCPConnectionStringHGSVBS;
                TCPConnectionStringAASVBS   = c.TCPConnectionStringAASVBS;
                TCPConnectionStringAASSGX   = c.TCPConnectionStringAASSGX;
                AADAuthorityURL             = c.AADAuthorityURL;
                AADPasswordConnectionString = c.AADPasswordConnectionString;
                SupportsLocalDb             = c.SupportsLocalDb;
                SupportsIntegratedSecurity  = c.SupportsIntegratedSecurity;
                SupportsFileStream          = c.SupportsFileStream;
                EnclaveEnabled         = c.EnclaveEnabled;
                TracingEnabled         = c.TracingEnabled;
                UseManagedSNIOnWindows = c.UseManagedSNIOnWindows;

                if (TracingEnabled)
                {
                    TraceListener = new DataTestUtility.TraceEventListener();
                }

                if (UseManagedSNIOnWindows)
                {
                    AppContext.SetSwitch(ManagedNetworkingAppContextSwitch, true);
                    Console.WriteLine($"App Context switch {ManagedNetworkingAppContextSwitch} enabled on {Environment.OSVersion}");
                }

                if (IsAADPasswordConnStrSetup() && IsAADAuthorityURLSetup())
                {
                    string username = RetrieveValueFromConnStr(AADPasswordConnectionString, new string[] { "User ID", "UID" });
                    string password = RetrieveValueFromConnStr(AADPasswordConnectionString, new string[] { "Password", "PWD" });
                    AADAccessToken = GenerateAccessToken(AADAuthorityURL, username, password);
                }

                string url        = c.AzureKeyVaultURL;
                Uri    AKVBaseUri = null;
                if (!string.IsNullOrEmpty(url) && Uri.TryCreate(url, UriKind.Absolute, out AKVBaseUri))
                {
                    AKVBaseUri = new Uri(AKVBaseUri, "/");
                    AKVBaseUrl = AKVBaseUri.AbsoluteUri;
                    AKVUrl     = (new Uri(AKVBaseUri, $"/keys/{AKVKeyName}")).AbsoluteUri;
                }

                AKVClientId     = c.AzureKeyVaultClientId;
                AKVClientSecret = c.AzureKeyVaultClientSecret;
            }

            if (EnclaveEnabled)
            {
                if (!string.IsNullOrEmpty(TCPConnectionStringHGSVBS))
                {
                    AEConnStrings.Add(TCPConnectionStringHGSVBS);
                    AEConnStringsSetup.Add(TCPConnectionStringHGSVBS);
                }

                if (!string.IsNullOrEmpty(TCPConnectionStringAASVBS))
                {
                    AEConnStrings.Add(TCPConnectionStringAASVBS);
                }

                if (!string.IsNullOrEmpty(TCPConnectionStringAASSGX))
                {
                    AEConnStrings.Add(TCPConnectionStringAASSGX);
                    AEConnStringsSetup.Add(TCPConnectionStringAASSGX);
                }

                System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12;
            }
            else
            {
                if (!string.IsNullOrEmpty(TCPConnectionString))
                {
                    AEConnStrings.Add(TCPConnectionString);
                    AEConnStringsSetup.Add(TCPConnectionString);
                }
            }
        }
Example #3
0
        static DataTestUtility()
        {
            Config c = Config.Load();

            NPConnectionString          = c.NPConnectionString;
            TCPConnectionString         = c.TCPConnectionString;
            TCPConnectionStringHGSVBS   = c.TCPConnectionStringHGSVBS;
            TCPConnectionStringAASVBS   = c.TCPConnectionStringAASVBS;
            TCPConnectionStringAASSGX   = c.TCPConnectionStringAASSGX;
            AADAuthorityURL             = c.AADAuthorityURL;
            AADPasswordConnectionString = c.AADPasswordConnectionString;
            AADServicePrincipalId       = c.AADServicePrincipalId;
            AADServicePrincipalSecret   = c.AADServicePrincipalSecret;
            SupportsLocalDb             = c.SupportsLocalDb;
            SupportsIntegratedSecurity  = c.SupportsIntegratedSecurity;
            SupportsFileStream          = c.SupportsFileStream;
            EnclaveEnabled                 = c.EnclaveEnabled;
            TracingEnabled                 = c.TracingEnabled;
            UseManagedSNIOnWindows         = c.UseManagedSNIOnWindows;
            DNSCachingConnString           = c.DNSCachingConnString;
            DNSCachingServerCR             = c.DNSCachingServerCR;
            DNSCachingServerTR             = c.DNSCachingServerTR;
            IsAzureSynapse                 = c.IsAzureSynapse;
            IsDNSCachingSupportedCR        = c.IsDNSCachingSupportedCR;
            IsDNSCachingSupportedTR        = c.IsDNSCachingSupportedTR;
            EnclaveAzureDatabaseConnString = c.EnclaveAzureDatabaseConnString;
            UserManagedIdentityObjectId    = c.UserManagedIdentityObjectId;

            System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12;

            if (TracingEnabled)
            {
                TraceListener = new TraceEventListener();
            }

            if (UseManagedSNIOnWindows)
            {
                AppContext.SetSwitch(ManagedNetworkingAppContextSwitch, true);
                Console.WriteLine($"App Context switch {ManagedNetworkingAppContextSwitch} enabled on {Environment.OSVersion}");
            }

            string url = c.AzureKeyVaultURL;

            if (!string.IsNullOrEmpty(url) && Uri.TryCreate(url, UriKind.Absolute, out Uri AKVBaseUri))
            {
                AKVBaseUri = new Uri(AKVBaseUri, "/");
                AKVBaseUrl = AKVBaseUri.AbsoluteUri;
                AKVUrl     = (new Uri(AKVBaseUri, $"/keys/{AKVKeyName}")).AbsoluteUri;
            }

            AKVClientId     = c.AzureKeyVaultClientId;
            AKVClientSecret = c.AzureKeyVaultClientSecret;

            if (EnclaveEnabled)
            {
                if (!string.IsNullOrEmpty(TCPConnectionStringHGSVBS))
                {
                    AEConnStrings.Add(TCPConnectionStringHGSVBS);
                    AEConnStringsSetup.Add(TCPConnectionStringHGSVBS);
                }

                if (!string.IsNullOrEmpty(TCPConnectionStringAASVBS))
                {
                    AEConnStrings.Add(TCPConnectionStringAASVBS);
                }

                if (!string.IsNullOrEmpty(TCPConnectionStringAASSGX))
                {
                    AEConnStrings.Add(TCPConnectionStringAASSGX);
                    AEConnStringsSetup.Add(TCPConnectionStringAASSGX);
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(TCPConnectionString))
                {
                    AEConnStrings.Add(TCPConnectionString);
                    AEConnStringsSetup.Add(TCPConnectionString);
                }
            }
        }