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 authored and ntruchsess committed Oct 15, 2024
1 parent 1244fd9 commit 67f60c8
Show file tree
Hide file tree
Showing 237 changed files with 1,687 additions and 2,332 deletions.
17 changes: 8 additions & 9 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
nuget/nuget/-/AutoFixture.AutoFakeItEasy/4.18.1, MIT, approved, #10064
nuget/nuget/-/AutoFixture.Xunit/4.18.1, MIT, approved, #10082
nuget/nuget/-/AutoFixture/4.18.1, MIT, approved, #10057
nuget/nuget/-/BouncyCastle.Cryptography/2.2.1, MIT AND Apache-2.0 AND BSD-3-Clause AND LicenseRef-Permission-Notice, approved, #10066
nuget/nuget/-/BouncyCastle.Cryptography/2.4.0, MIT AND Apache-2.0 AND BSD-3-Clause AND LicenseRef-scancode-ietf-trust, approved, #15706
nuget/nuget/-/Castle.Core/5.1.1, Apache-2.0, approved, #13966
nuget/nuget/-/EFCore.NamingConventions/8.0.3, Apache-2.0, approved, #13983
nuget/nuget/-/FakeItEasy/8.3.0, MIT, approved, #16328
nuget/nuget/-/Fare/2.1.1, MIT, approved, clearlydefined
nuget/nuget/-/FluentAssertions/6.12.1, MIT AND Apache-2.0 AND BSD-3-Clause AND CC-BY-3.0-US AND (GPL-2.0-only OR MIT) AND OFL-1.1 AND WTFPL, approved, #13976
nuget/nuget/-/Flurl.Http.Signed/3.2.4, MIT, approved, #3503
nuget/nuget/-/Flurl.Signed/3.0.6, MIT, approved, #3501
nuget/nuget/-/HtmlAgilityPack/1.11.59, MIT, approved, #9293
nuget/nuget/-/Flurl.Http.Signed/4.0.2, MIT, approved, #16447
nuget/nuget/-/Flurl.Signed/4.0.0, MIT, approved, #16448
nuget/nuget/-/HtmlAgilityPack/1.11.63, MIT, approved, #9293
nuget/nuget/-/Humanizer.Core/2.14.1, MIT, approved, #10060
nuget/nuget/-/Json.More.Net/2.0.0, MIT AND OFL-1.1 AND CC-BY-SA-4.0, approved, #15173
nuget/nuget/-/JsonPointer.Net/4.0.0, MIT, approved, clearlydefined
Expand All @@ -21,8 +20,9 @@ nuget/nuget/-/MailKit/4.3.0, MIT AND LicenseRef-scancode-ietf AND LicenseRef-sca
nuget/nuget/-/MimeKit/4.7.1, MIT AND FSFULLRWD AND LicenseRef-scancode-ietf AND LicenseRef-scancode-ietf-trust AND (BSD-3-Clause AND LicenseRef-scancode-ietf-trust) AND BSD-3-Clause AND MS-PL AND CC-BY-SA-4.0 AND LicenseRef-MIT-style AND CC-PDDC AND GPL-2.0-only, approved, #15705
nuget/nuget/-/Mono.TextTemplating/2.2.1, MIT, approved, #15073
nuget/nuget/-/NHamcrest/3.4.0, MIT, approved, #13964
nuget/nuget/-/NJsonSchema/10.9.0, MIT, approved, #9300
nuget/nuget/-/Namotion.Reflection/2.1.2, MIT, approved, #9320
nuget/nuget/-/NJsonSchema.Annotations/11.0.2, MIT, approved, #15638
nuget/nuget/-/NJsonSchema/11.0.2, MIT, approved, #15632
nuget/nuget/-/Namotion.Reflection/3.1.1, MIT, approved, #15634
nuget/nuget/-/Newtonsoft.Json/13.0.1, MIT AND BSD-3-Clause, approved, #3266
nuget/nuget/-/Newtonsoft.Json/13.0.3, MIT AND BSD-3-Clause, approved, #3266
nuget/nuget/-/Npgsql.EntityFrameworkCore.PostgreSQL/8.0.4, PostgreSQL AND MIT, approved, #13972
Expand All @@ -31,7 +31,7 @@ nuget/nuget/-/PasswordGenerator/2.1.0, MIT, approved, #3192
nuget/nuget/-/ReportPortal.Client/3.4.0, Apache-2.0, approved, #9298
nuget/nuget/-/ReportPortal.Shared/3.6.0, Apache-2.0, approved, #10587
nuget/nuget/-/ReportPortal.XUnit/2.5.0, Apache-2.0, approved, #10588
nuget/nuget/-/RestAssured.Net/4.2.1, Apache-2.0, approved, #13961
nuget/nuget/-/RestAssured.Net/4.3.1, Apache-2.0, approved, #16238
nuget/nuget/-/SSH.NET/2023.0.0, MIT AND (MIT AND MS-PL) AND ISC, approved, #13965
nuget/nuget/-/Serilog.AspNetCore/8.0.1, Apache-2.0 AND MIT, approved, #13967
nuget/nuget/-/Serilog.Enrichers.CorrelationId/3.0.1, MIT, approved, clearlydefined
Expand All @@ -56,9 +56,8 @@ nuget/nuget/-/Swashbuckle.AspNetCore.Swagger/6.8.0, MIT AND Apache-2.0, approved
nuget/nuget/-/Swashbuckle.AspNetCore.SwaggerGen/6.8.0, MIT AND Apache-2.0, approved, #16259
nuget/nuget/-/Swashbuckle.AspNetCore.SwaggerUI/6.8.0, MIT AND Apache-2.0, approved, #16261
nuget/nuget/-/Swashbuckle.AspNetCore/6.8.0, MIT AND Apache-2.0, approved, #16260
nuget/nuget/-/Testcontainers.PostgreSql/3.7.0, MIT, approved, #13960
nuget/nuget/-/Testcontainers.PostgreSql/3.10.0, MIT, approved, #16241
nuget/nuget/-/Testcontainers/3.10.0, MIT, approved, #16236
nuget/nuget/-/Testcontainers/3.7.0, MIT, approved, #13982
nuget/nuget/-/Xunit.Extensions.AssemblyFixture/2.4.1, MIT, approved, #3502
nuget/nuget/-/coverlet.collector/6.0.0, MIT, approved, #10075
nuget/nuget/-/coverlet.collector/6.0.2, MIT, approved, #10075
Expand Down
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: 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.2" />
<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
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.10" />
<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.2" />
</ItemGroup>

Expand Down
27 changes: 3 additions & 24 deletions src/keycloak/Keycloak.Factory/KeycloakFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,16 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Flurl.Http.Configuration;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Library;

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

public class KeycloakFactory : IKeycloakFactory
public class KeycloakFactory(IOptions<KeycloakSettingsMap> options)
: IKeycloakFactory
{
private readonly KeycloakSettingsMap _settings;

private static readonly JsonSerializerSettings SerializerSettings = new()
{
NullValueHandling = NullValueHandling.Ignore,
ContractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy
{
ProcessDictionaryKeys = false
}
}
};

public KeycloakFactory(IOptions<KeycloakSettingsMap> settings)
{
_settings = settings.Value;
}
private readonly KeycloakSettingsMap _settings = options.Value;

public KeycloakClient CreateKeycloakClient(string instance)
{
Expand All @@ -59,7 +40,6 @@ public KeycloakClient CreateKeycloakClient(string instance)
var keycloakClient = settings.ClientSecret == null
? new KeycloakClient(settings.ConnectionString, settings.User, settings.Password, settings.AuthRealm, settings.UseAuthTrail)
: KeycloakClient.CreateWithClientId(settings.ConnectionString, settings.ClientId, settings.ClientSecret, settings.UseAuthTrail, settings.AuthRealm);
keycloakClient.SetSerializer(new NewtonsoftJsonSerializer(SerializerSettings));

return keycloakClient;
}
Expand All @@ -73,7 +53,6 @@ public KeycloakClient CreateKeycloakClient(string instance, string clientId, str

var settings = _settings.Single(x => x.Key.Equals(instance, StringComparison.InvariantCultureIgnoreCase)).Value;
var keycloakClient = KeycloakClient.CreateWithClientId(settings.ConnectionString, clientId, secret, settings.UseAuthTrail, settings.AuthRealm);
keycloakClient.SetSerializer(new NewtonsoftJsonSerializer(SerializerSettings));

return keycloakClient;
}
Expand Down
Loading

0 comments on commit 67f60c8

Please sign in to comment.