public void CanRoundTripHttpPath() { var httpPath = new Uri("http://storageaccounthost.blob.core.windows.net/containerName"); var asvPath = WabStorageAbstraction.ConvertToAsvPath(httpPath); var httpPathRoundTripped = WabStorageAbstraction.ConvertToHttpPath(asvPath); Assert.AreEqual(httpPath.OriginalString.TrimEnd('/'), httpPathRoundTripped.OriginalString.TrimEnd('/')); }
public void CanConvertHttpPathToAsvPath() { var httpPath = new Uri("http://storageaccounthost.blob.core.windows.net/containerName"); var asvPath = WabStorageAbstraction.ConvertToAsvPath(httpPath); var expectedAsvPath = Constants.WabsProtocolSchemeName + "*****@*****.**"; Assert.AreEqual(expectedAsvPath, asvPath.OriginalString.TrimEnd('/')); }
public void CanGetStorageAccountName_Production() { var storageCreds = new WindowsAzureStorageAccountCredentials() { Name = "demostorage" }; var wabsStorageClient = new WabStorageAbstraction(storageCreds); Assert.AreEqual(wabsStorageClient.StorageAccountName, "demostorage"); Assert.AreEqual(wabsStorageClient.StorageAccountRoot, "http://demostorage.blob.core.windows.net/"); }
public void CanConvertWabsPathToHttpPath() { var storageCreds = new WindowsAzureStorageAccountCredentials() { Name = "demostorage.blob.core.windows-int.net" }; var asvPath = Constants.WabsProtocolSchemeName + "[email protected]/path1/path2"; var httpPath = WabStorageAbstraction.ConvertToHttpPath(new Uri(asvPath)); Assert.AreEqual("http://demostorage.blob.core.windows-int.net/container/path1/path2", httpPath.AbsoluteUri); }
public void CanGetStorageAccountName_Internal() { var storageCreds = new WindowsAzureStorageAccountCredentials() { Name = Constants.WabsProtocolSchemeName + "demostorage.blob.core.windows-int.net" }; var wabsStorageClient = new WabStorageAbstraction(storageCreds); Assert.AreEqual("demostorage", wabsStorageClient.StorageAccountName); Assert.AreEqual("http://demostorage.blob.core.windows-int.net", wabsStorageClient.StorageAccountRoot); }
public static async Task ValidateAndResolveWasbScriptActionEndpointUri(Uri uri, WabStorageAccountConfiguration storage) { if (uri == null) { throw new ArgumentNullException("uri"); } if (storage == null) { throw new ArgumentNullException("storage"); } // Try to check the existence of the script in the URI specified. var storageAbstractionCreds = new WindowsAzureStorageAccountCredentials() { Key = storage.Key, Name = GetFullyQualifiedStorageAccountName(storage.Name), }; var storageAbstraction = new WabStorageAbstraction(storageAbstractionCreds); bool exists = false; try { // Firstly converts the URI to wasb style and then test it against wasb storage for existence. exists = await storageAbstraction.Exists(ConvertToWasbUriIfNeeded(uri)); } catch (Exception e) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Script action URI: {0} cannot be retrieved correctly. Inner exception: {1}", uri.AbsoluteUri, e.Message), e); } if (!exists) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Script action URI: {0} cannot be retrieved correctly because it does not exist", uri.AbsoluteUri)); } }