Пример #1
0
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if ((this.Actions == null) || (this.Actions.Length == 0))
     {
         errorProcesser.ProcessWarning("This task will not do anything - no actions specified");
     }
 }
        /// <summary>
        /// Validates this task.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="parent"></param>
        /// <param name="errorProcesser"></param>
        public override void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            base.Validate(configuration, parent, errorProcesser);
            var project = parent.GetAncestorValue <Project>();

            if (project != null)
            {
                // Check if this task is set in the publishers section
                var isPublisher = false;
                foreach (var publisher in project.Publishers)
                {
                    if (object.ReferenceEquals(publisher, this))
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // Display a warning
                if (isPublisher)
                {
                    errorProcesser.ProcessWarning("Putting the parallel task in the publishers section may cause unpredictable results");
                }
            }
        }
Пример #3
0
        private bool RunValidationCheck(Configuration configuration, IConfigurationValidation validator, string name, ref int row, IConfigurationErrorProcesser errorProcesser)
        {
            bool isValid = true;

            try
            {
                validator.Validate(configuration, ConfigurationTrace.Start(configuration), errorProcesser);
            }
            catch (Exception error)
            {
                var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, "Internal validation failed for {0}: {1}",
                                            name,
                                            error.Message);
                HtmlAttribute rowClass = new HtmlAttribute("class", (row % 2) == 1 ? "even" : "odd");
                myBodyEl.AppendChild(
                    GenerateElement("div",
                                    rowClass,
                                    GenerateElement("div",
                                                    new HtmlAttribute("class", "error"),
                                                    message)));
                LogMessage(message);
                isValid = false;
                row++;
            }
            return(isValid);
        }
 public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if (this.RepeatCount <= 0)
     {
         errorProcesser.ProcessWarning("count is less than 1!");
     }
 }
Пример #5
0
 public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if (this.RepeatCount <= 0)
     {
         errorProcesser.ProcessWarning("count is less than 1!");
     }
 }
Пример #6
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser"></param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            var isInitialised = false;

            try
            {
                Initialise();
                isInitialised = true;
            }
            catch (Exception error)
            {
                errorProcesser.ProcessError(error);
            }

            if (isInitialised)
            {
                foreach (IAuthentication user in this.loadedUsers.Values)
                {
                    var config = user as IConfigurationValidation;
                    if (config != null)
                    {
                        config.Validate(configuration, parent.Wrap(this), errorProcesser);
                    }
                }

                foreach (IPermission permission in this.loadedPermissions.Values)
                {
                    var config = permission as IConfigurationValidation;
                    if (config != null)
                    {
                        config.Validate(configuration, parent.Wrap(this), errorProcesser);
                    }
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            var parentProject = parent.GetAncestorValue <Project>();

            if (parentProject != null)
            {
                // Attempt to find this publisher in the publishers section
                var isPublisher = false;
                foreach (var task in parentProject.Publishers)
                {
                    if (task == this)
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // If not found then throw a validation exception
                if (!isPublisher)
                {
                    errorProcesser.ProcessWarning(
                        "Email publishers are best placed in the publishers section of the configuration");
                }
            }
            else
            {
                errorProcesser.ProcessError(new CruiseControlException("This publisher can only belong to a project"));
            }

            // Make sure the xslFiles are not empty
            if (this.xslFiles != null && this.XslFiles.Any(f => string.IsNullOrEmpty(f)))
            {
                errorProcesser.ProcessError("xslFiles cannot contain empty or null filenames");
            }
        }
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if ((this.Actions == null) || (this.Actions.Length == 0))
     {
         errorProcesser.ProcessWarning("This task will not do anything - no actions specified");
     }
 }
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if (string.IsNullOrEmpty(this.Url))
     {
         errorProcesser.ProcessError("URL cannot be empty");
     }
 }
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if (string.IsNullOrEmpty(this.Url))
     {
         errorProcesser.ProcessError("URL cannot be empty");
     }
 }
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            // Get the name of the executable
            var canCheck = true;
            var fileName = this.GetProcessFilename().Trim();

            if (!Path.IsPathRooted(fileName))
            {
                var project = parent.GetAncestorValue <Project>();
                if (project != null)
                {
                    var result    = ConfigurationValidationUtils.GenerateResultForProject(project);
                    var directory = this.GetProcessBaseDirectory(result);
                    fileName = Path.Combine(directory, fileName);
                }
                else
                {
                    // Can't generate the path, therefore can't check for the file
                    canCheck = false;
                }
            }

            // See if it exists - shortcut the process if there is an exact match (the remainder uses pattern matching to try and find the file)
            if (canCheck && !this.IOSystemActual.FileExists(fileName))
            {
                var fileExists = false;

                // This needs to be from the filename, just in case the path is a relative path and it has been joined to the base directory
                var directory = Path.GetDirectoryName(fileName);
                if (this.IOSystemActual.DirectoryExists(directory))
                {
                    // Get all the files and check each file
                    var files           = this.IOSystemActual.GetFilesInDirectory(directory);
                    var executableName1 = Path.GetFileNameWithoutExtension(fileName);
                    var executableName2 = Path.GetFileName(fileName);
                    foreach (var file in files)
                    {
                        // Strip the extension so we can compare partial file names (since Windows does not need the .exe extension)
                        var fileToTest = Path.GetFileNameWithoutExtension(file);

                        // Need to perform two checks here as some Windows names have two multiple dots - therefore GetFileNameWithoutExtension will strip the last part,
                        // whether or not it is an extension
                        if (string.Equals(fileToTest, executableName1, StringComparison.InvariantCultureIgnoreCase) ||
                            string.Equals(fileToTest, executableName2, StringComparison.InvariantCultureIgnoreCase))
                        {
                            fileExists = true;
                            break;
                        }
                    }
                }

                if (!fileExists)
                {
                    errorProcesser.ProcessWarning("Unable to find executable '" + fileName + "'");
                }
            }
        }
Пример #12
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            // Get the name of the executable
            var canCheck = true;
            var fileName = this.GetProcessFilename();
            if (!Path.IsPathRooted(fileName))
            {
                var project = parent.GetAncestorValue<Project>();
                if (project != null)
                {
                    var result = ConfigurationValidationUtils.GenerateResultForProject(project);
                    var directory = this.GetProcessBaseDirectory(result);
                    fileName = Path.Combine(directory, fileName);
                }
                else
                {
                    // Can't generate the path, therefore can't check for the file
                    canCheck = false;
                }
            }

            // See if it exists - shortcut the process if there is an exact match (the remainder uses pattern matching to try and find the file)
            if (canCheck && !this.IOSystemActual.FileExists(fileName))
            {
                var fileExists = false;

                // This needs to be from the filename, just in case the path is a relative path and it has been joined to the base directory
                var directory = Path.GetDirectoryName(fileName);
                if (this.IOSystemActual.DirectoryExists(directory))
                {
                    // Get all the files and check each file
                    var files = this.IOSystemActual.GetFilesInDirectory(directory);
                    var executableName1 = Path.GetFileNameWithoutExtension(fileName);
                    var executableName2 = Path.GetFileName(fileName);
                    foreach (var file in files)
                    {
                        // Strip the extension so we can compare partial file names (since Windows does not need the .exe extension)
                        var fileToTest = Path.GetFileNameWithoutExtension(file);

                        // Need to perform two checks here as some Windows names have two multiple dots - therefore GetFileNameWithoutExtension will strip the last part,
                        // whether or not it is an extension
                        if (string.Equals(fileToTest, executableName1, StringComparison.InvariantCultureIgnoreCase) ||
                            string.Equals(fileToTest, executableName2, StringComparison.InvariantCultureIgnoreCase))
                        {
                            fileExists = true;
                            break;
                        }
                    }
                }

                if (!fileExists)
                {
                    errorProcesser.ProcessWarning("Unable to find executable '" + fileName + "'");
                }
            }
        }
Пример #13
0
        public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            if (this.ValidateAction != null)
            {
                this.ValidateAction(configuration, parent, errorProcesser);
                return;
            }

            throw new NotImplementedException();
        }
Пример #14
0
 public void Validate(IConfiguration configuration,
     ConfigurationTrace parent,
     IConfigurationErrorProcesser errorProcesser)
 {
     if (this.MaximumValue <= 0)
     {
         errorProcesser.ProcessError(
             "The maximum value must be greater than zero");
     }
 }
Пример #15
0
        public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            if (this.ValidateAction != null)
            {
                this.ValidateAction(configuration, parent, errorProcesser);
                return;
            }

            throw new NotImplementedException();
        }
Пример #16
0
 public void Validate(IConfiguration configuration,
                      ConfigurationTrace parent,
                      IConfigurationErrorProcesser errorProcesser)
 {
     if (this.MaximumValue <= 0)
     {
         errorProcesser.ProcessError(
             "The maximum value must be greater than zero");
     }
 }
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if (!string.IsNullOrEmpty(refId))
     {
         IPermission refPermission = configuration.SecurityManager.RetrievePermission(refId);
         if (refPermission == null)
         {
             errorProcesser.ProcessError(new BadReferenceException(refId));
         }
     }
 }
Пример #18
0
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser"></param>
 public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     foreach (IPermission permission in permissions)
     {
         var dummy = permission as IConfigurationValidation;
         if (dummy != null)
         {
             dummy.Validate(configuration, parent.Wrap(this), errorProcesser);
         }
     }
 }
        public void ValidateThrowsErrorsWithoutUrl()
        {
            var processor = this.mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;
            var condition = new UrlPingsTaskCondition();

            Mock.Get(processor).Setup(_processor => _processor.ProcessError("URL cannot be empty")).Verifiable();

            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
        public void ValidatePassesWithUrl()
        {
            var processor = this.mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;
            var condition = new UrlPingsTaskCondition
            {
                Url = "http://somewhere"
            };

            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
        public void ValidateThrowsErrorsWithoutUrl()
        {
            var processor = this.mocks.StrictMock <IConfigurationErrorProcesser>();
            var condition = new UrlPingsTaskCondition();

            Expect.Call(() => processor.ProcessError("URL cannot be empty"));

            this.mocks.ReplayAll();
            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
Пример #22
0
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     try
     {
         this.GetFBVersion();
         this.GetFBPath();
     }
     catch (Exception error)
     {
         errorProcesser.ProcessError(error);
     }
 }
        public void ValidateDoesNotAllowaNegativeProfilerTimeout()
        {
            var trace          = new ConfigurationTrace(null, null);
            var errorProcesser = this.mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;

            Mock.Get(errorProcesser).Setup(_errorProcesser => _errorProcesser.ProcessError("profilerTimeout cannot be negative")).Verifiable();
            var task = new AntsPerformanceProfilerTask();

            task.ProfilerTimeOut = -1;
            task.Validate(null, trace, errorProcesser);
            this.mocks.VerifyAll();
        }
        public void ValidatePassesWithUrl()
        {
            var processor = this.mocks.StrictMock <IConfigurationErrorProcesser>();
            var condition = new UrlPingsTaskCondition
            {
                Url = "http://somewhere"
            };

            this.mocks.ReplayAll();
            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
        public void ValidateDoesNotAllowBothQuietAndVerbose()
        {
            var trace          = new ConfigurationTrace(null, null);
            var errorProcesser = this.mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;

            Mock.Get(errorProcesser).Setup(_errorProcesser => _errorProcesser.ProcessError("Cannot have both verbose and quiet set")).Verifiable();
            var task = new AntsPerformanceProfilerTask();

            task.Quiet   = true;
            task.Verbose = true;
            task.Validate(null, trace, errorProcesser);
            this.mocks.VerifyAll();
        }
Пример #26
0
        public void ValidateDoesNotAllowaNegativeProfilerTimeout()
        {
            var trace          = new ConfigurationTrace(null, null);
            var errorProcesser = this.mocks.StrictMock <IConfigurationErrorProcesser>();

            Expect.Call(() => errorProcesser.ProcessError("profilerTimeout cannot be negative"));
            var task = new AntsPerformanceProfilerTask();

            task.ProfilerTimeOut = -1;
            this.mocks.ReplayAll();
            task.Validate(null, trace, errorProcesser);
            this.mocks.VerifyAll();
        }
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public override void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            base.Validate(configuration, parent, errorProcesser);
            if (this.Verbose && this.Quiet)
            {
                errorProcesser.ProcessError("Cannot have both verbose and quiet set");
            }

            if (this.ProfilerTimeOut < 0)
            {
                errorProcesser.ProcessError("profilerTimeout cannot be negative");
            }
        }
 public void Validate(IConfiguration configuration,
                      ConfigurationTrace parent,
                      IConfigurationErrorProcesser errorProcesser)
 {
     if (string.IsNullOrEmpty(this.MonitorFile))
     {
         errorProcesser.ProcessError("File cannot be empty");
     }
     else if (!File.Exists(this.MonitorFile))
     {
         errorProcesser.ProcessWarning(
             "File '" + this.MonitorFile + "' does not exist");
     }
 }
Пример #29
0
        public void ValidateThrowsErrorsWithoutHeaderKey()
        {
            var processor = this.mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;
            var condition = new UrlHeaderValueTaskCondition
            {
                Url = "http://somewhere"
            };

            Mock.Get(processor).Setup(_processor => _processor.ProcessError("Header Key cannot be empty")).Verifiable();

            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
Пример #30
0
        public void ValidateDoesNotAllowBothQuietAndVerbose()
        {
            var trace          = new ConfigurationTrace(null, null);
            var errorProcesser = this.mocks.StrictMock <IConfigurationErrorProcesser>();

            Expect.Call(() => errorProcesser.ProcessError("Cannot have both verbose and quiet set"));
            var task = new AntsPerformanceProfilerTask();

            task.Quiet   = true;
            task.Verbose = true;
            this.mocks.ReplayAll();
            task.Validate(null, trace, errorProcesser);
            this.mocks.VerifyAll();
        }
Пример #31
0
        public void ValidateHandlesValidationTasks()
        {
            var subTask = new MockTask();
            var task    = new TestTask
            {
                Tasks = new ITask[]
                {
                    subTask
                }
            };

            task.Validate(null, ConfigurationTrace.Start(null), null);
            Assert.IsTrue(subTask.IsValided);
        }
 public void Validate(IConfiguration configuration,
     ConfigurationTrace parent,
     IConfigurationErrorProcesser errorProcesser)
 {
     if (string.IsNullOrEmpty(this.MonitorFile))
     {
         errorProcesser.ProcessError("File cannot be empty");
     }
     else if (!File.Exists(this.MonitorFile))
     {
         errorProcesser.ProcessWarning(
             "File '" + this.MonitorFile + "' does not exist");
     }
 }
Пример #33
0
 /// <summary>
 /// Validates this task.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     // Validate all the child tasks
     if (Tasks != null)
     {
         foreach (var task in Tasks)
         {
             var validatorTask = task as IConfigurationValidation;
             if (validatorTask != null)
             {
                 validatorTask.Validate(configuration, parent.Wrap(this), errorProcesser);
             }
         }
     }
 }
Пример #34
0
        public void ValidatePassesForTasksSection()
        {
            var task    = new ParallelTask();
            var project = new Project
            {
                Tasks = new ITask[]
                {
                    task
                }
            };
            var errorProcessor = mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;

            task.Validate(null, ConfigurationTrace.Start(project), errorProcessor);
            mocks.VerifyAll();
        }
        public void ValidateThrowsErrorsWithoutHeaderKey()
        {
            var processor = this.mocks.StrictMock <IConfigurationErrorProcesser>();
            var condition = new UrlHeaderValueTaskCondition
            {
                Url = "http://somewhere"
            };

            Expect.Call(() => processor.ProcessError("Header Key cannot be empty"));

            this.mocks.ReplayAll();
            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
Пример #36
0
        public void ValidateValidatesElseTasks()
        {
            var wasValidated = false;
            var taskMock     = new MockTask()
            {
                ValidateAction = (c, t, ep) => wasValidated = true
            };
            var task = new ConditionalTask
            {
                ElseTasks = new[] { taskMock }
            };

            task.Validate(null, ConfigurationTrace.Start(this), null);
            Assert.IsTrue(wasValidated);
        }
 /// <summary>
 /// Validates this task.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     // Validate all the child tasks
     if (Tasks != null)
     {
         foreach (var task in Tasks)
         {
             var validatorTask = task as IConfigurationValidation;
             if (validatorTask != null)
             {
                 validatorTask.Validate(configuration, parent.Wrap(this), errorProcesser);
             }
         }
     }
 }
        void IConfigurationValidation.Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            string projectName = "(Unknown)";

            var project = parent.GetAncestorValue <Project>();

            if (project != null)
            {
                projectName = project.Name;
            }

            if (integrationTime.Minutes + RandomOffSetInMinutesFromTime >= 60)
            {
                errorProcesser.ProcessError("Scheduled time {0}:{1} + randomOffSetInMinutesFromTime {2} would exceed the hour, this is not allowed. Conflicting project {3}", integrationTime.Hours, integrationTime.Minutes, RandomOffSetInMinutesFromTime, projectName);
            }
        }
Пример #39
0
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public void Validate(IConfiguration configuration,
     ConfigurationTrace parent,
     IConfigurationErrorProcesser errorProcesser)
 {
     if ((this.Conditions == null) || (this.Conditions.Length == 0))
     {
         errorProcesser
             .ProcessError("Validation failed for andCondition - at least one child condition must be supplied");
     }
     else
     {
         foreach (var child in this.Conditions.OfType<IConfigurationValidation>())
         {
             child.Validate(
                 configuration,
                 parent.Wrap(this),
                 errorProcesser);
         }
     }
 }
 public void ValidateDoesNotAllowaNegativeProfilerTimeout()
 {
     var trace = new ConfigurationTrace(null, null);
     var errorProcesser = this.mocks.StrictMock<IConfigurationErrorProcesser>();
     Expect.Call(() => errorProcesser.ProcessError("profilerTimeout cannot be negative"));
     var task = new AntsPerformanceProfilerTask();
     task.ProfilerTimeOut = -1;
     this.mocks.ReplayAll();
     task.Validate(null, trace, errorProcesser);
     this.mocks.VerifyAll();
 }
 public void ValidateDoesNotAllowBothQuietAndVerbose()
 {
     var trace = new ConfigurationTrace(null, null);
     var errorProcesser = this.mocks.StrictMock<IConfigurationErrorProcesser>();
     Expect.Call(() => errorProcesser.ProcessError("Cannot have both verbose and quiet set"));
     var task = new AntsPerformanceProfilerTask();
     task.Quiet = true;
     task.Verbose = true;
     this.mocks.ReplayAll();
     task.Validate(null, trace, errorProcesser);
     this.mocks.VerifyAll();
 }
 /// <summary>
 /// Validates some tasks.
 /// </summary>
 /// <param name="tasks">The tasks.</param>
 /// <param name="configuration">The configuration.</param>
 /// <param name="parent">The parent.</param>
 /// <param name="errorProcesser">The error processer.</param>
 private void ValidateTasks(ITask[] tasks,
     IConfiguration configuration, 
     ConfigurationTrace parent, 
     IConfigurationErrorProcesser errorProcesser)
 {
     if (tasks != null)
     {
         foreach (var task in tasks)
         {
             var validatorTask = task as IConfigurationValidation;
             if (validatorTask != null)
             {
                 validatorTask.Validate(configuration, parent, errorProcesser);
             }
         }
     }
 }
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser"></param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            // Ensure that the queue has at least one project in it
            var queueFound = false;
            foreach (IProject projectDef in configuration.Projects)
            {
                if (string.Equals(this.Name, projectDef.QueueName, StringComparison.InvariantCulture))
                {
                    queueFound = true;
                    break;
                }
            }

            if (!queueFound)
            {
                errorProcesser.ProcessError(new ConfigurationException(
                    string.Format(System.Globalization.CultureInfo.CurrentCulture,"An unused queue definition has been found: name '{0}'", this.Name)));
            }
        }
Пример #44
0
        /// <summary>
        /// Validates this task.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="parent"></param>
        /// <param name="errorProcesser"></param>
        public override void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            base.Validate(configuration, parent, errorProcesser);
            var project = parent.GetAncestorValue<Project>();

            if (project != null)
            {
                // Check if this task is set in the publishers section
                var isPublisher = false;
                foreach (var publisher in project.Publishers)
                {
                    if (object.ReferenceEquals(publisher, this))
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // Display a warning
                if (isPublisher)
                {
                    errorProcesser.ProcessWarning("Putting the parallel task in the publishers section may cause unpredictable results");
                }
            }
        }
Пример #45
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser"></param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            if (security.RequiresServerSecurity &&
                (configuration.SecurityManager is NullSecurityManager))
            {
                errorProcesser.ProcessError(
                    new ConfigurationException(
                        string.Format(System.Globalization.CultureInfo.CurrentCulture, "Security is defined for project '{0}', but not defined at the server", this.Name)));
            }

            this.ValidateProject(errorProcesser);
            this.ValidateItem(sourceControl, configuration, parent, errorProcesser);
            this.ValidateItem(labeller, configuration, parent, errorProcesser);
            this.ValidateItems(PrebuildTasks, configuration, parent, errorProcesser);
            this.ValidateItems(tasks, configuration, parent, errorProcesser);
            this.ValidateItems(publishers, configuration, parent, errorProcesser);
            this.ValidateItem(state, configuration, parent, errorProcesser);
            this.ValidateItem(security, configuration, parent, errorProcesser);

            var mt = (MultipleTrigger)this.Triggers;
            if (mt != null)
            {
                this.ValidateItems(mt.Triggers, configuration, parent, errorProcesser);
            }

            this.configuration = configuration;
        }
Пример #46
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            var parentProject = parent.GetAncestorValue<Project>();
            if (parentProject != null)
            {
                // Attempt to find this publisher in the publishers section
                var isPublisher = false;
                foreach (var task in parentProject.Publishers)
                {
                    if (task == this)
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // If not found then throw a validation exception
                if (!isPublisher)
                {
                    errorProcesser.ProcessWarning("Email publishers are best placed in the publishers section of the configuration");
                }
            }
            else
            {
                errorProcesser.ProcessError(
                    new CruiseControlException("This publisher can only belong to a project"));
            }
        }
Пример #47
0
        /// <summary>
        /// Validates the configuration of an item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="errorProcesser">The error processer.</param>
        private void ValidateItem(object item, IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            if (item == null) return;

            var dummy = item as IConfigurationValidation;
            if (dummy != null)
            {
                dummy.Validate(configuration, parent.Wrap(this), errorProcesser);
            }
        }
        /// <summary>
        /// Validates this task.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            // Validate the conditions
            var trace = parent.Wrap(this);
            foreach (var condition in this.TaskConditions ?? new ITaskCondition[0])
            {
                var validation = condition as IConfigurationValidation;
                if (validation != null)
                {
                    validation.Validate(
                        configuration,
                        trace,
                        errorProcesser);
                }
            }

            // Validate the tasks
            this.ValidateTasks(this.Tasks, configuration, trace, errorProcesser);
            this.ValidateTasks(this.ElseTasks, configuration, trace, errorProcesser);
        }
 public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     IsValided = true;
 }
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser"></param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            var isInitialised = false;
            try
            {
                Initialise();
                isInitialised = true;
            }
            catch (Exception error)
            {
                errorProcesser.ProcessError(error);
            }

            if (isInitialised)
            {
                foreach (IAuthentication user in this.loadedUsers.Values)
                {
                    if (user is IConfigurationValidation)
                    {
                        (user as IConfigurationValidation).Validate(configuration, parent.Wrap(this), errorProcesser);
                    }
                }

                foreach (IPermission permission in this.loadedPermissions.Values)
                {
                    if (permission is IConfigurationValidation)
                    {
                        (permission as IConfigurationValidation).Validate(configuration, parent.Wrap(this), errorProcesser);
                    }
                }
            }
        }
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public override void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            base.Validate(configuration, parent, errorProcesser);
            if (this.Verbose && this.Quiet)
            {
                errorProcesser.ProcessError("Cannot have both verbose and quiet set");
            }

            if (this.ProfilerTimeOut < 0)
            {
                errorProcesser.ProcessError("profilerTimeout cannot be negative");
            }
        }
Пример #52
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            var parentProject = parent.GetAncestorValue<Project>();
            if (parentProject != null)
            {
                // Attempt to find this publisher in the publishers section
                var isPublisher = false;
                foreach (var task in parentProject.Publishers)
                {
                    if (task == this)
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // If not found then throw a validation exception
                if (!isPublisher)
                {
                    errorProcesser.ProcessWarning(
                        "Email publishers are best placed in the publishers section of the configuration");
                }
            }
            else
            {
                errorProcesser.ProcessError(new CruiseControlException("This publisher can only belong to a project"));
            }

            // Make sure the xslFiles are not empty
            if (this.xslFiles != null &&  this.XslFiles.Any(f => string.IsNullOrEmpty(f)))
            {
                errorProcesser.ProcessError("xslFiles cannot contain empty or null filenames");
            }
        }
Пример #53
0
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     try
     {
         this.GetFBVersion();
         this.GetFBPath();
     }
     catch (Exception error)
     {
         errorProcesser.ProcessError(error);
     }
 }
Пример #54
0
        public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            string ErrorInfo = "Invalid chars in TFS workspace name. Look at http://msdn.microsoft.com/en-us/library/aa980550.aspx#SourceControl for naming restrictions.";

            bool AllOk = true;
            System.Collections.Generic.List<string> badchars = new System.Collections.Generic.List<string>();

            badchars.Add("/");
            badchars.Add(":");
            badchars.Add("<");
            badchars.Add(">");
            badchars.Add("|");
            badchars.Add(@"\");
            badchars.Add("*");
            badchars.Add("?");
            badchars.Add(";");


            if (workspaceName.Length > 64)
            {
                AllOk = false;
                ErrorInfo += System.Environment.NewLine + "Max length is 64 chars";
            }
            if (workspaceName.EndsWith(" "))
            {
                AllOk = false;
                ErrorInfo += System.Environment.NewLine + "can not end with space";
            }


            foreach (string s in badchars)
            {
                if (workspaceName.Contains(s))
                {
                    AllOk = false;
                    ErrorInfo += System.Environment.NewLine + "can not contain character " + s;
                }
            }

            if (!AllOk) errorProcesser.ProcessError(ErrorInfo);
        }
Пример #55
0
 /// <summary>
 /// Validates the configuration of an item.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="configuration"></param>
 /// <param name="errorProcesser"></param>
 private void ValidateItem(object item, IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if ((item != null) && (item is IConfigurationValidation))
     {
         (item as IConfigurationValidation).Validate(configuration, parent.Wrap(this), errorProcesser);
     }
 }
Пример #56
0
 /// <summary>
 /// Validates the configuration of an enumerable.
 /// </summary>
 /// <param name="items">The items.</param>
 /// <param name="configuration">The configuration.</param>
 /// <param name="parent">The parent.</param>
 /// <param name="errorProcesser">The error processer.</param>
 private void ValidateItems(IEnumerable items, IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if (items != null)
     {
         foreach (object item in items)
         {
             this.ValidateItem(item, configuration, parent, errorProcesser);
         }
     }
 }
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser"></param>
 public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     foreach (IPermission permission in permissions)
     {
         var dummy = permission as IConfigurationValidation;
         if (dummy != null)
         {
             dummy.Validate(configuration, parent.Wrap(this), errorProcesser);
         }
     }
 }
Пример #58
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            if (string.IsNullOrEmpty(AwsAccessKey))
            {
                errorProcesser.ProcessError("awsAccessKey cannot be empty");
            }

            if (string.IsNullOrEmpty(AwsSecretAccessKey))
            {
                errorProcesser.ProcessError("awsSecretAccessKey cannot be empty");
            }

            if (!Uri.IsWellFormedUriString(QueueUrl, UriKind.Absolute))
            {
                errorProcesser.ProcessError("queueUrl is not well-formed");
            }
        }
Пример #59
0
        void IConfigurationValidation.Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            string projectName = "(Unknown)";

            var project = parent.GetAncestorValue<Project>();
            if (project != null)
            {
                projectName = project.Name;
            }

            if (integrationTime.Minutes + RandomOffSetInMinutesFromTime >= 60)
            {
                errorProcesser.ProcessError("Scheduled time {0}:{1} + randomOffSetInMinutesFromTime {2} would exceed the hour, this is not allowed. Conflicting project {3}", integrationTime.Hours, integrationTime.Minutes, RandomOffSetInMinutesFromTime, projectName);
            }
        }
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser"></param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            foreach (IAuthentication user in users)
            {
                if (user is IConfigurationValidation)
                {
                    (user as IConfigurationValidation).Validate(configuration, parent.Wrap(this), errorProcesser);
                }
            }

            foreach (IPermission permission in permissions)
            {
                if (permission is IConfigurationValidation)
                {
                    (permission as IConfigurationValidation).Validate(configuration, parent.Wrap(this), errorProcesser);
                }
            }
        }