Exemple #1
0
        internal void GenericEnableDisableServiceLogging(ServiceType serviceType, GetLoggingProperty <ServiceProperties> getServiceProperties)
        {
            Test.Info("Enable/Disable service logging for {0}", serviceType);
            int retentionDays = 10;

            Test.Assert(CommandAgent.SetAzureStorageServiceLogging(serviceType, string.Empty, retentionDays.ToString(), string.Empty), "Enable service logging should succeed");
            ServiceProperties retrievedProperties;

            retrievedProperties = getServiceProperties(retentionDays, LoggingOperations.None.ToString());
            ExpectEqual(retentionDays, retrievedProperties.Logging.RetentionDays.Value, "logging retention days");

            retentionDays = lang == Language.PowerShell ? -1 : 0;
            Test.Assert(CommandAgent.SetAzureStorageServiceLogging(serviceType, string.Empty, retentionDays.ToString(), string.Empty), "Enable blob service logging should succeed");

            retrievedProperties = getServiceProperties(retentionDays, LoggingOperations.None.ToString());
            Test.Assert(!retrievedProperties.Logging.RetentionDays.HasValue, "service logging retention days should be null");
        }
Exemple #2
0
        internal void GenericSetLoggingRetentionDays(ServiceType serviceType, GetLoggingProperty <ServiceProperties> getServiceProperties)
        {
            Test.Info("Set service logging retention days for {0}", serviceType);
            // valid values for RetentionDay
            int retentionDays = Utility.GetRandomTestCount(1, 365 + 1);

            Test.Assert(CommandAgent.SetAzureStorageServiceLogging(serviceType, string.Empty, retentionDays.ToString(), string.Empty), "Set service logging retention days should succeed");
            ServiceProperties retrievedProperties = getServiceProperties(retentionDays, LoggingOperations.None.ToString());

            ExpectEqual(retentionDays, retrievedProperties.Logging.RetentionDays.Value, "Logging retention days");

            if (lang == Language.PowerShell)
            {
                retentionDays = -1;
                Test.Assert(CommandAgent.SetAzureStorageServiceLogging(serviceType, string.Empty, retentionDays.ToString(), string.Empty), "Set service logging retention days should succeed");
                retrievedProperties = getServiceProperties(retentionDays, LoggingOperations.None.ToString());
                Test.Assert(!retrievedProperties.Logging.RetentionDays.HasValue, "Service logging retention days should be null");

                // invalid values for RetentionDay
                retentionDays = 0;
                Test.Assert(!CommandAgent.SetAzureStorageServiceLogging(serviceType, string.Empty, retentionDays.ToString(), string.Empty), "Set service logging retention days for invalid retention days should fail");
                ExpectedContainErrorMessage("The minimum value of retention days is 1, the largest value is 365 (one year).");

                retentionDays = -1 * Utility.GetRandomTestCount(2, 365 + 1);
                Test.Assert(!CommandAgent.SetAzureStorageServiceLogging(serviceType, string.Empty, retentionDays.ToString(), string.Empty), "Set service logging retention days for invalid retention days should fail");
                ExpectedContainErrorMessage("Cannot validate argument on parameter 'RetentionDays'");

                retentionDays = Utility.GetRandomTestCount(366, 365 + 100);
                Test.Assert(!CommandAgent.SetAzureStorageServiceLogging(serviceType, string.Empty, retentionDays.ToString(), string.Empty), "Set service logging retention days for invalid retention days should fail");
                ExpectedContainErrorMessage("Cannot validate argument on parameter 'RetentionDays'");
            }
            else
            {
                retentionDays = 0;
                Test.Assert(CommandAgent.SetAzureStorageServiceLogging(serviceType, string.Empty, retentionDays.ToString(), string.Empty), "Set service logging retention days for 0 retention days should succeed");

                retentionDays = Utility.GetRandomTestCount(366, 365 + 100);
                Test.Assert(!CommandAgent.SetAzureStorageServiceLogging(serviceType, string.Empty, retentionDays.ToString(), string.Empty), "Set service logging retention days for invalid retention days should fail");

                string[] errMessages = { "XML specified is not syntactically valid", "Error" };
                ExpectedContainErrorMessage(errMessages);
            }
        }
Exemple #3
0
        internal void GenericSetLoggingOperation(ServiceType serviceType, GetLoggingProperty <ServiceProperties> getServiceProperties)
        {
            Test.Info("Set service logging operation for {0}", serviceType);
            string[] operations = { "None", "All", "Read", "Write", "Delete" };
            foreach (string op in operations)
            {
                ExpectValidLoggingOperation(serviceType, op, getServiceProperties);
            }

            //Random combine
            string[] combineOperations = { "Read", "Write", "Delete" };
            string   combination       = Utility.GenRandomCombination(combineOperations.ToList(), ",");

            Test.Info("Generate combined operations {0}", combination);
            ExpectValidLoggingOperation(serviceType, combination, getServiceProperties);

            //Test case for case-insesitive, duplicate keys, key order.
            combination = "Delete,write,deLETE";
            Test.Info("Generate combined operations {0}", combination);
            ExpectValidLoggingOperation(serviceType, combination, getServiceProperties);
        }
Exemple #4
0
        internal void ExpectValidLoggingOperation(ServiceType serviceType, string operations, GetLoggingProperty <ServiceProperties> getServiceProperties)
        {
            int retentionDays = Utility.GetRandomTestCount(1, 365 + 1);

            Test.Assert(CommandAgent.SetAzureStorageServiceLogging(serviceType, operations, retentionDays.ToString(), string.Empty), "Set logging operation should succeed");

            ServiceProperties retrievedProperties = getServiceProperties(retentionDays, operations);
            LoggingOperations expectOperation     = (LoggingOperations)Enum.Parse(typeof(LoggingOperations), operations, true);
            bool?read   = (expectOperation & LoggingOperations.Read) != 0;
            bool?write  = (expectOperation & LoggingOperations.Write) != 0;
            bool?delete = (expectOperation & LoggingOperations.Delete) != 0;

            Utility.ValidateLoggingOperationProperty(operations, read, write, delete);
        }