From d5b47cbcc65b03047f2adce5aeebce0737cb815a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Mon, 18 Nov 2024 04:22:00 -0700 Subject: [PATCH] [Resources.AWS] Execute tests against .NET9 (#2328) --- build/Common.nonprod.props | 1 - .../Http/ServerCertificateValidationProviderTests.cs | 11 ++++++++++- .../OpenTelemetry.Resources.AWS.Tests.csproj | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/build/Common.nonprod.props b/build/Common.nonprod.props index 8e50abe1da..54d1acd980 100644 --- a/build/Common.nonprod.props +++ b/build/Common.nonprod.props @@ -31,7 +31,6 @@ $(OpenTelemetryCoreLatestVersion) net9.0;net8.0 - net8.0 [2.8.2,3.0) [2.9.0,3.0) [1.6.3,2.0) diff --git a/test/OpenTelemetry.Resources.AWS.Tests/Http/ServerCertificateValidationProviderTests.cs b/test/OpenTelemetry.Resources.AWS.Tests/Http/ServerCertificateValidationProviderTests.cs index c3164353be..7151659be8 100644 --- a/test/OpenTelemetry.Resources.AWS.Tests/Http/ServerCertificateValidationProviderTests.cs +++ b/test/OpenTelemetry.Resources.AWS.Tests/Http/ServerCertificateValidationProviderTests.cs @@ -23,7 +23,11 @@ public void TestValidCertificate() Assert.NotNull(serverCertificateValidationProvider); +#if NET9_0_OR_GREATER + var certificate = X509CertificateLoader.LoadCertificateFromFile(certificateUploader.FilePath); +#else var certificate = new X509Certificate2(certificateUploader.FilePath); +#endif X509Chain chain = new X509Chain(); chain.Build(certificate); @@ -65,7 +69,12 @@ public void TestCallbackWithNullChain() ServerCertificateValidationProvider.FromCertificateFile(certificateUploader.FilePath, NoopServerCertificateValidationEventSource.Instance); Assert.NotNull(serverCertificateValidationProvider); - Assert.False(serverCertificateValidationProvider.ValidationCallback(this, new X509Certificate2(certificateUploader.FilePath), null, default)); +#if NET9_0_OR_GREATER + var certificate = X509CertificateLoader.LoadCertificateFromFile(certificateUploader.FilePath); +#else + var certificate = new X509Certificate2(certificateUploader.FilePath); +#endif + Assert.False(serverCertificateValidationProvider.ValidationCallback(this, certificate, null, default)); } } diff --git a/test/OpenTelemetry.Resources.AWS.Tests/OpenTelemetry.Resources.AWS.Tests.csproj b/test/OpenTelemetry.Resources.AWS.Tests/OpenTelemetry.Resources.AWS.Tests.csproj index dc0a10ebc8..8e2510fc3b 100644 --- a/test/OpenTelemetry.Resources.AWS.Tests/OpenTelemetry.Resources.AWS.Tests.csproj +++ b/test/OpenTelemetry.Resources.AWS.Tests/OpenTelemetry.Resources.AWS.Tests.csproj @@ -2,7 +2,7 @@ - $(SupportedNetTargetsWithoutNet9) + $(SupportedNetTargets) $(TargetFrameworks);$(NetFrameworkMinimumSupportedVersion) Unit test project for AWS Detector for OpenTelemetry.