From 67fa3affac5be535f4402f786cd84afacc3d7a6d Mon Sep 17 00:00:00 2001 From: Paul Volavsek Date: Tue, 9 Apr 2024 08:23:34 +0200 Subject: [PATCH 1/2] rename launcher scripts. fix download timeout handling. --- scripts/linux/{install.sh => launcher-install.sh} | 0 scripts/linux/{test.sh => launcher-test.sh} | 0 scripts/linux/{uninstall.sh => launcher-uninstall.sh} | 0 scripts/macos/{test.sh => launcher-test.sh} | 0 scripts/windows/{install.cmd => launcher-install.cmd} | 0 scripts/windows/{migrate.cmd => launcher-migrate.cmd} | 0 scripts/windows/{test.cmd => launcher-test.cmd} | 0 scripts/windows/{uninstall.cmd => launcher-uninstall.cmd} | 0 .../Configuration/Configuration.cs | 2 +- src/fiskaltrust.Launcher/Helpers/PolicyHelper.cs | 5 ++--- 10 files changed, 3 insertions(+), 4 deletions(-) rename scripts/linux/{install.sh => launcher-install.sh} (100%) rename scripts/linux/{test.sh => launcher-test.sh} (100%) rename scripts/linux/{uninstall.sh => launcher-uninstall.sh} (100%) rename scripts/macos/{test.sh => launcher-test.sh} (100%) rename scripts/windows/{install.cmd => launcher-install.cmd} (100%) rename scripts/windows/{migrate.cmd => launcher-migrate.cmd} (100%) rename scripts/windows/{test.cmd => launcher-test.cmd} (100%) rename scripts/windows/{uninstall.cmd => launcher-uninstall.cmd} (100%) diff --git a/scripts/linux/install.sh b/scripts/linux/launcher-install.sh similarity index 100% rename from scripts/linux/install.sh rename to scripts/linux/launcher-install.sh diff --git a/scripts/linux/test.sh b/scripts/linux/launcher-test.sh similarity index 100% rename from scripts/linux/test.sh rename to scripts/linux/launcher-test.sh diff --git a/scripts/linux/uninstall.sh b/scripts/linux/launcher-uninstall.sh similarity index 100% rename from scripts/linux/uninstall.sh rename to scripts/linux/launcher-uninstall.sh diff --git a/scripts/macos/test.sh b/scripts/macos/launcher-test.sh similarity index 100% rename from scripts/macos/test.sh rename to scripts/macos/launcher-test.sh diff --git a/scripts/windows/install.cmd b/scripts/windows/launcher-install.cmd similarity index 100% rename from scripts/windows/install.cmd rename to scripts/windows/launcher-install.cmd diff --git a/scripts/windows/migrate.cmd b/scripts/windows/launcher-migrate.cmd similarity index 100% rename from scripts/windows/migrate.cmd rename to scripts/windows/launcher-migrate.cmd diff --git a/scripts/windows/test.cmd b/scripts/windows/launcher-test.cmd similarity index 100% rename from scripts/windows/test.cmd rename to scripts/windows/launcher-test.cmd diff --git a/scripts/windows/uninstall.cmd b/scripts/windows/launcher-uninstall.cmd similarity index 100% rename from scripts/windows/uninstall.cmd rename to scripts/windows/launcher-uninstall.cmd diff --git a/src/fiskaltrust.Launcher.Common/Configuration/Configuration.cs b/src/fiskaltrust.Launcher.Common/Configuration/Configuration.cs index 2f42d414..e05a8c42 100644 --- a/src/fiskaltrust.Launcher.Common/Configuration/Configuration.cs +++ b/src/fiskaltrust.Launcher.Common/Configuration/Configuration.cs @@ -316,7 +316,7 @@ public void Encrypt(IDataProtector dataProtector) { return dataProtector.Protect((string)value); } - catch (Exception e) + catch { Log.Warning($"Failed to encrypt value of configuration field {name}. Consider using the 'config set' command to set the field's value.", name); return null; diff --git a/src/fiskaltrust.Launcher/Helpers/PolicyHelper.cs b/src/fiskaltrust.Launcher/Helpers/PolicyHelper.cs index cdf1bdfa..48484455 100644 --- a/src/fiskaltrust.Launcher/Helpers/PolicyHelper.cs +++ b/src/fiskaltrust.Launcher/Helpers/PolicyHelper.cs @@ -13,6 +13,7 @@ public sealed class PolicyHttpClient : IDisposable public PolicyHttpClient(LauncherConfiguration configuration, HttpClient httpClient) { _httpClient = httpClient; + _httpClient.Timeout = TimeSpan.FromSeconds(configuration.DownloadTimeoutSec!.Value); _policy = GetPolicy(configuration); } @@ -24,9 +25,7 @@ private IAsyncPolicy GetPolicy(LauncherConfiguration config configuration.DownloadRetry!.Value, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))); - var timeoutPolicy = Policy.TimeoutAsync(configuration.DownloadTimeoutSec!.Value); - - return Policy.WrapAsync(retryPolicy, timeoutPolicy); + return retryPolicy; } public Task SendAsync(Func getMessage) => _policy.ExecuteAsync(ct => _httpClient.SendAsync(getMessage(), ct), CancellationToken.None); From 3455bb935b78cfdadb0c335853290578d07d897d Mon Sep 17 00:00:00 2001 From: Paul Volavsek Date: Tue, 9 Apr 2024 12:13:18 +0200 Subject: [PATCH 2/2] fix tests --- .../Download/ConfigurationDownloaderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fiskaltrust.Launcher.IntegrationTest/Download/ConfigurationDownloaderTests.cs b/test/fiskaltrust.Launcher.IntegrationTest/Download/ConfigurationDownloaderTests.cs index 56ce742d..9e6a6902 100644 --- a/test/fiskaltrust.Launcher.IntegrationTest/Download/ConfigurationDownloaderTests.cs +++ b/test/fiskaltrust.Launcher.IntegrationTest/Download/ConfigurationDownloaderTests.cs @@ -87,7 +87,7 @@ public async Task DownloadConfigurationAsync_ShouldTimeout() var downloader = new ConfigurationDownloader(config, httpClient); var clientCurve = ECDiffieHellman.Create(); - await Assert.ThrowsAsync(() => downloader.DownloadConfigurationAsync(clientCurve)); + await Assert.ThrowsAsync(() => downloader.DownloadConfigurationAsync(clientCurve)); } } }