Exemple #1
0
        internal void StorageTest(string caseName)
        {
            NodeJSAgent nodeAgent     = (NodeJSAgent)CommandAgent;
            string      containerName = Utility.GenNameString("astoria-");
            string      blobName      = Utility.GenNameString("astoria-");

            Test.Assert(!nodeAgent.NewAzureStorageContainer(containerName), Utility.GenComparisonData("NewAzureStorageContainer", false));
            nodeAgent.ValidateErrorMessage(caseName);

            Test.Assert(!nodeAgent.GetAzureStorageContainer(containerName), Utility.GenComparisonData("GetAzureStorageContainer", false));
            nodeAgent.ValidateErrorMessage(caseName);

            Test.Assert(!nodeAgent.SetAzureStorageContainerACL(containerName, BlobContainerPublicAccessType.Container),
                        Utility.GenComparisonData("SetAzureStorageContainerACL", false));
            nodeAgent.ValidateErrorMessage(caseName);

            Test.Assert(!nodeAgent.RemoveAzureStorageContainer(containerName), Utility.GenComparisonData("RemoveAzureStorageContainer", false));
            nodeAgent.ValidateErrorMessage(caseName);

            Test.Assert(!nodeAgent.ShowAzureStorageContainer(containerName), Utility.GenComparisonData("ShowAzureStorageContainer", false));
            nodeAgent.ValidateErrorMessage(caseName);

            Test.Assert(!nodeAgent.SetAzureStorageBlobContent(TempTestFile, containerName, BlobType.BlockBlob, blobName),
                        Utility.GenComparisonData("SetAzureStorageBlobContent", false));
            nodeAgent.ValidateErrorMessage(caseName);

            Test.Assert(!nodeAgent.SetAzureStorageBlobContent(TempTestFile, containerName, BlobType.PageBlob, blobName),
                        Utility.GenComparisonData("SetAzureStorageBlobContent", false));
            nodeAgent.ValidateErrorMessage(caseName);

            Test.Assert(!nodeAgent.GetAzureStorageBlobContent(blobName, TempTestFile, containerName),
                        Utility.GenComparisonData("GetAzureStorageBlobContent", false));
            nodeAgent.ValidateErrorMessage(caseName);

            Test.Assert(!nodeAgent.GetAzureStorageBlob(blobName, containerName),
                        Utility.GenComparisonData("GetAzureStorageBlob", false));
            nodeAgent.ValidateErrorMessage(caseName);

            Test.Assert(!nodeAgent.ShowAzureStorageBlob(blobName, containerName),
                        Utility.GenComparisonData("ShowAzureStorageBlob", false));
            nodeAgent.ValidateErrorMessage(caseName);

            Test.Assert(!nodeAgent.RemoveAzureStorageBlob(blobName, containerName),
                        Utility.GenComparisonData("RemoveAzureStorageBlob", false));
            nodeAgent.ValidateErrorMessage(caseName);
        }
Exemple #2
0
        public void ShowNonExistingContainer()
        {
            string containerName = Utility.GenNameString("nonexisting");

            // Delete the container if it exists
            CloudBlobClient    blobClient = StorageAccount.CreateCloudBlobClient();
            CloudBlobContainer container  = blobClient.GetContainerReference(containerName);

            container.DeleteIfExists();

            NodeJSAgent nodejsAgent = (NodeJSAgent)CommandAgent;

            //--------------Show operation--------------
            Test.Assert(!nodejsAgent.ShowAzureStorageContainer(containerName), Utility.GenComparisonData("show container", false));
            // Verification for returned values
            nodejsAgent.ValidateErrorMessage(MethodBase.GetCurrentMethod().Name, containerName);
        }
Exemple #3
0
        public void ShowLogsContainer()
        {
            const string containerName      = "$logs";
            Dictionary <string, object> dic = Utility.GenComparisonData(StorageObjectType.Container, containerName);
            Collection <Dictionary <string, object> > comp = new Collection <Dictionary <string, object> > {
                dic
            };

            CloudBlobContainer container = StorageAccount.CreateCloudBlobClient().GetContainerReference(containerName);

            NodeJSAgent nodejsAgent = (NodeJSAgent)CommandAgent;

            //--------------Show operation--------------
            Test.Assert(nodejsAgent.ShowAzureStorageContainer(containerName), Utility.GenComparisonData("show $logs container", true));

            container.FetchAttributes();
            CloudBlobUtil.PackContainerCompareData(container, dic);
            // Verification for returned values
            nodejsAgent.OutputValidation(comp);
        }
Exemple #4
0
        public void ShowContainerWithSasPolicy()
        {
            string             containerName = Utility.GenNameString("container");
            CloudBlobContainer container     = blobUtil.CreateContainer(containerName);

            NodeJSAgent nodejsAgent = (NodeJSAgent)CommandAgent;

            try
            {
                TimeSpan sasLifeTime = TimeSpan.FromMinutes(10);
                BlobContainerPermissions permission = new BlobContainerPermissions();
                int count = random.Next(1, 5);

                for (int i = 0; i < count; i++)
                {
                    permission.SharedAccessPolicies.Add(Utility.GenNameString("saspolicy"), new SharedAccessBlobPolicy
                    {
                        SharedAccessExpiryTime = DateTime.Now.Add(sasLifeTime),
                        Permissions            = SharedAccessBlobPermissions.Read,
                    });
                }

                container.SetPermissions(permission);

                Test.Assert(nodejsAgent.ShowAzureStorageContainer(containerName), Utility.GenComparisonData("show container", true));
                Test.Assert(nodejsAgent.Output.Count == 1, String.Format("Create {0} containers, actually retrieved {1} containers", 1, nodejsAgent.Output.Count));

                nodejsAgent.OutputValidation(new List <BlobContainerPermissions>()
                {
                    permission
                });
            }
            finally
            {
                blobUtil.RemoveContainer(containerName);
            }
        }