/// <summary>
 /// Initializes a new instance of the
 /// BlobAuditingCreateOrUpdateParameters class with required arguments.
 /// </summary>
 public BlobAuditingCreateOrUpdateParameters(BlobAuditingProperties properties)
     : this()
 {
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     this.Properties = properties;
 }
 /// <summary>
 /// Initializes a new instance of the
 /// BlobAuditingCreateOrUpdateParameters class with required arguments.
 /// </summary>
 public BlobAuditingCreateOrUpdateParameters(BlobAuditingProperties properties)
     : this()
 {
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     this.Properties = properties;
 }
 /// <summary>
 /// Creates and returns a BlobAuditingProperties object that holds the default settings for a database blob auditing policy
 /// </summary>
 /// <returns>A BlobAuditingProperties object with the default audit policy settings</returns>
 private BlobAuditingProperties GetDefaultBlobAuditProperties()
 {
     BlobAuditingProperties props = new BlobAuditingProperties
     {
         State = "Disabled",
         RetentionDays = 0,
         StorageAccountAccessKey = "",
         StorageEndpoint = ""
     };
     return props;
 }
 /// <summary>
 /// Verify that the received properties match their expected values
 /// </summary>
 /// <param name="expected">The expected value of the properties object</param>
 /// <param name="actual">The properties object that needs to be checked</param>
 private static void VerifyAuditingPolicyInformation(BlobAuditingProperties expected, BlobAuditingProperties actual)
 {
     Assert.Equal(expected.State, actual.State);
     Assert.Equal(expected.RetentionDays, actual.RetentionDays);
     Assert.Equal(expected.StorageEndpoint, actual.StorageEndpoint);
     Assert.Equal(expected.StorageAccountAccessKey, actual.StorageAccountAccessKey);
     if (expected.AuditActionsAndGroups == null)
     {
         Assert.Equal(actual.AuditActionsAndGroups, null);
     }
     else
     {
         Assert.Equal(expected.AuditActionsAndGroups.Count, actual.AuditActionsAndGroups.Count);
         actual.AuditActionsAndGroups.ForEach(s => Assert.True(expected.AuditActionsAndGroups.Any(es => es.Equals(s))));
     }
 }
Пример #5
0
        /// <summary>
        /// Takes the cmdlets model object and transform it to the policy as expected by the endpoint
        /// </summary>
        /// <param name="model">The AuditingPolicy model object</param>
        /// <param name="storageEndpointSuffix">The suffix of the storage endpoint</param>
        /// <returns>The communication model object</returns>
        private BlobAuditingCreateOrUpdateParameters PolicizeBlobAuditingModel(BaseBlobAuditingPolicyModel model, string storageEndpointSuffix)
        {
            var updateParameters = new BlobAuditingCreateOrUpdateParameters();
            var properties = new BlobAuditingProperties();
            updateParameters.Properties = properties;
            properties.State = model.AuditState.ToString();
            if (!IgnoreStorage)
            {
                properties.StorageEndpoint = ExtractStorageAccountName(model, storageEndpointSuffix);
                properties.StorageAccountAccessKey = ExtractStorageAccountKey(model.StorageAccountName);
            }
            properties.AuditActionsAndGroups = ExtractAuditActionsAndGroups(model);
            properties.RetentionDays = (int) model.RetentionInDays;

            return updateParameters;
        }
 /// <summary>
 /// Changes the server auditing policy with new values
 /// </summary>
 private void ChangeBlobAuditPolicy(BlobAuditingProperties properties)
 {
     properties.RetentionDays = 10;
     properties.AuditActionsAndGroups = new List<string>{ "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP" };
 }