public void Test_Verify_Option_No_Explicit_Options() { //arrange var traceService = new Mock <ITraceService>(); var environmentService = new Mock <IEnvironmentService>(); environmentService.Setup(s => s.GetCurrentDirectory()).Returns(@"c:\temp\yuniql"); environmentService.Setup(s => s.GetEnvironmentVariable("YUNIQL_CONNECTION_STRING")).Returns("sqlserver-connection-string"); var localVersionService = new Mock <ILocalVersionService>(); localVersionService.Setup(s => s.GetLatestVersion(@"c:\temp\yuniql")).Returns("v1.00"); var migrationService = new Mock <IMigrationService>(); var migrationServiceFactory = new Mock <CLI.IMigrationServiceFactory>(); migrationServiceFactory.Setup(s => s.Create("sqlserver")).Returns(migrationService.Object); //act var option = new VerifyOption { }; var sut = new CommandLineService(migrationServiceFactory.Object, localVersionService.Object, environmentService.Object, traceService.Object); sut.RunVerify(option); //assert var toolName = "yuniql-cli"; var toolVersion = typeof(CommandLineService).Assembly.GetName().Version.ToString(); migrationService.Verify(s => s.Initialize("sqlserver-connection-string", DEFAULT_CONSTANTS.COMMAND_TIMEOUT_SECS)); migrationService.Verify(s => s.Run(@"c:\temp\yuniql", "v1.00", false, It.Is <List <KeyValuePair <string, string> > >(x => x.Count == 0), true, DEFAULT_CONSTANTS.BULK_SEPARATOR, null, null, DEFAULT_CONSTANTS.COMMAND_TIMEOUT_SECS, 0, toolName, toolVersion, null, null, false)); }
// SetVerifyOption(nn::ssl::sf::VerifyOption) public ResultCode SetVerifyOption(ServiceCtx context) { VerifyOption verifyOption = (VerifyOption)context.RequestData.ReadUInt32(); Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { verifyOption }); return(ResultCode.Success); }
public ISslConnection(ulong processId, SslVersion sslVersion) { _processId = processId; _sslVersion = sslVersion; _ioMode = IoMode.Blocking; _sessionCacheMode = SessionCacheMode.None; _verifyOption = VerifyOption.PeerCa | VerifyOption.HostName; }
public void Test_Verify_Option_With_Tokens() { //arrange var traceService = new Mock <ITraceService>(); var environmentService = new Mock <IEnvironmentService>(); environmentService.Setup(s => s.GetCurrentDirectory()).Returns(@"c:\temp\yuniql"); environmentService.Setup(s => s.GetEnvironmentVariable("YUNIQL_CONNECTION_STRING")).Returns("sqlserver-connection-string"); var workspaceService = new Mock <IWorkspaceService>(); workspaceService.Setup(s => s.GetLatestVersion(@"c:\temp\yuniql")).Returns("v1.00"); var configuration = Configuration.Instance; configuration.Workspace = @"C:\temp\yuniql"; configuration.Platform = SUPPORTED_DATABASES.SQLSERVER; configuration.ConnectionString = "sqlserver-connection-string"; var configurationService = new Mock <IConfigurationService>(); configurationService.Setup(s => s.GetValueOrDefault(null, ENVIRONMENT_VARIABLE.YUNIQL_PLATFORM, SUPPORTED_DATABASES.SQLSERVER)).Returns(SUPPORTED_DATABASES.SQLSERVER); var migrationService = new Mock <IMigrationService>(); var migrationServiceFactory = new Mock <CLI.IMigrationServiceFactory>(); migrationServiceFactory.Setup(s => s.Create("sqlserver")).Returns(migrationService.Object); var dataService = new Mock <IDataService>(); var dataServiceFactory = new Mock <CLI.IDataServiceFactory>(); dataServiceFactory.Setup(s => s.Create("sqlserver")).Returns(dataService.Object); var manifest = new Mock <ManifestData>(); var manifestFactory = new Mock <IManifestFactory>(); manifestFactory.Setup(s => s.Create("sqlserver")).Returns(manifest.Object); //act var option = new VerifyOption { Tokens = new List <string> { "Token1=TokenValue1", "Token2=TokenValue2", "Token3=TokenValue3" } }; var sut = new CommandLineService(migrationServiceFactory.Object, dataServiceFactory.Object, manifestFactory.Object, workspaceService.Object, environmentService.Object, traceService.Object, configurationService.Object); sut.RunVerifyOption(option); //assert migrationService.Verify(s => s.Run()); }
public int RunVerifyOption(VerifyOption opts) { try { //run the migration var configuration = SetupRunConfiguration(opts, isVerifyOnly: true); var migrationService = _migrationServiceFactory.Create(configuration.Platform); migrationService.Run(); _traceService.Success($"Schema migration verification completed successfuly on {configuration.Workspace}."); return(0); } catch (Exception ex) { return(OnException(ex, "Failed to execute verification function. Target database will be rolled back to its previous state", opts.IsDebug)); } }
public int RunVerify(VerifyOption opts) { try { //if no path provided, we default into current directory if (string.IsNullOrEmpty(opts.Path)) { var workingPath = _environmentService.GetCurrentDirectory(); opts.Path = workingPath; } _traceService.Info($"Started verifcation from {opts.Path}."); //if no target platform provided, we default into sqlserver if (string.IsNullOrEmpty(opts.Platform)) { opts.Platform = _environmentService.GetEnvironmentVariable(ENVIRONMENT_VARIABLE.YUNIQL_TARGET_PLATFORM); if (string.IsNullOrEmpty(opts.Platform)) { opts.Platform = SUPPORTED_DATABASES.SQLSERVER; } } //if no connection string provided, we default into environment variable or throw exception if (string.IsNullOrEmpty(opts.ConnectionString)) { opts.ConnectionString = _environmentService.GetEnvironmentVariable(ENVIRONMENT_VARIABLE.YUNIQL_CONNECTION_STRING); } //if no target version specified, we capture the latest from local folder structure if (string.IsNullOrEmpty(opts.TargetVersion)) { opts.TargetVersion = _localVersionService.GetLatestVersion(opts.Path); _traceService.Info($"No explicit target version requested. We'll use latest available locally {opts.TargetVersion} on {opts.Path}."); } //parse tokens var tokens = opts.Tokens .Select(t => new KeyValuePair <string, string>(t.Split("=")[0], t.Split("=")[1])) .ToList(); //run the migration var toolName = "yuniql-cli"; var toolVersion = this.GetType().Assembly.GetName().Version.ToString(); //run the migration var migrationService = _migrationServiceFactory.Create(opts.Platform); migrationService.Initialize(opts.ConnectionString, opts.CommandTimeout); migrationService.Run(opts.Path, opts.TargetVersion, autoCreateDatabase: false, tokens: tokens, verifyOnly: true, bulkSeparator: opts.BulkSeparator, metaSchemaName: opts.MetaSchema, metaTableName: opts.MetaTable, commandTimeout: opts.CommandTimeout, bulkBatchSize: opts.BulkBatchSize, appliedByTool: toolName, appliedByToolVersion: toolVersion, environmentCode: opts.Environment, null); _traceService.Success($"Schema migration verification completed successfuly on {opts.Path}."); return(0); } catch (Exception ex) { return(OnException(ex, "Failed to execute verification function. Target database will be rolled back to its previous state", opts.Debug, _traceService)); } }