String Validate(DbConnectionStringBuilder connStrBldr)
        {
            IConnectionStringValidator csv = new ConnectionStringValidator();

            _testedConnectionString = connStrBldr.ConnectionString;
            return(csv.Validate(_testedConnectionString));
        }
        public void IsValid_WithNullOrEmptyConnectionString_ShouldReturnFalseAndEmptyErrorMessage(
            [Values("", " ", null)] string connectionString
            )
        {
            var result = ConnectionStringValidator.IsValid(connectionString, _connectionStringName, out var errorMessage);

            Assert.That(result, Is.False);
            Assert.That(errorMessage, Is.EqualTo(_connectionStringName + " is null or empty"));
        }
 protected override void ValidateConnectionString()
 {
     try
     {
         ConnectionStringValidator.Validate(this);
     }
     catch (EngineValidationException ex)
     {
         ReportCard.Errors.Add(ex.Message);
     }
 }
        public void IsValid_WithInvalidConnectionString_ShouldReturnFalseAndEmptyErrorMessage()
        {
            var result = ConnectionStringValidator.IsValid(
                Constants.InvalidConnectionString,
                _connectionStringName,
                out var errorMessage
                );

            Assert.That(result, Is.False);
            Assert.That(errorMessage, Is.SupersetOf(_connectionStringName + " is invalid: "));
        }
        public void IsValid_WithValidConnectionString_ShouldReturnTrueAndNullErrorMessage()
        {
            var result = ConnectionStringValidator.IsValid(
                Constants.ValidConnectionString,
                _connectionStringName,
                out var errorMessage
                );

            Assert.That(result, Is.True);
            Assert.That(errorMessage, Is.Null);
        }
        public void ValidateChanges()
        {
            try
            {
                new PathsValidator(this).RunValidation(false);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                ServiceControlQueueNameValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            var oldSettings    = InstanceFinder.FindServiceControlInstance(Name);
            var passwordSet    = !string.IsNullOrWhiteSpace(ServiceAccountPwd);
            var accountChanged = !string.Equals(oldSettings.ServiceAccount, ServiceAccount, StringComparison.OrdinalIgnoreCase);

            if (passwordSet || accountChanged)
            {
                try
                {
                    ServiceAccountValidation.Validate(this);
                }
                catch (IdentityNotMappedException)
                {
                    ReportCard.Errors.Add("The service account specified does not exist");
                    return;
                }
                catch (EngineValidationException ex)
                {
                    ReportCard.Errors.Add(ex.Message);
                    return;
                }
            }

            try
            {
                ConnectionStringValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }
        }
        public ValidateOptionsResult Validate(string name, AzureTopicEventSenderOptions options)
        {
            if (!ConnectionStringValidator.IsValid(
                    options.SendConnectionString,
                    nameof(options.SendConnectionString),
                    out var errorMessage
                    )
                )
            {
                return(ValidateOptionsResult.Fail(errorMessage));
            }

            return(ValidateOptionsResult.Success);
        }
        public ValidateOptionsResult Validate(string name, AzureTopicEventReceiverOptions options)
        {
            if (!ConnectionStringValidator.IsValid(
                    options.ReceiveConnectionString,
                    nameof(options.ReceiveConnectionString),
                    out var receiveConnectionStringErrorMessage
                    )
                )
            {
                return(ValidateOptionsResult.Fail(receiveConnectionStringErrorMessage));
            }

            if (options.IsSubscriptionCreationEnabled && !ConnectionStringValidator.IsValid(
                    options.ManagementConnectionString,
                    nameof(options.ManagementConnectionString),
                    out var managementConnectionStringErrorMessage
                    )
                )
            {
                return(ValidateOptionsResult.Fail(managementConnectionStringErrorMessage));
            }

            if (string.IsNullOrWhiteSpace(options.SubscriptionName) && options.SubscriptionNameProvider == null)
            {
                return(ValidateOptionsResult.Fail(
                           $"{nameof(options.SubscriptionName)} and {nameof(options.SubscriptionNameProvider)} are null or empty," +
                           $" please specify at least one of the parameters"
                           ));
            }

            if (string.IsNullOrWhiteSpace(options.TopicPath))
            {
                return(ValidateOptionsResult.Fail(
                           $"{nameof(options.TopicPath)} is null or empty"
                           ));
            }

            return(ValidateOptionsResult.Success);
        }
Exemple #9
0
        public void Validate(Func <PathInfo, bool> promptToProceed)
        {
            if (TransportPackage.Equals("MSMQ", StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    MsmqConfigValidator.Validate();
                }
                catch (EngineValidationException ex)
                {
                    ReportCard.Errors.Add(ex.Message);
                }
            }

            try
            {
                PortValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                DatabaseMaintenancePortValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                ReportCard.CancelRequested = new PathsValidator(this).RunValidation(true, promptToProceed);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                ServiceControlQueueNameValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                CheckForConflictingUrlAclReservations();
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                ServiceAccountValidation.Validate(this);
                ConnectionStringValidator.Validate(this);
            }
            catch (IdentityNotMappedException)
            {
                ReportCard.Errors.Add("The service account specified does not exist");
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }
        }
Exemple #10
0
        public override ValidationsGroup Create(ProcessContext processContext)
        {
            processContext.ThrowIfNull(nameof(processContext));

            ProjectConfigItem projectConfig = (processContext as CommonProcessContext).ProjectConfig;


            ValidationsGroup validationsGroup = new ValidationsGroup(true);

            IdMandatory projectIdValidator = new IdMandatory(projectConfig.Id);

            validationsGroup.Add(projectIdValidator);

            DBTypeValidator dbTypeValidator = new DBTypeValidator(projectConfig.DBConnectionInfo.DBType, _dbCommandsFactory);

            validationsGroup.Add(dbTypeValidator);


            DBNameValidator dbNameValidator = new DBNameValidator(projectConfig.DBConnectionInfo.DBName);

            validationsGroup.Add(dbNameValidator);

            ConnectionStringValidator connectionStringValidator = new ConnectionStringValidator(projectConfig.DBConnectionInfo, _dbCommandsFactory);

            validationsGroup.Add(connectionStringValidator);

            AdminConnectionStringValidator adminConnectionStringValidator = new AdminConnectionStringValidator(projectConfig.DBConnectionInfo, _dbCommandsFactory);

            validationsGroup.Add(adminConnectionStringValidator);

            DBBackupFolderValidator dbBackupBaseFolderValidator = new DBBackupFolderValidator(projectConfig.BackupFolderPath);

            validationsGroup.Add(dbBackupBaseFolderValidator);

            if (projectConfig.DevEnvironment)
            {
                DevScriptsBaseFolderPathValidator scriptsRootFolderPathValidator = new DevScriptsBaseFolderPathValidator(projectConfig.DevEnvironment, projectConfig.DevScriptsBaseFolderPath);
                validationsGroup.Add(scriptsRootFolderPathValidator);

                if (!string.IsNullOrWhiteSpace(projectConfig.DevScriptsBaseFolderPath))
                {
                    ScriptsFolderPathValidator incrementalScriptsFolderPathValidator =
                        new ScriptsFolderPathValidator(nameof(projectConfig.IncrementalScriptsFolderPath), projectConfig.IncrementalScriptsFolderPath);
                    validationsGroup.Add(incrementalScriptsFolderPathValidator);

                    ScriptsFolderPathValidator repeatableScriptsFolderPathValidator =
                        new ScriptsFolderPathValidator(nameof(projectConfig.RepeatableScriptsFolderPath), projectConfig.RepeatableScriptsFolderPath);
                    validationsGroup.Add(repeatableScriptsFolderPathValidator);

                    ScriptsFolderPathValidator devDummyDataScriptsFolderPathValidator =
                        new ScriptsFolderPathValidator(nameof(projectConfig.DevDummyDataScriptsFolderPath), projectConfig.DevDummyDataScriptsFolderPath);
                    validationsGroup.Add(devDummyDataScriptsFolderPathValidator);
                }

                DeployArtifactFolderPathValidator deployArtifactFolderPathValidator = new DeployArtifactFolderPathValidator(projectConfig.DeployArtifactFolderPath);
                validationsGroup.Add(deployArtifactFolderPathValidator);
            }
            else
            {
                DeliveryArtifactFolderPathValidator deliveryArtifactFolderPathValidator = new DeliveryArtifactFolderPathValidator(projectConfig.DeliveryArtifactFolderPath);
                validationsGroup.Add(deliveryArtifactFolderPathValidator);
            }


            return(validationsGroup);
        }
Exemple #11
0
 protected override void ValidateConnectionString()
 {
     ConnectionStringValidator.Validate(this);
 }
        public void Should_throw()
        {
            var connectionString = "DefaultEndpointsProtocol=https;AccountName=abcdefg;AccountKey=kIHCqw2jaATPAaayJoiJwPEYZITu2Ic5p4rDyJ5OhU97aub4IzoNCuTbuWgeaY29zQcw==;TableEndpoint=https://abcdefg.table.cosmos.azure.com:443/;";

            Assert.Throws <Exception>(() => ConnectionStringValidator.ThrowIfPremiumEndpointConnectionString(connectionString));
        }