Skip to content

Commit

Permalink
Merge pull request #172 from fiskaltrust/fixes
Browse files Browse the repository at this point in the history
Rename launcher scripts and fix download timeout handling.
  • Loading branch information
volllly authored Apr 9, 2024
2 parents c9ad1b6 + 3455bb9 commit 5287a8f
Show file tree
Hide file tree
Showing 11 changed files with 4 additions and 5 deletions.
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.
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));
}
}
}

0 comments on commit 5287a8f

Please sign in to comment.