public override bool RecordWillBePersisted(AuditRecord auditRecord) { var packageAuditRecord = auditRecord as PackageAuditRecord; return(packageAuditRecord != null && (packageAuditRecord.Action == AuditedPackageAction.Delete || packageAuditRecord.Action == AuditedPackageAction.SoftDelete)); }
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)); }
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); }
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); }
public AuditEntry(AuditRecord record, AuditActor actor) { Record = record; Actor = actor; }
public override bool RecordWillBePersisted(AuditRecord auditRecord) { return(auditRecord.GetType() == typeof(PackageAuditRecord)); }