Skip to content

Commit

Permalink
build(deps): upgrade flurl
Browse files Browse the repository at this point in the history
* upgrade Flurl packages to the latest major
* remove Newtonsoft.Json references from all non test projects

Refs: #1052
  • Loading branch information
Phil91 committed Oct 2, 2024
1 parent 2922d43 commit 2e1367f
Show file tree
Hide file tree
Showing 252 changed files with 1,497 additions and 2,334 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities;
using Org.Eclipse.TractusX.Portal.Backend.Processes.Library;
using Org.Eclipse.TractusX.Portal.Backend.Processes.Mailing.Library;
using System.Collections.Immutable;
using System.Globalization;
using System.Text.Json;
using System.Text.RegularExpressions;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Extensions;
using Org.Eclipse.TractusX.Portal.Backend.Processes.Library;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Linq;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
********************************************************************************/

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
using Org.Eclipse.TractusX.Portal.Backend.Dim.Library.Models;
Expand Down
2 changes: 1 addition & 1 deletion src/framework/Framework.Async/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Cors/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.DBAccess/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.IO/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Linq/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Logging/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Models/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Seeding/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 0 additions & 2 deletions src/framework/Framework.Seeding/Framework.Seeding.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />

<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down

This file was deleted.

3 changes: 1 addition & 2 deletions src/framework/Framework.Seeding/SeederHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

using Microsoft.Extensions.Logging;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Seeding.JsonHelper;
using System.Collections.Concurrent;
using System.Reflection;
using System.Text.Json;
Expand All @@ -31,7 +30,7 @@ public static class SeederHelper
{
private static readonly JsonSerializerOptions Options = new()
{
PropertyNamingPolicy = new SnakeCaseNamingPolicy(),
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
Converters = { new JsonDateTimeOffsetConverter() }
};

Expand Down
2 changes: 1 addition & 1 deletion src/framework/Framework.Swagger/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Token/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Web/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
1 change: 0 additions & 1 deletion src/framework/Framework.Web/Framework.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Flurl.Signed" Version="3.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Enrichers.CorrelationId" Version="3.0.1" />
Expand Down
8 changes: 2 additions & 6 deletions src/framework/Framework.Web/WebApplicationBuildRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Flurl.Util;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
Expand Down Expand Up @@ -64,11 +63,8 @@ public static async Task BuildAndRunWebApplicationAsync<TProgram>(
if (healthCheckPaths != null)
{
configuration
.Filter.ByExcluding(le =>
{
return le.Properties.TryGetValue("RequestPath", out var logProperty) &&
logProperty.ToKeyValuePairs().Any(x => healthCheckPaths.Contains(x.Value));
});
.Filter.ByExcluding(le => le.Properties.TryGetValue("RequestPath", out var logProperty) &&
healthCheckPaths.Contains(logProperty.ToString()));
}
});
builder.Services
Expand Down
35 changes: 19 additions & 16 deletions src/keycloak/Keycloak.ErrorHandling/FlurlErrorHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,34 @@ public static class FlurlErrorHandler
{
public static void ConfigureErrorHandler(ILogger logger)
{
FlurlHttp.Configure(settings => settings.OnError = (call) =>
FlurlHttp.Clients.WithDefaults(c => c.OnError(call =>
{
var message = $"{call.HttpResponseMessage?.ReasonPhrase ?? "ReasonPhrase is null"}: {call.HttpRequestMessage.RequestUri}";
if (logger.IsEnabled(LogLevel.Debug))
{
LogDebug(logger, call);
}
if (call.HttpResponseMessage != null)
if (call.HttpResponseMessage is null)
{
throw new ServiceException(message, call.Exception);
}
var errorContent = JsonSerializer.Deserialize<KeycloakErrorResponse>(call.HttpResponseMessage.Content.ReadAsStream())?.ErrorMessage;
if (!string.IsNullOrWhiteSpace(errorContent))
{
var errorContent = JsonSerializer.Deserialize<KeycloakErrorResponse>(call.HttpResponseMessage.Content.ReadAsStream())?.ErrorMessage;
if (!string.IsNullOrWhiteSpace(errorContent))
{
message = errorContent;
}
throw call.HttpResponseMessage.StatusCode switch
{
HttpStatusCode.NotFound => new KeycloakEntityNotFoundException(message, call.Exception),
HttpStatusCode.Conflict => new KeycloakEntityConflictException(message, call.Exception),
HttpStatusCode.BadRequest => new KeycloakNoSuccessException(message, call.Exception),
_ => new ServiceException(message, call.Exception, call.HttpResponseMessage.StatusCode),
};
message = errorContent;
}
throw new ServiceException(message, call.Exception);
});
throw call.HttpResponseMessage.StatusCode switch
{
HttpStatusCode.NotFound => new KeycloakEntityNotFoundException(message, call.Exception),
HttpStatusCode.Conflict => new KeycloakEntityConflictException(message, call.Exception),
HttpStatusCode.BadRequest => new KeycloakNoSuccessException(message, call.Exception),
_ => new ServiceException(message, call.Exception, call.HttpResponseMessage.StatusCode),
};
}));
}

private static void LogDebug(ILogger logger, FlurlCall call)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
********************************************************************************/

using Flurl.Http;
using Flurl.Http.Configuration;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;

namespace Org.Eclipse.TractusX.Portal.Backend.Keycloak.ErrorHandling;

Expand All @@ -30,25 +28,9 @@ public static void ConfigureExceptions(IEnumerable<string> urlsToTrust)
{
foreach (var urlToTrust in urlsToTrust)
{
FlurlHttp.ConfigureClient(urlToTrust, cli => cli.Settings.HttpClientFactory = new UntrustedCertHttpClientFactory());
FlurlHttp
.ConfigureClientForUrl(urlToTrust)
.ConfigureInnerHandler(chc => chc.ServerCertificateCustomValidationCallback = (_, _, _, _) => true);
}
}
}

public class UntrustedCertHttpClientFactory : DefaultHttpClientFactory
{
public override HttpMessageHandler CreateMessageHandler()
{
var handler = base.CreateMessageHandler();
var httpClientHander = handler as HttpClientHandler;
if (httpClientHander != null)
{
httpClientHander.ServerCertificateCustomValidationCallback = (_, _, _, _) => true;
}
else
{
throw new ConfigurationException($"flurl HttpMessageHandler's type is not HttpClientHandler but {handler.GetType()}");
}
return handler;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Flurl.Http.Signed" Version="3.2.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Flurl.Http.Signed" Version="4.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
</ItemGroup>

Expand Down
Loading

0 comments on commit 2e1367f

Please sign in to comment.