Ejemplo n.º 1
0
        public override bool RecordWillBePersisted(AuditRecord auditRecord)
        {
            var packageAuditRecord = auditRecord as PackageAuditRecord;

            return(packageAuditRecord != null &&
                   (packageAuditRecord.Action == AuditedPackageAction.Delete || packageAuditRecord.Action == AuditedPackageAction.SoftDelete));
        }
Ejemplo n.º 2
0
        public void OnlyPackageAuditRecordsWillBeSaved(AuditRecord record, bool expectedResult)
        {
            // Arrange
            CloudBlobContainer nullBlobContainer = null;
            var service = new CloudAuditingService(nullBlobContainer, AuditActor.GetCurrentMachineActorAsync);

            // Act + Assert
            Assert.Equal<bool>(expectedResult, service.RecordWillBePersisted(record));
        }
Ejemplo n.º 3
0
        public virtual async Task<Uri> SaveAuditRecord(AuditRecord record)
        {
            // Build an audit entry
            var entry = new AuditEntry(record, await GetActor());

            // Serialize to json
            string rendered = RenderAuditEntry(entry);

            // Save the record
            return await SaveAuditRecord(rendered, record.GetResourceType(), record.GetPath(), record.GetAction(), entry.Actor.TimestampUtc);
        }
Ejemplo n.º 4
0
        public virtual async Task <Uri> SaveAuditRecord(AuditRecord record)
        {
            // Build an audit entry
            var entry = new AuditEntry(record, await GetActor());

            // Serialize to json
            string rendered = RenderAuditEntry(entry);

            // Save the record
            return(await SaveAuditRecord(rendered, record.GetResourceType(), record.GetPath(), record.GetAction(), entry.Actor.TimestampUtc));
        }
        /// <summary>
        /// Persists the audit record to storage.
        /// </summary>
        /// <param name="record">An audit record.</param>
        /// <returns>A <see cref="Task"/> that represents the asynchronous save operation.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="record" /> is <c>null</c>.</exception>
        public async Task SaveAuditRecordAsync(AuditRecord record)
        {
            if (record == null)
            {
                throw new ArgumentNullException(nameof(record));
            }

            var tasks = _services.Select(service => service.SaveAuditRecordAsync(record))
                        .ToArray();

            await Task.WhenAll(tasks);
        }
        /// <summary>
        /// Persists the audit record to storage.
        /// </summary>
        /// <param name="record">An audit record.</param>
        /// <returns>A <see cref="Task"/> that represents the asynchronous save operation.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="record" /> is <c>null</c>.</exception>
        public async Task SaveAuditRecordAsync(AuditRecord record)
        {
            if (record == null)
            {
                throw new ArgumentNullException(nameof(record));
            }

            var entry    = new AuditEntry(record, await GetActorAsync());
            var rendered = RenderAuditEntry(entry);

            await SaveAuditRecordAsync(rendered, record.GetResourceType(), record.GetPath(), record.GetAction(), entry.Actor.TimestampUtc);
        }
 /// <summary>
 /// The Auditing services can use it to stop the saving of the record before rendering.
 /// </summary>
 public virtual bool RecordWillBePersisted(AuditRecord auditRecord)
 {
     return(true);
 }
Ejemplo n.º 8
0
 public AuditEntry(AuditRecord record, AuditActor actor)
 {
     Record = record;
     Actor  = actor;
 }
Ejemplo n.º 9
0
 public AuditEntry(AuditRecord record, AuditActor actor)
 {
     Record = record;
     Actor = actor;
 }
Ejemplo n.º 10
0
 public override bool RecordWillBePersisted(AuditRecord auditRecord)
 {
     return(auditRecord.GetType() == typeof(PackageAuditRecord));
 }