From cfd28da562815fafcebbb06611e760ef344b9c6e Mon Sep 17 00:00:00 2001 From: Paul Volavsek Date: Tue, 24 Oct 2023 16:29:03 +0200 Subject: [PATCH] rename plebeian --- .../Commands/DoctorCommand.cs | 22 ++++++++--------- .../Commands/HostCommand.cs | 14 +++++------ .../Configuration/PlebianConfiguration.cs | 6 ++--- .../Helpers/SerializerContext.cs | 2 +- .../ProcessHost/ProcessHostMonarch.cs | 14 +++++------ ...sHostPlebian.cs => ProcessHostPlebeian.cs} | 18 +++++++------- .../Services/EncodingProvider.cs | 2 +- .../PlebeianTests.cs} | 24 +++++++++---------- 8 files changed, 51 insertions(+), 51 deletions(-) rename src/fiskaltrust.Launcher/ProcessHost/{ProcessHostPlebian.cs => ProcessHostPlebeian.cs} (89%) rename test/fiskaltrust.Launcher.IntegrationTest/{Plebian/PlebianTests.cs => Plebeian/PlebeianTests.cs} (92%) diff --git a/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs b/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs index 159830dc..36266d91 100644 --- a/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs +++ b/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs @@ -158,7 +158,7 @@ public async Task InvokeAsync(InvocationContext context) await CheckAwait("Start monarch WebApplication", async () => await WithTimeout(async () => await monarchApp.StartAsync(_lifetime.ApplicationLifetime.ApplicationStopping), TimeSpan.FromSeconds(5)), throws: true); - var plebianConfiguration = new PlebianConfiguration + var plebeianConfiguration = new PlebeianConfiguration { PackageId = doctorId, PackageType = Constants.PackageType.Queue @@ -167,24 +167,24 @@ public async Task InvokeAsync(InvocationContext context) var packageConfiguration = new PackageConfiguration { Configuration = new(), - Id = plebianConfiguration.PackageId, + Id = plebeianConfiguration.PackageId, Package = "none", Url = Array.Empty(), Version = "1.0.0" }; - IProcessHostService? processHostService = Check("Start plebian processhostservice client", () => GrpcChannel.ForAddress($"http://localhost:{launcherConfiguration.LauncherPort}").CreateGrpcService()); + IProcessHostService? processHostService = Check("Start plebeian processhostservice client", () => GrpcChannel.ForAddress($"http://localhost:{launcherConfiguration.LauncherPort}").CreateGrpcService()); - var plebianBuilder = Host.CreateDefaultBuilder() + var plebeianBuilder = Host.CreateDefaultBuilder() .UseSerilog(new LoggerConfiguration().CreateLogger()) .ConfigureServices(services => { - Check("Setup plebian services", () => + Check("Setup plebeian services", () => { services.Configure(opts => opts.ShutdownTimeout = TimeSpan.FromSeconds(30)); services.AddSingleton(_ => launcherConfiguration); services.AddSingleton(_ => packageConfiguration); - services.AddSingleton(_ => plebianConfiguration); + services.AddSingleton(_ => plebeianConfiguration); var pluginLoader = new PluginLoader(); services.AddSingleton(_ => pluginLoader); @@ -195,7 +195,7 @@ public async Task InvokeAsync(InvocationContext context) } services.AddSingleton(); - services.AddHostedService(); + services.AddHostedService(); services.AddSingleton, DESSCDClientFactory>(); services.AddSingleton, POSClientFactory>(); @@ -212,9 +212,9 @@ public async Task InvokeAsync(InvocationContext context) }, throws: true); }); - var plebianApp = Check("Build plebian Host", plebianBuilder.Build, throws: true)!; + var plebeianApp = Check("Build plebeian Host", plebeianBuilder.Build, throws: true)!; - await CheckAwait("Start plebian Host", async () => await WithTimeout(async () => await plebianApp.StartAsync(_lifetime.ApplicationLifetime.ApplicationStopping), TimeSpan.FromSeconds(5))); + await CheckAwait("Start plebeian Host", async () => await WithTimeout(async () => await plebeianApp.StartAsync(_lifetime.ApplicationLifetime.ApplicationStopping), TimeSpan.FromSeconds(5))); await doctorProcessHostMonarch.IsStarted.Task; @@ -225,8 +225,8 @@ await CheckAwait("Shutdown launcher gracefully", async () => await WithTimeout(a await monarchApp.StopAsync(); await monarchApp.WaitForShutdownAsync(); - await plebianApp.StopAsync(); - await plebianApp.WaitForShutdownAsync(); + await plebeianApp.StopAsync(); + await plebeianApp.WaitForShutdownAsync(); }, TimeSpan.FromSeconds(5)) ); } diff --git a/src/fiskaltrust.Launcher/Commands/HostCommand.cs b/src/fiskaltrust.Launcher/Commands/HostCommand.cs index 965c4d8a..bb6bec54 100644 --- a/src/fiskaltrust.Launcher/Commands/HostCommand.cs +++ b/src/fiskaltrust.Launcher/Commands/HostCommand.cs @@ -28,7 +28,7 @@ public class HostCommand : Command { public HostCommand() : base("host") { - AddOption(new Option("--plebian-configuration")); + AddOption(new Option("--plebeian-configuration")); AddOption(new Option("--debugging")); AddOption(new Option("--launcher-configuration")); AddOption(new Option("--no-process-host-service", getDefaultValue: () => false)); @@ -38,7 +38,7 @@ public HostCommand() : base("host") public class HostCommandHandler : ICommandHandler { public string LauncherConfiguration { get; set; } = null!; - public string PlebianConfiguration { get; set; } = null!; + public string PlebeianConfiguration { get; set; } = null!; public bool NoProcessHostService { get; set; } public bool Debugging { get; set; } @@ -63,19 +63,19 @@ public async Task InvokeAsync(InvocationContext context) var launcherConfiguration = Common.Configuration.LauncherConfiguration.Deserialize(System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(LauncherConfiguration))); - var plebianConfiguration = Configuration.PlebianConfiguration.Deserialize(System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(PlebianConfiguration))); + var plebeianConfiguration = Configuration.PlebeianConfiguration.Deserialize(System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(PlebeianConfiguration))); var cashboxConfiguration = CashBoxConfigurationExt.Deserialize(await File.ReadAllTextAsync(launcherConfiguration.CashboxConfigurationFile!)); cashboxConfiguration.Decrypt(launcherConfiguration, await CommonCommandHandler.LoadCurve(launcherConfiguration.AccessToken!, launcherConfiguration.UseLegacyDataProtection!.Value)); - var packageConfiguration = (plebianConfiguration.PackageType switch + var packageConfiguration = (plebeianConfiguration.PackageType switch { PackageType.Queue => cashboxConfiguration.ftQueues, PackageType.SCU => cashboxConfiguration.ftSignaturCreationDevices, PackageType.Helper => cashboxConfiguration.helpers, var unknown => throw new Exception($"Unknown PackageType {unknown}") - }).First(p => p.Id == plebianConfiguration.PackageId); + }).First(p => p.Id == plebeianConfiguration.PackageId); packageConfiguration.Configuration = ProcessPackageConfiguration(packageConfiguration.Configuration, launcherConfiguration, cashboxConfiguration); @@ -103,7 +103,7 @@ public async Task InvokeAsync(InvocationContext context) }); services.AddSingleton(_ => launcherConfiguration); services.AddSingleton(_ => packageConfiguration); - services.AddSingleton(_ => plebianConfiguration); + services.AddSingleton(_ => plebeianConfiguration); var pluginLoader = new PluginLoader(); services.AddSingleton(_ => pluginLoader); @@ -114,7 +114,7 @@ public async Task InvokeAsync(InvocationContext context) } services.AddSingleton(); - services.AddHostedService(); + services.AddHostedService(); services.AddSingleton, DESSCDClientFactory>(); services.AddSingleton, ITSSCDClientFactory>(); diff --git a/src/fiskaltrust.Launcher/Configuration/PlebianConfiguration.cs b/src/fiskaltrust.Launcher/Configuration/PlebianConfiguration.cs index 4b250c12..473bc863 100644 --- a/src/fiskaltrust.Launcher/Configuration/PlebianConfiguration.cs +++ b/src/fiskaltrust.Launcher/Configuration/PlebianConfiguration.cs @@ -3,13 +3,13 @@ namespace fiskaltrust.Launcher.Configuration { - public record PlebianConfiguration + public record PlebeianConfiguration { public PackageType PackageType { get; set; } public Guid PackageId { get; set; } - public static PlebianConfiguration Deserialize(string text) => JsonSerializer.Deserialize(text, typeof(PlebianConfiguration), Helpers.Serialization.SerializerContext.Default) as PlebianConfiguration ?? throw new Exception($"Could not deserialize {nameof(PlebianConfiguration)}"); + public static PlebeianConfiguration Deserialize(string text) => JsonSerializer.Deserialize(text, typeof(PlebeianConfiguration), Helpers.Serialization.SerializerContext.Default) as PlebeianConfiguration ?? throw new Exception($"Could not deserialize {nameof(PlebeianConfiguration)}"); - public string Serialize() => JsonSerializer.Serialize(this, typeof(PlebianConfiguration), Helpers.Serialization.SerializerContext.Default); + public string Serialize() => JsonSerializer.Serialize(this, typeof(PlebeianConfiguration), Helpers.Serialization.SerializerContext.Default); } } diff --git a/src/fiskaltrust.Launcher/Helpers/SerializerContext.cs b/src/fiskaltrust.Launcher/Helpers/SerializerContext.cs index f4d67a28..3950915f 100644 --- a/src/fiskaltrust.Launcher/Helpers/SerializerContext.cs +++ b/src/fiskaltrust.Launcher/Helpers/SerializerContext.cs @@ -3,6 +3,6 @@ namespace fiskaltrust.Launcher.Helpers.Serialization { - [JsonSerializable(typeof(PlebianConfiguration))] + [JsonSerializable(typeof(PlebeianConfiguration))] public partial class SerializerContext : JsonSerializerContext { } } \ No newline at end of file diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs index 87e0421d..e1c0768a 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs @@ -27,7 +27,7 @@ public class ProcessHostMonarch : IProcessHostMonarch private readonly PackageConfiguration _packageConfiguration; private readonly ILogger _logger; - private readonly List _plebianLogBuffer = new List(); + private readonly List _plebeianLogBuffer = new List(); private LauncherConfiguration _launcherConfiguration; private PackageType _packageType; private LauncherExecutablePath _launcherExecutablePath; @@ -63,7 +63,7 @@ private void Setup() CreateNoWindow = false, Arguments = string.Join(" ", new string[] { "host", - "--plebian-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(new PlebianConfiguration { PackageType = _packageType, PackageId = _packageConfiguration.Id }.Serialize()))}\"", + "--plebeian-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(new PlebeianConfiguration { PackageType = _packageType, PackageId = _packageConfiguration.Id }.Serialize()))}\"", "--launcher-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(_launcherConfiguration.Serialize()))}\"", }), RedirectStandardInput = true, @@ -81,7 +81,7 @@ private void ReceiveStdOut(object sender, DataReceivedEventArgs e) { if (e.Data != null) { - _plebianLogBuffer.Add(e.Data); + _plebeianLogBuffer.Add(e.Data); } } @@ -122,11 +122,11 @@ private async Task HandleExit(CancellationToken cancellationToken) if (!_started.Task.IsCompleted) { // If the process hat not signaled startup, we print the log buffer. - _logger.LogError($"Error while starting {{package}} {{id}}.{Environment.NewLine}{{error}}", _packageConfiguration.Package, _packageConfiguration.Id, string.Join(Environment.NewLine, _plebianLogBuffer)); - _plebianLogBuffer.Clear(); + _logger.LogError($"Error while starting {{package}} {{id}}.{Environment.NewLine}{{error}}", _packageConfiguration.Package, _packageConfiguration.Id, string.Join(Environment.NewLine, _plebeianLogBuffer)); + _plebeianLogBuffer.Clear(); } - // Plebian crash happened during the startup phase so we don't went to keep restarting. + // Plebeian crash happened during the startup phase so we don't went to keep restarting. if (!_monarchStartupCompleted) { _started.TrySetCanceled(); @@ -212,7 +212,7 @@ public void SetPlebeanStarted() _process.OutputDataReceived -= ReceiveStdOut; _process.ErrorDataReceived -= ReceiveStdOut; } - _plebianLogBuffer.Clear(); + _plebeianLogBuffer.Clear(); } public void SetStartupCompleted() diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebian.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebeian.cs similarity index 89% rename from src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebian.cs rename to src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebeian.cs index 256cdc76..d1b16257 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebian.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebeian.cs @@ -13,24 +13,24 @@ namespace fiskaltrust.Launcher.ProcessHost { - public class ProcessHostPlebian : BackgroundService + public class ProcessHostPlebeian : BackgroundService { private readonly PackageConfiguration _packageConfiguration; private readonly IProcessHostService? _processHostService; private readonly HostingService _hosting; - private readonly PlebianConfiguration _plebianConfiguration; + private readonly PlebeianConfiguration _plebeianConfiguration; private readonly LauncherConfiguration _launcherConfiguration; - private readonly ILogger _logger; + private readonly ILogger _logger; private readonly IServiceProvider _services; private readonly IHostApplicationLifetime _lifetime; - public ProcessHostPlebian(ILogger logger, HostingService hosting, LauncherConfiguration launcherConfiguration, PackageConfiguration packageConfiguration, PlebianConfiguration plebianConfiguration, IServiceProvider services, IHostApplicationLifetime lifetime, IProcessHostService? processHostService = null) + public ProcessHostPlebeian(ILogger logger, HostingService hosting, LauncherConfiguration launcherConfiguration, PackageConfiguration packageConfiguration, PlebeianConfiguration plebeianConfiguration, IServiceProvider services, IHostApplicationLifetime lifetime, IProcessHostService? processHostService = null) { _logger = logger; _hosting = hosting; _launcherConfiguration = launcherConfiguration; _packageConfiguration = packageConfiguration; - _plebianConfiguration = plebianConfiguration; + _plebeianConfiguration = plebeianConfiguration; _services = services; _processHostService = processHostService; _lifetime = lifetime; @@ -45,7 +45,7 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken) { await StartHosting(_packageConfiguration.Url); - if (_plebianConfiguration.PackageType == PackageType.Helper) + if (_plebeianConfiguration.PackageType == PackageType.Helper) { _logger.LogDebug("Helper StartBegin() and StartEnd()"); var helper = _services.GetRequiredService(); @@ -69,7 +69,7 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken) try { - if (_plebianConfiguration.PackageType == PackageType.Helper) + if (_plebeianConfiguration.PackageType == PackageType.Helper) { IHelper helper; try @@ -118,7 +118,7 @@ private async Task StartHosting(string[] uris) { var hostingFailedCompletely = uris.Length > 0; - (object instance, Action addEndpoints, Type instanceInterface) = _plebianConfiguration.PackageType switch + (object instance, Action addEndpoints, Type instanceInterface) = _plebeianConfiguration.PackageType switch { PackageType.Queue => GetQueue(_services), PackageType.SCU => GetScu(_services), @@ -140,7 +140,7 @@ private async Task StartHosting(string[] uris) try { - switch (_plebianConfiguration.PackageType) + switch (_plebeianConfiguration.PackageType) { case PackageType.SCU: if (instanceInterface == typeof(IDESSCD)) diff --git a/src/fiskaltrust.Launcher/Services/EncodingProvider.cs b/src/fiskaltrust.Launcher/Services/EncodingProvider.cs index 8f2d7e47..3080bf5e 100644 --- a/src/fiskaltrust.Launcher/Services/EncodingProvider.cs +++ b/src/fiskaltrust.Launcher/Services/EncodingProvider.cs @@ -6,7 +6,7 @@ public class LauncherEncodingProvider : EncodingProvider { public override Encoding? GetEncoding(int codepage) => null; - // This EncodingProvider needs to be registered in the plebian processes + // This EncodingProvider needs to be registered in the plebeian processes // because ASP.NET Core uses the Encoding.GetEncoding(string) method to parse the charset of the Content-Type header. // According to the http standard (https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.1) the charset may be wrapped in quotes. // Until this is fixed in ASP.NET we'll need the workaround below. diff --git a/test/fiskaltrust.Launcher.IntegrationTest/Plebian/PlebianTests.cs b/test/fiskaltrust.Launcher.IntegrationTest/Plebeian/PlebeianTests.cs similarity index 92% rename from test/fiskaltrust.Launcher.IntegrationTest/Plebian/PlebianTests.cs rename to test/fiskaltrust.Launcher.IntegrationTest/Plebeian/PlebeianTests.cs index 500ea873..537696ff 100644 --- a/test/fiskaltrust.Launcher.IntegrationTest/Plebian/PlebianTests.cs +++ b/test/fiskaltrust.Launcher.IntegrationTest/Plebeian/PlebeianTests.cs @@ -16,7 +16,7 @@ using System.Net; using Xunit.Abstractions; -namespace fiskaltrust.Launcher.IntegrationTest.Plebian +namespace fiskaltrust.Launcher.IntegrationTest.Plebeian { public enum Binding { @@ -26,7 +26,7 @@ public enum Binding Hostname } - public class PlebianTests + public class PlebeianTests { [SkippableTheory] [InlineData(Binding.Localhost, true, new[] { 0, 1, 2 })] @@ -37,7 +37,7 @@ public class PlebianTests [InlineData(Binding.Ip, false, new[] { 16, 17, 18 })] [InlineData(Binding.Hostname, true, new[] { 19, 20, 21 })] [InlineData(Binding.Hostname, false, new[] { 22, 23, 24 })] - public async Task PlebianScu_WithGrpcAndRestAndSoapShouldRespond(Binding binding, bool useHttpSysBinding, int[] ports) + public async Task PlebeianScu_WithGrpcAndRestAndSoapShouldRespond(Binding binding, bool useHttpSysBinding, int[] ports) { Skip.If(!OperatingSystem.IsWindows() && useHttpSysBinding, "HttpSysBinding is only supported on windows"); Skip.If(OperatingSystem.IsWindows() && useHttpSysBinding && binding is not Binding.Localhost && !Runtime.IsAdministrator!.Value, $"Test needs to be run as an administrator with HttpSysBinding and {binding} binding"); @@ -106,7 +106,7 @@ await RunTest(new DummyDeSscd(), PackageType.SCU, packageConfiguration, [InlineData(Binding.Ip, false, new[] { 40, 41, 42 })] [InlineData(Binding.Hostname, true, new[] { 43, 44, 45 })] [InlineData(Binding.Hostname, false, new[] { 46, 47, 48 })] - public async Task PlebianQueue_WithGrpcAndRestAndSoapShouldRespond(Binding binding, bool useHttpSysBinding, int[] ports) + public async Task PlebeianQueue_WithGrpcAndRestAndSoapShouldRespond(Binding binding, bool useHttpSysBinding, int[] ports) { Skip.If(!OperatingSystem.IsWindows() && useHttpSysBinding, "HttpSysBinding is only supported on windows"); Skip.If(OperatingSystem.IsWindows() && useHttpSysBinding && !Runtime.IsAdministrator!.Value, $"Test needs to be run as an administrator with HttpSysBinding and {binding} binding"); @@ -170,7 +170,7 @@ await RunTest(new DummyPos(), PackageType.Queue, packageConfiguration, use [InlineData(Binding.Loopback, 50)] [InlineData(Binding.Ip, 51)] [InlineData(Binding.Hostname, 52)] - public async Task PlebianQueue_WithSamePort(Binding binding, int port) + public async Task PlebeianQueue_WithSamePort(Binding binding, int port) { Skip.If(!OperatingSystem.IsWindows(), "HttpSysBinding is only supported on windows"); Skip.If(OperatingSystem.IsWindows() && !Runtime.IsAdministrator!.Value, $"Test needs to be run as an administrator with HttpSysBinding and {binding} binding"); @@ -230,7 +230,7 @@ private async Task RunTest(T instance, PackageType packageType, PackageConfig UseHttpSysBinding = useHttpSysBinding }; - var plebianConfiguration = new PlebianConfiguration + var plebeianConfiguration = new PlebeianConfiguration { PackageId = packageConfiguration.Id, PackageType = packageType @@ -260,8 +260,8 @@ private async Task RunTest(T instance, PackageType packageType, PackageConfig )) .Verifiable(); - var loggerProcessHostPlebian = Mock.Of>(MockBehavior.Strict); - Mock.Get(loggerProcessHostPlebian) + var loggerProcessHostPlebeian = Mock.Of>(MockBehavior.Strict); + Mock.Get(loggerProcessHostPlebeian) .Setup(x => x.Log( It.IsNotIn(new[] { LogLevel.Error, LogLevel.Critical }), It.IsAny(), @@ -272,18 +272,18 @@ private async Task RunTest(T instance, PackageType packageType, PackageConfig .Verifiable(); var hostingService = new HostingService(loggerHostingService, packageConfiguration, launcherConfiguration, processHostService); - using var plebian = new ProcessHostPlebian(loggerProcessHostPlebian, hostingService, launcherConfiguration, packageConfiguration, plebianConfiguration, services.BuildServiceProvider(), lifetime, processHostService); - await plebian.StartAsync(new CancellationToken()); + using var plebeian = new ProcessHostPlebeian(loggerProcessHostPlebeian, hostingService, launcherConfiguration, packageConfiguration, plebeianConfiguration, services.BuildServiceProvider(), lifetime, processHostService); + await plebeian.StartAsync(new CancellationToken()); if (started.Task != await Task.WhenAny(started.Task, Task.Delay(TimeSpan.FromSeconds(10)))) { - throw new TimeoutException("plebian did not start in time"); + throw new TimeoutException("plebeian did not start in time"); } await Task.Run(checks); Mock.Get(logger).Verify(x => x.Error(It.IsAny()), Times.Never); Mock.Get(loggerHostingService).Verify(); - Mock.Get(loggerProcessHostPlebian).Verify(); + Mock.Get(loggerProcessHostPlebeian).Verify(); } }