Skip to content

Commit

Permalink
Move signed package testing utils to new package (#6100)
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkan authored Oct 17, 2024
1 parent 310f5d4 commit b8efbf3
Show file tree
Hide file tree
Showing 264 changed files with 631 additions and 556 deletions.
3 changes: 2 additions & 1 deletion NuGet-Commandline-WithTests.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"test\\NuGet.Core.Tests\\NuGet.Resolver.Test\\NuGet.Resolver.Test.csproj",
"test\\NuGet.Core.Tests\\NuGet.Shared.Tests\\NuGet.Shared.Tests.csproj",
"test\\NuGet.Core.Tests\\NuGet.Versioning.Test\\NuGet.Versioning.Test.csproj",
"test\\TestUtilities\\Microsoft.Internal.NuGet.Testing.SignedPackages\\Microsoft.Internal.NuGet.Testing.SignedPackages.csproj",
"test\\TestUtilities\\Test.Utility\\Test.Utility.csproj"
]
}
}
}
1 change: 1 addition & 0 deletions NuGet-UnitTests.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"test\\TestExtensions\\SampleCommandLineExtensions\\SampleCommandLineExtensions.csproj",
"test\\TestExtensions\\TestablePluginCredentialProvider\\TestableCredentialProvider.csproj",
"test\\TestExtensions\\TestablePlugin\\TestablePlugin.csproj",
"test\\TestUtilities\\Microsoft.Internal.NuGet.Testing.SignedPackages\\Microsoft.Internal.NuGet.Testing.SignedPackages.csproj",
"test\\TestUtilities\\Test.Utility\\Test.Utility.csproj"
]
}
Expand Down
7 changes: 7 additions & 0 deletions NuGet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ensure-nupkg-dependencies-o
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuGet.Tests.Apex.Daily", "test\NuGet.Tests.Apex\NuGet.Tests.Apex.Daily\NuGet.Tests.Apex.Daily.csproj", "{9DD99D1D-6C9A-40BF-A650-3F14AA8B1275}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Internal.NuGet.Testing.SignedPackages", "test\TestUtilities\Microsoft.Internal.NuGet.Testing.SignedPackages\Microsoft.Internal.NuGet.Testing.SignedPackages.csproj", "{E41384AA-ED2D-4251-A571-F5C924CE2913}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -711,6 +713,10 @@ Global
{9DD99D1D-6C9A-40BF-A650-3F14AA8B1275}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DD99D1D-6C9A-40BF-A650-3F14AA8B1275}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DD99D1D-6C9A-40BF-A650-3F14AA8B1275}.Release|Any CPU.Build.0 = Release|Any CPU
{E41384AA-ED2D-4251-A571-F5C924CE2913}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E41384AA-ED2D-4251-A571-F5C924CE2913}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E41384AA-ED2D-4251-A571-F5C924CE2913}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E41384AA-ED2D-4251-A571-F5C924CE2913}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -825,6 +831,7 @@ Global
{1BCC177E-D529-4015-93E2-4C254FA015AA} = {23CEFC88-9365-4464-A517-700224ECA033}
{719AC60C-59EF-4A63-AC9E-7841DF14179D} = {CE4C7E1B-6883-49C3-A407-F807094777CC}
{9DD99D1D-6C9A-40BF-A650-3F14AA8B1275} = {3150445A-C422-4D40-B341-DE5AD063C632}
{E41384AA-ED2D-4251-A571-F5C924CE2913} = {79266117-FEDD-45B3-B603-33A4B6E9F12F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3747A66A-00D1-41B8-A9C5-ED0D7BEA9D25}
Expand Down
10 changes: 5 additions & 5 deletions build/sign.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<SignWithNuGetKey Condition="'$(SignWithMicrosoftKey)' != 'true' And '$(SignWithNuGetKey)' == ''">true</SignWithNuGetKey>
<SignWithMicrosoftKey Condition="'$(SignWithNuGetKey)' != 'true' And '$(SignWithMicrosoftKey)' == ''">true</SignWithMicrosoftKey>
</PropertyGroup>

<!-- Use Test SNK by default for all test projects -->
<PropertyGroup Condition="'$(SignWithTestKey)' == 'true'">
<AssemblyOriginatorKeyFile>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory), '..', 'keys', 'Test.snk'))</AssemblyOriginatorKeyFile>
Expand All @@ -34,11 +34,11 @@
<ItemGroup>
<!-- All InternalsVisibleTo are supposed to be tests so update them with the public key from Test.snk -->
<InternalsVisibleTo Update="@(InternalsVisibleTo)" PublicKey="0024000004800000940000000602000000240000525341310004000001000100A5276DF8650A58CB43396DC7B3D395F30A82D0D1FA98FBCFE3ABEAD5DE0B1DB6764347A0F6BF0B060A27C202CCD122DB5DED8F596CEBE2ECC3A6629015EEB96C94F6B9E8185D4ACC84C376FF6B1C3147431A4D55CB5736DB97A9E88FCC47D9193F4DB5896DC5817E5D0CBD2641726E7431990BCD2DD7FA1D28493D0CFD9DCFA4" />

<!-- DynamicProxyGenAssembly2 is the assembly generated by mocks and are signed with a known key -->
<InternalsVisibleTo Update="DynamicProxyGenAssembly2" PublicKey="0024000004800000940000000602000000240000525341310004000001000100C547CAC37ABD99C8DB225EF2F6C8A3602F3B3606CC9891605D02BAA56104F4CFC0734AA39B93BF7852F7D9266654753CC297E7D2EDFE0BAC1CDCF9F717241550E0A7B191195B7667BB4F64BCB8E2121380FD1D9D46AD2D92D2D15605093924CCEAF74C4861EFF62ABF69B9291ED0A340E113BE11E6A7D3113E92484CF7045CC7" />
<!-- Test.Utility is shipped so is singed with the NuGet key -->
<InternalsVisibleTo Update="Test.Utility" PublicKey="002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293" />

<!-- Microsoft.Internal.NuGet.Testing.SignedPackages is shipped (to a dotnet feed, not to nuget.org) so is singed with the NuGet key -->
<InternalsVisibleTo Update="Microsoft.Internal.NuGet.Testing.SignedPackages" PublicKey="002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293" />
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions eng/pipelines/templates/Build_and_UnitTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ steps:
configuration: "$(BuildConfiguration)"
msbuildArguments: "/restore:false /target:Pack /property:BuildRTM=$(BuildRTM) /property:ExcludeTestProjects=$(BuildRTM) /property:BuildNumber=$(BuildNumber) /binarylogger:$(Build.StagingDirectory)\\binlog\\10.Pack.binlog /property:MicroBuild_SigningEnabled=false"

- task: PowerShell@1
displayName: "Check expected packages exist for publishing"
name: "EnsureAllPackagesExist"
inputs:
scriptName: "$(Build.Repository.LocalPath)\\scripts\\utils\\EnsureAllPackagesExist.ps1"
arguments: "-BuildRTM:$$(BuildRTM) -NupkgOutputPath '$(Build.Repository.LocalPath)\\artifacts\\$(NupkgOutputDir)'"

- task: MSBuild@1
displayName: "Ensure all Nupkgs and Symbols are created"
inputs:
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/EnsureAllPackagesExist.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Param (

if (!$BuildRTM)
{
$PackageIDListShouldExist.Add("Test.Utility")
$PackageIDListShouldExist.Add("Microsoft.Internal.NuGet.Testing.SignedPackages")
$PackageIDListShouldExist.Add("NuGet.Localization")
}

Expand Down
2 changes: 1 addition & 1 deletion src/NuGet.Core/NuGet.Packaging/NuGet.Packaging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@
<InternalsVisibleTo Include="NuGet.Commands.Test" />
<InternalsVisibleTo Include="NuGet.Packaging.FuncTest" />
<InternalsVisibleTo Include="NuGet.Packaging.Test" />
<InternalsVisibleTo Include="Test.Utility" />
<InternalsVisibleTo Include="Microsoft.Internal.NuGet.Testing.SignedPackages" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using NuGet.Common;
using NuGet.Frameworks;
using NuGet.Packaging;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NuGet.Test.Utility;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;

namespace NuGet.CommandLine.Test.Caching
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using NuGet.Common;
using NuGet.Test.Utility;

namespace NuGet.CommandLine.Test.Caching
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;
using NuGet.Test.Utility;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;

namespace NuGet.CommandLine.Test.Caching
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using NuGet.Test.Utility;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;

namespace NuGet.CommandLine.Test.Caching
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;
using NuGet.Test.Utility;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;

namespace NuGet.CommandLine.Test.Caching
{
Expand All @@ -20,7 +20,7 @@ public interface ICachingTest
/// <summary>
/// Iteration count. How many times should the same commmand be executed.
/// </summary>
///
///
int IterationCount { get; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;
using NuGet.Test.Utility;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;

namespace NuGet.CommandLine.Test.Caching
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;
using NuGet.Test.Utility;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;

namespace NuGet.CommandLine.Test.Caching
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;
using NuGet.Test.Utility;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;

namespace NuGet.CommandLine.Test.Caching
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;
using NuGet.Test.Utility;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;

namespace NuGet.CommandLine.Test.Caching
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;
using NuGet.Test.Utility;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;

namespace NuGet.CommandLine.Test.Caching
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;
using NuGet.Test.Utility;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;

namespace NuGet.CommandLine.Test.Caching
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Text;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using NuGet.Common;
using NuGet.Test.Utility;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Internal.NuGet.Testing.SignedPackages;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using NuGet.Test.Utility;
using Test.Utility.Signing;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Net;
using System.Threading;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using NuGet.CommandLine.Test;
using NuGet.Configuration;
using NuGet.Test.Utility;
Expand Down Expand Up @@ -298,7 +299,7 @@ public void PushCommand_Server_Snupkg_ByFilename_DoesNotExist_FileNotFoundError(
}

/// <summary>
/// When pushing a snupkg wildcard where no matching files exist, show a File Not Found error.
/// When pushing a snupkg wildcard where no matching files exist, show a File Not Found error.
/// </summary>
[Fact]
public void PushCommand_Server_Snupkg_ByWildcard_FindsNothing_FileNotFoundError()
Expand Down Expand Up @@ -333,7 +334,7 @@ public void PushCommand_Server_Snupkg_ByWildcard_FindsNothing_FileNotFoundError(
}

/// <summary>
/// When pushing a nupkg by filename where no matching files exist, show a File Not Found error.
/// When pushing a nupkg by filename where no matching files exist, show a File Not Found error.
/// </summary>
[Fact]
public void PushCommand_Server_Nupkg_ByFilename_FindsNothing_FileNotFoundError()
Expand Down Expand Up @@ -368,7 +369,7 @@ public void PushCommand_Server_Nupkg_ByFilename_FindsNothing_FileNotFoundError()
}

/// <summary>
/// When pushing a nupkg by wildcard where no matching files exist, show a File Not Found error.
/// When pushing a nupkg by wildcard where no matching files exist, show a File Not Found error.
/// </summary>
[Fact]
public void PushCommand_Server_Nupkg_ByWildcard_FindsNothing_FileNotFoundError()
Expand Down Expand Up @@ -403,7 +404,7 @@ public void PushCommand_Server_Nupkg_ByWildcard_FindsNothing_FileNotFoundError()
}

/// <summary>
/// When pushing a nupkg by filename to a Symbol Server with no matching snupkg, do not show a File Not Found error.
/// When pushing a nupkg by filename to a Symbol Server with no matching snupkg, do not show a File Not Found error.
/// </summary>
[Fact]
public void PushCommand_Server_Nupkg_ByFilename_SnupkgDoesNotExist_NoFileNotFoundError()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using System.Text;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Internal.NuGet.Testing.SignedPackages;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using NuGet.Common;
using NuGet.Frameworks;
using NuGet.Packaging.Signing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using NuGet.CommandLine.Test;
using NuGet.Common;
using NuGet.Configuration.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using NuGet.CommandLine.Test;
using NuGet.Configuration;
using NuGet.Test.Utility;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Test.Utility.Signing;
using Microsoft.Internal.NuGet.Testing.SignedPackages;
using Xunit;

namespace NuGet.CommandLine.FuncTest.Commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Microsoft.Internal.NuGet.Testing.SignedPackages;
using NuGet.CommandLine.Test;
using NuGet.Packaging.Signing;
using NuGet.Test.Utility;
using Test.Utility;
using Test.Utility.Signing;

namespace NuGet.CommandLine.FuncTest.Commands
{
using X509StorePurpose = global::Test.Utility.Signing.X509StorePurpose;
using X509StorePurpose = Microsoft.Internal.NuGet.Testing.SignedPackages.X509StorePurpose;

/// <summary>
/// Used to bootstrap functional tests for signing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Internal.NuGet.Testing.SignedPackages;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using NuGet.Common;
using NuGet.Packaging.Signing;
using NuGet.Test.Utility;
using Test.Utility.Signing;
using Xunit;
using Xunit.Abstractions;
using HashAlgorithmName = NuGet.Common.HashAlgorithmName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Internal.NuGet.Testing.SignedPackages;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using Moq;
using NuGet.CommandLine.Commands;
using NuGet.CommandLine.Test;
Expand Down Expand Up @@ -136,7 +138,7 @@ public async Task TrustedSignersCommand_SendsArgumentsCorrectlyToCommandRunnerAs
[InlineData("notSupportedAction")]
public void TrustedSignersCommand_Failure_InvalidArguments_HelpMessage(string args)
{
// Arrange & Act
// Arrange & Act
var result = CommandRunner.Run(
_nugetExePath,
Directory.GetCurrentDirectory(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Internal.NuGet.Testing.SignedPackages;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using NuGet.Common;
using NuGet.Test.Utility;
using Test.Utility.Signing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using FluentAssertions;
using NuGet.Test.Utility;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using Xunit;
using Xunit.Abstractions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
using System.Security.Cryptography;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Internal.NuGet.Testing.SignedPackages;
using Microsoft.Internal.NuGet.Testing.SignedPackages.ChildProcess;
using Moq;
using NuGet.CommandLine;
using NuGet.Common;
using NuGet.Packaging.Signing;
using NuGet.Test.Utility;
using Test.Utility.Signing;
using Xunit;

namespace NuGet.MSSigning.Extensions.FuncTest.Commands
Expand Down
Loading

0 comments on commit b8efbf3

Please sign in to comment.