internal StorageConnectionString GetConnectionString(
            SharedAccessSignatureCredentials credentials = default,
            bool includeEndpoint = true)
        {
            credentials ??= GetAccountSasCredentials();
            if (!includeEndpoint)
            {
                return(TestExtensions.CreateStorageConnectionString(
                           credentials,
                           TestConfigDefault.AccountName));
            }

            (Uri, Uri)fileUri = StorageConnectionString.ConstructFileEndpoint(
                Constants.Https,
                TestConfigDefault.AccountName,
        public void DefaultStorageAccountWithHttps()
        {
            var cred = new StorageSharedKeyCredential(TestConfigurations.DefaultTargetTenant.AccountName, TestConfigurations.DefaultTargetTenant.AccountKey);
            var conn = TestExtensions.CreateStorageConnectionString(cred, true);

            Assert.AreEqual(conn.BlobEndpoint,
                            new Uri(string.Format("https://{0}.blob.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName)));
            Assert.AreEqual(conn.QueueEndpoint,
                            new Uri(string.Format("https://{0}.queue.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName)));
            Assert.AreEqual(conn.FileEndpoint,
                            new Uri(string.Format("https://{0}.file.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName)));
            Assert.AreEqual(conn.BlobStorageUri.SecondaryUri,
                            new Uri(string.Format("https://{0}-secondary.blob.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName)));
            Assert.AreEqual(conn.QueueStorageUri.SecondaryUri,
                            new Uri(string.Format("https://{0}-secondary.queue.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName)));
            Assert.AreEqual(conn.FileStorageUri.SecondaryUri,
                            new Uri(string.Format("https://{0}-secondary.file.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName)));

            var storageConnectionStringToStringWithSecrets = conn.ToString(true);
            var testAccount = StorageConnectionString.Parse(storageConnectionStringToStringWithSecrets);

            AccountsAreEqual(testAccount, conn);
        }
        public void StorageCredentialsEmptyKeyValue()
        {
            var accountName = TestConfigurations.DefaultTargetTenant.AccountName;

            _ = TestConfigurations.DefaultTargetTenant.AccountKey;
            var emptyKeyValueAsString    = string.Empty;
            var emptyKeyConnectionString = string.Format(CultureInfo.InvariantCulture, "DefaultEndpointsProtocol=https;AccountName={0};AccountKey=", accountName);

            var credentials1 = new StorageSharedKeyCredential(accountName, emptyKeyValueAsString);

            StorageConnectionString conn1 = TestExtensions.CreateStorageConnectionString(credentials1, true);

            Assert.AreEqual(emptyKeyConnectionString, conn1.ToString(true));
            Assert.IsNotNull(conn1.Credentials);
            Assert.IsInstanceOf(typeof(StorageSharedKeyCredential), conn1.Credentials);
            Assert.AreEqual(accountName, ((StorageSharedKeyCredential)conn1.Credentials).AccountName);
            Assert.AreEqual(emptyKeyValueAsString, ((StorageSharedKeyCredential)conn1.Credentials).ExportBase64EncodedKey());

            var account2 = StorageConnectionString.Parse(emptyKeyConnectionString);

            Assert.AreEqual(emptyKeyConnectionString, account2.ToString(true));
            Assert.IsNotNull(account2.Credentials);
            Assert.IsInstanceOf(typeof(StorageSharedKeyCredential), account2.Credentials);
            Assert.AreEqual(accountName, ((StorageSharedKeyCredential)account2.Credentials).AccountName);
            Assert.AreEqual(emptyKeyValueAsString, ((StorageSharedKeyCredential)account2.Credentials).ExportBase64EncodedKey());

            var isValidAccount3 = StorageConnectionString.TryParse(emptyKeyConnectionString, out StorageConnectionString account3);

            Assert.IsTrue(isValidAccount3);
            Assert.IsNotNull(account3);
            Assert.AreEqual(emptyKeyConnectionString, account3.ToString(true));
            Assert.IsNotNull(account3.Credentials);
            Assert.IsInstanceOf(typeof(StorageSharedKeyCredential), account3.Credentials);
            Assert.AreEqual(accountName, ((StorageSharedKeyCredential)account3.Credentials).AccountName);
            Assert.AreEqual(emptyKeyValueAsString, ((StorageSharedKeyCredential)account3.Credentials).ExportBase64EncodedKey());
        }