Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename launcher scripts and fix download timeout handling. #172

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/fiskaltrust.Launcher/Helpers/PolicyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -24,9 +25,7 @@ private IAsyncPolicy<HttpResponseMessage> GetPolicy(LauncherConfiguration config
configuration.DownloadRetry!.Value,
retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));

var timeoutPolicy = Policy.TimeoutAsync<HttpResponseMessage>(configuration.DownloadTimeoutSec!.Value);

return Policy.WrapAsync(retryPolicy, timeoutPolicy);
return retryPolicy;
}

public Task<HttpResponseMessage> SendAsync(Func<HttpRequestMessage> getMessage) => _policy.ExecuteAsync(ct => _httpClient.SendAsync(getMessage(), ct), CancellationToken.None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task DownloadConfigurationAsync_ShouldTimeout()
var downloader = new ConfigurationDownloader(config, httpClient);

var clientCurve = ECDiffieHellman.Create();
await Assert.ThrowsAsync<TimeoutRejectedException>(() => downloader.DownloadConfigurationAsync(clientCurve));
await Assert.ThrowsAsync<TaskCanceledException>(() => downloader.DownloadConfigurationAsync(clientCurve));
}
}
}
Loading