diff --git a/src/NuGet.Core/NuGet.Packaging/Properties/AssemblyInfo.cs b/src/NuGet.Core/NuGet.Packaging/Properties/AssemblyInfo.cs index b87cf8c32bf..aae643165c3 100644 --- a/src/NuGet.Core/NuGet.Packaging/Properties/AssemblyInfo.cs +++ b/src/NuGet.Core/NuGet.Packaging/Properties/AssemblyInfo.cs @@ -11,9 +11,11 @@ [assembly: InternalsVisibleTo("NuGet.Packaging.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] [assembly: InternalsVisibleTo("NuGet.Commands.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo("Test.Utility, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] #else [assembly: InternalsVisibleTo("NuGet.Packaging.Test")] [assembly: InternalsVisibleTo("NuGet.Packaging.FuncTest")] [assembly: InternalsVisibleTo("NuGet.Commands.Test")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] +[assembly: InternalsVisibleTo("Test.Utility")] #endif diff --git a/test/NuGet.Core.FuncTests/NuGet.Packaging.FuncTest/SigningTests/TimestampTests.cs b/test/NuGet.Core.FuncTests/NuGet.Packaging.FuncTest/SigningTests/TimestampTests.cs index 4f525a002bf..d4ce0a98981 100644 --- a/test/NuGet.Core.FuncTests/NuGet.Packaging.FuncTest/SigningTests/TimestampTests.cs +++ b/test/NuGet.Core.FuncTests/NuGet.Packaging.FuncTest/SigningTests/TimestampTests.cs @@ -81,17 +81,17 @@ public async Task Timestamp_Verify_WithOfflineRevocation_ReturnsCorrectFlagsAndL result.HasFlag(SignatureVerificationStatusFlags.UnknownRevocation).Should().BeTrue(); var errors = logs.Where(l => l.Level == LogLevel.Error); - errors.Count().Should().Be(RuntimeEnvironmentHelper.IsWindows ? 2 : 1); - if (RuntimeEnvironmentHelper.IsWindows) + if (RuntimeEnvironmentHelper.IsMacOSX) { - errors.Should().Contain(w => w.Code == NuGetLogCode.NU3028 && w.Message.Contains("The revocation function was unable to check revocation because the revocation server could not be reached.")); - errors.Should().Contain(w => w.Code == NuGetLogCode.NU3028 && w.Message.Contains("The revocation function was unable to check revocation for the certificate.")); + errors.Count().Should().Be(1); } else { - errors.Should().Contain(w => w.Code == NuGetLogCode.NU3028 && w.Message.Contains("unable to get certificate CRL")); + errors.Count().Should().Be(2); + SigningTestUtility.AssertOfflineRevocationOnlineMode(errors, LogLevel.Error, NuGetLogCode.NU3028); } + SigningTestUtility.AssertRevocationStatusUnknown(errors, LogLevel.Error, NuGetLogCode.NU3028); } } } diff --git a/test/TestUtilities/Test.Utility/Signing/SigningTestUtility.cs b/test/TestUtilities/Test.Utility/Signing/SigningTestUtility.cs index 7f5aeaa0b7c..2e6a23fb268 100644 --- a/test/TestUtilities/Test.Utility/Signing/SigningTestUtility.cs +++ b/test/TestUtilities/Test.Utility/Signing/SigningTestUtility.cs @@ -678,19 +678,29 @@ public static void AssertOfflineRevocation(IEnumerable issues, LogL //We will change the original X509ChainStatus.StatusInformation of OfflineRevocation to VerifyCertTrustOfflineWhileRevocationModeOffline or VerifyCertTrustOfflineWhileRevocationModeOnline in Signature.cs and Timestamp.cs //So if we use APIs above to verify the results of chain.build, we should use assert AssertOfflineRevocationOnlineMode and AssertOfflineRevocationOfflineMode public static void AssertOfflineRevocationOnlineMode(IEnumerable issues, LogLevel logLevel) + { + AssertOfflineRevocationOnlineMode(issues, logLevel, NuGetLogCode.NU3018); + } + + public static void AssertOfflineRevocationOnlineMode(IEnumerable issues, LogLevel logLevel, NuGetLogCode code) { Assert.Contains(issues, issue => - issue.Code == NuGetLogCode.NU3018 && + issue.Code == code && issue.Level == logLevel && - issue.Message.Contains("The revocation function was unable to check revocation because the revocation server could not be reached. For more information, visit https://aka.ms/certificateRevocationMode.")); + issue.Message.Contains(NuGet.Packaging.Strings.VerifyCertTrustOfflineWhileRevocationModeOnline)); } public static void AssertOfflineRevocationOfflineMode(IEnumerable issues) + { + AssertOfflineRevocationOfflineMode(issues, LogLevel.Information, NuGetLogCode.Undefined); + } + + public static void AssertOfflineRevocationOfflineMode(IEnumerable issues, LogLevel logLevel, NuGetLogCode code) { Assert.Contains(issues, issue => - issue.Code == NuGetLogCode.Undefined && - issue.Level == LogLevel.Information && - issue.Message.Contains("The revocation function was unable to check revocation because the certificate is not available in the cached certificate revocation list and NUGET_CERT_REVOCATION_MODE environment variable has been set to offline. For more information, visit https://aka.ms/certificateRevocationMode.")); + issue.Code == code && + issue.Level == logLevel && + issue.Message.Contains(NuGet.Packaging.Strings.VerifyCertTrustOfflineWhileRevocationModeOffline)); } public static void AssertRevocationStatusUnknown(IEnumerable issues, LogLevel logLevel)