public Result Update(StorageObjectType storageObjectType) { return(_storageHelper.GetResult(() => { var parameters = new List <NpgsqlParameter>(); _pgHelper.AddParam(parameters, "p_id", NpgsqlTypes.NpgsqlDbType.Integer, storageObjectType.Id); _pgHelper.AddParam(parameters, "p_code", NpgsqlTypes.NpgsqlDbType.Varchar, storageObjectType.Code); _pgClinet.ExecuteNonQuery("core.object_type__update", parameters); })); }
public void BlobOrContainerWithDeletePermission(StorageObjectType objectType) { blobUtil.SetupTestContainerAndBlob(); try { CommandAgent.SetContextWithSASToken(StorageAccount.Credentials.AccountName, blobUtil, objectType, StorageEndpoint, string.Empty, "rd"); // Delete blob with the generated SAS token Test.Assert(CommandAgent.RemoveAzureStorageBlob(blobUtil.Blob.Name, blobUtil.ContainerName), string.Format("Remove blob {0} in container {1} should succeed", blobUtil.Blob.Name, blobUtil.ContainerName)); } finally { blobUtil.CleanupTestContainerAndBlob(); } }
public void BlobOrContainerWithWritePermission(string uploadFilePath, StorageObjectType objectType, BlobType type) { blobUtil.SetupTestContainerAndBlob(type); try { CommandAgent.SetContextWithSASToken(StorageAccount.Credentials.AccountName, blobUtil, objectType, StorageEndpoint, string.Empty, "rw"); // Upload blob with the generated SAS token Test.Assert(CommandAgent.SetAzureStorageBlobContent(uploadFilePath, blobUtil.ContainerName, type, blobUtil.Blob.Name), string.Format("Overwriting existing blob {0} in container {1} should succeed", blobUtil.Blob.Name, blobUtil.ContainerName)); } finally { blobUtil.CleanupTestContainerAndBlob(); } }
public void BlobOrContainerWithReadPermission(StorageObjectType objectType, BlobType blobType) { blobUtil.SetupTestContainerAndBlob(SpecialCharsPrefix, blobType); try { CommandAgent.SetContextWithSASToken(StorageAccount.Credentials.AccountName, blobUtil, objectType, StorageEndpoint, string.Empty, "r"); // Get blob with the generated SAS token Test.Assert(CommandAgent.GetAzureStorageBlob(blobUtil.Blob.Name, blobUtil.ContainerName), string.Format("Get existing blob {0} in container {1} should succeed", blobUtil.Blob.Name, blobUtil.ContainerName)); // Download blob with the generated SAS token string downloadFilePath = Path.Combine(downloadDirPath, blobUtil.Blob.Name); Test.Assert(CommandAgent.GetAzureStorageBlobContent(blobUtil.Blob.Name, downloadFilePath, blobUtil.ContainerName), string.Format("Download blob {0} in container {1} to File {2} should succeed", blobUtil.Blob.Name, blobUtil.ContainerName, downloadFilePath)); // Copy blob with the generated SAS token(as source) string copiedName = Utility.GenNameString("copied"); object destContext = null; if (lang == Language.PowerShell) { destContext = PowerShellAgent.GetStorageContext(StorageAccount.ToString(true)); } else { destContext = StorageAccount; } Test.Assert(CommandAgent.StartAzureStorageBlobCopy(blobUtil.ContainerName, blobUtil.Blob.Name, blobUtil.ContainerName, copiedName, destContext: destContext), string.Format("Copy blob {0} in container {1} to blob {2} in container {3} should succeed", blobUtil.Blob.Name, blobUtil.ContainerName, blobUtil.ContainerName, copiedName)); } finally { blobUtil.CleanupTestContainerAndBlob(); } }
/// <summary> /// Generate the data for output comparision /// </summary> public static Dictionary <string, object> GenComparisonData(StorageObjectType objType, string name) { Dictionary <string, object> dic = new Dictionary <string, object> { { "Name", name }, { "Context", null } }; switch (objType) { case StorageObjectType.Container: dic.Add("PublicAccess", BlobContainerPublicAccessType.Off); // default value is Off dic.Add("LastModified", null); dic.Add("Permission", null); break; case StorageObjectType.Blob: dic.Add("BlobType", null); // need to validate this later dic.Add("Length", null); // need to validate this later dic.Add("ContentType", null); // the return value of upload operation is always null dic.Add("LastModified", null); // need to validate this later dic.Add("SnapshotTime", null); // need to validate this later break; case StorageObjectType.Queue: dic.Add("ApproximateMessageCount", 0); dic.Add("EncodeMessage", true); break; case StorageObjectType.Table: break; default: throw new Exception(String.Format("Object type:{0} not identified!", objType)); } return(dic); }
public abstract string SetContextWithSASToken(string accountName, CloudBlobUtil blobUtil, StorageObjectType objectType, string endpoint, string policy, string permission, DateTime?startTime = null, DateTime?expiryTime = null);