Ejemplo n.º 1
0
        public void SetUp()
        {
            record1 = new AuditRecord();
            record1.EventType = SecurityEvent.ViewAuditLog;
            record1.Message = "Message #1";
            record1.ProjectName = "Project #1";
            record1.SecurityRight = SecurityRight.Allow;
            record1.TimeOfEvent = DateTime.Today.AddDays(-1);
            record1.UserName = "******";

            record2 = new AuditRecord();
            record2.EventType = SecurityEvent.StopProject;
            record2.Message = "Message #2";
            record2.ProjectName = "Project #2";
            record2.SecurityRight = SecurityRight.Deny;
            record2.TimeOfEvent = DateTime.Today.AddDays(1);
            record2.UserName = "******";

            record3 = new AuditRecord();
            record3.EventType = SecurityEvent.StopProject;
            record3.Message = "Message #3";
            record3.ProjectName = "Project #2";
            record3.SecurityRight = SecurityRight.Deny;
            record3.TimeOfEvent = DateTime.Today.AddDays(1);
            record3.UserName = "******";
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks if the date range matches.
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        protected override bool DoCheckFilter(AuditRecord record)
        {
            bool include = (record.TimeOfEvent >= filterStartDate) &&
                           (record.TimeOfEvent <= filterEndDate);

            return(include);
        }
 public void ToStringSerialisesAllValues()
 {
     ReadAuditResponse response = new ReadAuditResponse();
     response.ErrorMessages.Add(new ErrorMessage("Error 1"));
     response.ErrorMessages.Add(new ErrorMessage("Error 2"));
     response.RequestIdentifier = "request";
     response.Result = ResponseResult.Success;
     response.Timestamp = DateTime.Now;
     AuditRecord auditRecord = new AuditRecord();
     auditRecord.EventType = SecurityEvent.ViewAuditLog;
     auditRecord.Message = "testing";
     auditRecord.ProjectName = "test project";
     auditRecord.SecurityRight = SecurityRight.Deny;
     auditRecord.TimeOfEvent = response.Timestamp;
     auditRecord.UserName = "******";
     response.Records.Add(auditRecord);
     string actual = response.ToString();
     string expected = string.Format(System.Globalization.CultureInfo.CurrentCulture,"<readAuditResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
         "timestamp=\"{2:yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz}\" identifier=\"{0}\" result=\"{1}\">" +
         "<error>Error 1</error>" +
         "<error>Error 2</error>" +
         "<record time=\"{2:yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz}\" project=\"test project\" " +
         "user=\"Test user\" event=\"ViewAuditLog\" right=\"Deny\">" +
         "<message>testing</message>" + 
         "</record>" + 
         "</readAuditResponse>",
         response.RequestIdentifier,
         response.Result,
         response.Timestamp);
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Logs an audit record.
 /// </summary>
 /// <param name="record">The record to log.</param>
 public virtual void LogEvent(AuditRecord record)
 {
     LogEvent(record.ProjectName,
         record.UserName,
         record.EventType,
         record.SecurityRight,
         record.Message);
     record.TimeOfEvent = DateTime.Now;
 }
        /// <summary>
        /// Checks whether the record should be included in the filter.
        /// </summary>
        /// <param name="record">The record to check.</param>
        /// <returns>True to include the record, false otherwise.</returns>
        public virtual bool CheckFilter(AuditRecord record)
        {
            bool include = DoCheckFilter(record);

            if (include && (innerFilter != null))
            {
                include = innerFilter.CheckFilter(record);
            }
            return(include);
        }
 /// <summary>
 /// Checks if the security right matches.
 /// </summary>
 /// <param name="record"></param>
 /// <returns></returns>
 protected override bool DoCheckFilter(AuditRecord record)
 {
     bool include = false;
     foreach (AuditFilterBase filter in combinedFilters)
     {
         if (filter.CheckFilter(record))
         {
             include = true;
             break;
         }
     }
     return include;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Checks if the security right matches.
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        protected override bool DoCheckFilter(AuditRecord record)
        {
            bool include = false;

            foreach (AuditFilterBase filter in combinedFilters)
            {
                if (filter.CheckFilter(record))
                {
                    include = true;
                    break;
                }
            }
            return(include);
        }
Ejemplo n.º 8
0
 public void SetGetAllProperties()
 {
     AuditRecord record = new AuditRecord();
     record.EventType = SecurityEvent.ViewAuditLog;
     Assert.AreEqual(SecurityEvent.ViewAuditLog, record.EventType, "EventType get/set mismatch");
     record.Message = "Test Message";
     Assert.AreEqual("Test Message", record.Message, "Message get/set mismatch");
     record.ProjectName = "Test Project";
     Assert.AreEqual("Test Project", record.ProjectName, "ProjectName get/set mismatch");
     record.SecurityRight = SecurityRight.Allow;
     Assert.AreEqual(SecurityRight.Allow, record.SecurityRight, "SecurityRight get/set mismatch");
     record.TimeOfEvent = DateTime.Today;
     Assert.AreEqual(DateTime.Today, record.TimeOfEvent, "TimeOfEvent get/set mismatch");
     record.UserName = "******";
     Assert.AreEqual("Test User", record.UserName, "UserName get/set mismatch");
 }
 /// <summary>
 /// Checks whether the record should be included in the filter.
 /// </summary>
 /// <param name="record">The record to check.</param>
 /// <returns>True to include the record, false otherwise.</returns>
 protected abstract bool DoCheckFilter(AuditRecord record);
 /// <summary>
 /// Checks if the security right matches.
 /// </summary>
 /// <param name="record"></param>
 /// <returns></returns>
 protected override bool DoCheckFilter(AuditRecord record)
 {
     bool include = (this.right == record.SecurityRight);
     return include;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Checks if the project name matches.
 /// </summary>
 /// <param name="record"></param>
 /// <returns></returns>
 protected override bool DoCheckFilter(AuditRecord record)
 {
     bool include = string.Equals(this.project, record.ProjectName);
     return include;
 }
 /// <summary>
 /// Checks if the date range matches.
 /// </summary>
 /// <param name="record"></param>
 /// <returns></returns>
 protected override bool DoCheckFilter(AuditRecord record)
 {
     bool include = (record.TimeOfEvent >= filterStartDate) &&
         (record.TimeOfEvent <= filterEndDate);
     return include;
 }
        /// <summary>
        /// Checks if the event type matches.
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        protected override bool DoCheckFilter(AuditRecord record)
        {
            bool include = (this.type == record.EventType);

            return(include);
        }
        /// <summary>
        /// Checks if the security right matches.
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        protected override bool DoCheckFilter(AuditRecord record)
        {
            bool include = (this.right == record.SecurityRight);

            return(include);
        }
 /// <summary>
 /// Checks whether the record should be included in the filter.
 /// </summary>
 /// <param name="record">The record to check.</param>
 /// <returns>True to include the record, false otherwise.</returns>
 public virtual bool CheckFilter(AuditRecord record)
 {
     bool include = DoCheckFilter(record);
     if (include && (innerFilter != null)) include = innerFilter.CheckFilter(record);
     return include;
 }
 /// <summary>
 /// Checks whether the record should be included in the filter.
 /// </summary>
 /// <param name="record">The record to check.</param>
 /// <returns>True to include the record, false otherwise.</returns>
 protected abstract bool DoCheckFilter(AuditRecord record);
Ejemplo n.º 17
0
 /// <summary>
 /// Checks if the event type matches.
 /// </summary>
 /// <param name="record"></param>
 /// <returns></returns>
 protected override bool DoCheckFilter(AuditRecord record)
 {
     bool include = (this.type == record.EventType);
     return include;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Checks if the project name matches.
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        protected override bool DoCheckFilter(AuditRecord record)
        {
            bool include = string.Equals(this.project, record.ProjectName, StringComparison.CurrentCulture);

            return(include);
        }
 /// <summary>
 /// Checks if the user name matches.
 /// </summary>
 /// <param name="record"></param>
 /// <returns></returns>
 protected override bool DoCheckFilter(AuditRecord record)
 {
     bool include = string.Equals(this.user, record.UserName, StringComparison.CurrentCulture);
     return include;
 }