public async Task DowngradeSignedToUnsignedVersionFromPMCForPC_SucceedAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); // This test is not considered an ideal behavior of the product but states the current behavior. // A package that is already installed as signed should be specailly treated and a user should not be // able to downgrade to an unsigned version. This test needs to be updated once this behavior gets // corrected in the product. var packageVersion09 = "0.9.0"; var signedPackage = _fixture.AuthorSignedTestPackage; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { await CommonUtility.CreatePackageInSourceAsync(testContext.PackageSource, signedPackage.Id, packageVersion09); await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, signedPackage); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(signedPackage.Id, signedPackage.Version); nugetConsole.UpdatePackageFromPMC(signedPackage.Id, packageVersion09); CommonUtility.AssetPackageInPackagesConfig(VisualStudio, testContext.Project, signedPackage.Id, packageVersion09, XunitLogger); } }
public async Task DowngradePackageFromPMCForPRAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var packageName = "TestPackage"; var packageVersion1 = "1.0.0"; var packageVersion2 = "2.0.0"; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { await Utils.CreatePackageInSourceAsync(testContext.PackageSource, packageName, packageVersion1); await Utils.CreatePackageInSourceAsync(testContext.PackageSource, packageName, packageVersion2); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(packageName, packageVersion2); testContext.Project.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); nugetConsole.UpdatePackageFromPMC(packageName, packageVersion1); testContext.Project.Build(); Utils.AssertPackageReferenceExists(VisualStudio, testContext.Project, packageName, packageVersion1, XunitLogger); Utils.AssertPackageInAssetsFile(VisualStudio, testContext.Project, packageName, packageVersion1, XunitLogger); } }
public async Task WithExpiredCertificate_InstallFromPMCForPC_WarnAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) using (var trustedExpiringTestCert = SigningTestUtility.GenerateTrustedTestCertificateThatExpiresIn10Seconds()) { XunitLogger.LogInformation("Creating package"); var package = CommonUtility.CreatePackage("ExpiredTestPackage", "1.0.0"); XunitLogger.LogInformation("Signing package"); var expiredTestPackage = CommonUtility.AuthorSignPackage(package, trustedExpiringTestCert.Source.Cert); await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, expiredTestPackage); XunitLogger.LogInformation("Waiting for package to expire"); SigningUtility.WaitForCertificateToExpire(trustedExpiringTestCert.Source.Cert); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(expiredTestPackage.Id, expiredTestPackage.Version); // TODO: Fix bug where no warnings are shown when package is untrusted but still installed //nugetConsole.IsMessageFoundInPMC("expired certificate").Should().BeTrue("expired certificate warning"); CommonUtility.AssetPackageInPackagesConfig(VisualStudio, testContext.Project, expiredTestPackage.Id, expiredTestPackage.Version, XunitLogger); } }
public void UpdateUnsignedPackageToSignedVersionFromPMCForPR(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var packageVersion09 = "0.9.0"; var signedPackage = _fixture.SignedTestPackage; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { Utils.CreatePackageInSource(testContext.PackageSource, signedPackage.Id, packageVersion09); SimpleTestPackageUtility.CreatePackages(testContext.PackageSource, signedPackage); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(signedPackage.Id, packageVersion09); testContext.Project.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); nugetConsole.UpdatePackageFromPMC(signedPackage.Id, signedPackage.Version); testContext.Project.Build(); Utils.AssertPackageReferenceExists(VisualStudio, testContext.Project, signedPackage.Id, signedPackage.Version, XunitLogger); } }
public void UpdateUnsignedPackageToSignedVersionFromPMC(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var packageVersion09 = "0.9.0"; var signedPackage = _fixture.SignedTestPackage; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate)) { Utils.CreatePackageInSource(testContext.PackageSource, signedPackage.Id, packageVersion09); SimpleTestPackageUtility.CreatePackages(testContext.PackageSource, signedPackage); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(signedPackage.Id, packageVersion09); testContext.Project.Build(); Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, signedPackage.Id, packageVersion09); nugetConsole.UpdatePackageFromPMC(signedPackage.Id, signedPackage.Version); testContext.Project.Build(); Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, signedPackage.Id, signedPackage.Version); Utils.AssertPackageIsNotInstalled(GetNuGetTestService(), testContext.Project, signedPackage.Id, packageVersion09); } }
public void UpdatePackageFromPMC(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate)) { var packageName = "TestPackage"; var packageVersion1 = "1.0.0"; var packageVersion2 = "2.0.0"; Utils.CreatePackageInSource(testContext.PackageSource, packageName, packageVersion1); Utils.CreatePackageInSource(testContext.PackageSource, packageName, packageVersion2); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(packageName, packageVersion1); testContext.Project.Build(); Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, packageName, packageVersion1); nugetConsole.UpdatePackageFromPMC(packageName, packageVersion2); testContext.Project.Build(); Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, packageName, packageVersion2); } }
public void UninstallMultiplePackagesFromPMCForPR(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var packageName1 = "TestPackage1"; var packageVersion1 = "1.0.0"; var packageName2 = "TestPackage2"; var packageVersion2 = "1.2.3"; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { Utils.CreatePackageInSource(testContext.PackageSource, packageName1, packageVersion1); Utils.CreatePackageInSource(testContext.PackageSource, packageName2, packageVersion2); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(packageName1, packageVersion1); testContext.Project.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); nugetConsole.InstallPackageFromPMC(packageName2, packageVersion2); testContext.Project.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); nugetConsole.UninstallPackageFromPMC(packageName1); nugetConsole.UninstallPackageFromPMC(packageName2); testContext.Project.Build(); Utils.AssertPackageReferenceDoesNotExist(VisualStudio, testContext.Project, packageName1, packageVersion1, XunitLogger); Utils.AssertPackageReferenceDoesNotExist(VisualStudio, testContext.Project, packageName2, packageVersion2, XunitLogger); Utils.AssertPackageNotInAssetsFile(VisualStudio, testContext.Project, packageName1, packageVersion1, XunitLogger); Utils.AssertPackageNotInAssetsFile(VisualStudio, testContext.Project, packageName2, packageVersion2, XunitLogger); } }
public async Task AuthorSignedPackage_WithExpiredCertificate_InstallFromPMCForPR_SucceedAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); await _fixture.CreateSignedPackageWithExpiredCertificateAsync(); var signedPackagePath = _fixture.ExpiredCertSignedTestPackagePath; var signedPackage = _fixture.ExpiredCertSignedTestPackage; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { File.Copy(signedPackagePath, Path.Combine(testContext.PackageSource, signedPackage.PackageName)); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(signedPackage.Id, signedPackage.Version); testContext.Project.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); // TODO: Fix bug where no warnings are shwon when package is untrusted but still installed //nugetConsole.IsMessageFoundInPMC("expired certificate").Should().BeTrue("expired certificate warning"); Utils.AssertPackageReferenceExists(VisualStudio, testContext.Project, signedPackage.Id, signedPackage.Version, XunitLogger); } }
public async Task WithExpiredAuthorCertificate_ExpiredRepoCertificate_InstallFromPMCForPC_WarnAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) using (var trustedExpiringTestCert = SigningTestUtility.GenerateTrustedTestCertificateThatExpiresIn5Seconds()) { XunitLogger.LogInformation("Creating package"); var package = CommonUtility.CreatePackage("ExpiredTestPackage", "1.0.0"); XunitLogger.LogInformation("Signing and countersigning package"); var expiredTestPackage = CommonUtility.AuthorSignPackage(package, trustedExpiringTestCert.Source.Cert); var countersignedPackage = CommonUtility.RepositoryCountersignPackage( expiredTestPackage, trustedExpiringTestCert.Source.Cert, new Uri("https://v3serviceIndexUrl.test/api/index.json")); await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, expiredTestPackage); XunitLogger.LogInformation("Waiting for package to expire"); SigningUtility.WaitForCertificateToExpire(trustedExpiringTestCert.Source.Cert); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(expiredTestPackage.Id, expiredTestPackage.Version); testContext.Project.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); // TODO: Fix bug where no warnings are shown when package is untrusted but still installed //nugetConsole.IsMessageFoundInPMC("expired certificate").Should().BeTrue("expired certificate warning"); CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.Project, expiredTestPackage.Id, expiredTestPackage.Version, XunitLogger); } }
public async Task UpdateUnsignedToSignedVersionFromPMCForPR_SucceedAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var packageVersion09 = "0.9.0"; var signedPackage = _fixture.AuthorSignedTestPackage; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { await CommonUtility.CreatePackageInSourceAsync(testContext.PackageSource, signedPackage.Id, packageVersion09); await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, signedPackage); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(signedPackage.Id, packageVersion09); testContext.SolutionService.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); nugetConsole.UpdatePackageFromPMC(signedPackage.Id, signedPackage.Version); testContext.SolutionService.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.Project, signedPackage.Id, signedPackage.Version, XunitLogger); } }
public void DowngradeSignedPackageToUnsignedVersionFromPMC(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); // This test is not considered an ideal behavior of the product but states the current behavior. // A package that is already installed as signed should be specailly treated and a user should not be // able to downgrade to an unsigned version. This test needs to be updated once this behavior gets // corrected in the product. var packageVersion09 = "0.9.0"; var signedPackage = _fixture.SignedTestPackage; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate)) { Utils.CreatePackageInSource(testContext.PackageSource, signedPackage.Id, packageVersion09); SimpleTestPackageUtility.CreatePackages(testContext.PackageSource, signedPackage); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(signedPackage.Id, signedPackage.Version); testContext.Project.Build(); Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, signedPackage.Id, signedPackage.Version); nugetConsole.UpdatePackageFromPMC(signedPackage.Id, packageVersion09); testContext.Project.Build(); Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, signedPackage.Id, packageVersion09); Utils.AssertPackageIsNotInstalled(GetNuGetTestService(), testContext.Project, signedPackage.Id, signedPackage.Version); } }
public async Task InstallPackageForPR_PackageNamespace_WithMultipleFeedsWithIdenticalPackages_InstallsCorrectPackage(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using var simpleTestPathContext = new SimpleTestPathContext(); string solutionDirectory = simpleTestPathContext.SolutionRoot; var packageName = "Contoso.A"; var packageVersion1 = "1.0.0"; var opensourceRepositoryPath = Path.Combine(solutionDirectory, "OpensourceRepository"); Directory.CreateDirectory(opensourceRepositoryPath); await CommonUtility.CreateNetFrameworkPackageInSourceAsync(opensourceRepositoryPath, packageName, packageVersion1); var privateRepositoryPath = Path.Combine(solutionDirectory, "PrivateRepository"); Directory.CreateDirectory(privateRepositoryPath); await CommonUtility.CreateNetFrameworkPackageInSourceAsync(privateRepositoryPath, packageName, packageVersion1); //Create nuget.config with Package namespace filtering rules. CommonUtility.CreateConfigurationFile(Path.Combine(solutionDirectory, "NuGet.Config"), $@"<?xml version=""1.0"" encoding=""utf-8""?> <configuration> <packageSources> <add key=""ExternalRepository"" value=""{opensourceRepositoryPath}"" /> <add key=""PrivateRepository"" value=""{privateRepositoryPath}"" /> </packageSources> <packageSourceMapping> <packageSource key=""externalRepository""> <package pattern=""External.*"" /> <package pattern=""Others.*"" /> </packageSource> <packageSource key=""PrivateRepository""> <package pattern=""Contoso.*"" /> <package pattern=""Test.*"" /> </packageSource> <packageSource key=""nuget""> <package pattern=""Microsoft.*"" /> <package pattern=""NetStandard*"" /> </packageSource> </packageSourceMapping> </configuration>"); using var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger, noAutoRestore: false, addNetStandardFeeds: true, simpleTestPathContext: simpleTestPathContext); var nugetConsole = GetConsole(testContext.Project); // Act nugetConsole.InstallPackageFromPMC(packageName, packageVersion1); // Assert var expectedMessage = $"Installed {packageName} {packageVersion1} from {privateRepositoryPath}"; Assert.True(nugetConsole.IsMessageFoundInPMC(expectedMessage), expectedMessage); VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); Assert.True(VisualStudio.HasNoErrorsInOutputWindows()); }
public async Task WithSourceMappingEnabled_InstallPackageFromPMUIAndNoSourcesFound_Fails(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var simpleTestPathContext = new SimpleTestPathContext()) { string solutionDirectory = simpleTestPathContext.SolutionRoot; var privateRepositoryPath = Path.Combine(solutionDirectory, "PrivateRepository"); Directory.CreateDirectory(privateRepositoryPath); var externalRepositoryPath = Path.Combine(solutionDirectory, "ExternalRepository"); Directory.CreateDirectory(externalRepositoryPath); var packageName = "Contoso.a"; var packageVersion = "1.0.0"; await CommonUtility.CreatePackageInSourceAsync(externalRepositoryPath, packageName, packageVersion); // Create nuget.config with Package source mapping filtering rules before project is created. CommonUtility.CreateConfigurationFile(Path.Combine(solutionDirectory, "NuGet.Config"), $@"<?xml version=""1.0"" encoding=""utf-8""?> <configuration> <packageSources> <add key=""ExternalRepository"" value=""{externalRepositoryPath}"" /> <add key=""PrivateRepository"" value=""{privateRepositoryPath}"" /> </packageSources> <packageSourceMapping> <packageSource key=""externalRepository""> <package pattern=""External.*"" /> <package pattern=""Others.*"" /> </packageSource> <packageSource key=""PrivateRepository""> <package pattern=""contoso.*"" /> <package pattern=""Test.*"" /> </packageSource> <packageSource key=""nuget""> <package pattern=""Microsoft.*"" /> <package pattern=""NetStandard*"" /> </packageSource> </packageSourceMapping> </configuration>"); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger, addNetStandardFeeds: true, simpleTestPathContext: simpleTestPathContext)) { VisualStudio.AssertNoErrors(); // Act CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, XunitLogger); var nugetTestService = GetNuGetTestService(); var uiwindow = nugetTestService.GetUIWindowfromProject(testContext.SolutionService.Projects[0]); uiwindow.InstallPackageFromUI(packageName, packageVersion); // Assert CommonUtility.AssertPackageReferenceDoesNotExist(VisualStudio, testContext.SolutionService.Projects[0], packageName, packageVersion, XunitLogger); } } }
public void InstallAndUpdatePackageWithSourceParameterWarns(ProjectTemplate projectTemplate, bool warns, bool installationStatus) { EnsureVisualStudioHost(); var packageName = "TestPackage"; var packageVersion1 = "1.0.0"; var packageVersion2 = "2.0.0"; var source = "https://api.nuget.org/v3/index.json"; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate)) { // Arrange var solutionService = VisualStudio.Get <SolutionService>(); testContext.Project.Build(); Utils.CreatePackageInSource(testContext.PackageSource, packageName, packageVersion1); Utils.CreatePackageInSource(testContext.PackageSource, packageName, packageVersion2); var nugetTestService = GetNuGetTestService(); var nugetConsole = GetConsole(testContext.Project); Assert.True(nugetTestService.EnsurePackageManagerConsoleIsOpen()); // Act nugetConsole.InstallPackageFromPMC(packageName, packageVersion1, source); testContext.Project.Build(); // Assert var expectedMessage = $"The 'Source' parameter is not respected for the transitive package management based project(s) {Path.GetFileNameWithoutExtension(testContext.Project.UniqueName)}. The enabled sources in your NuGet configuration will be used"; Assert.True(warns == nugetConsole.IsMessageFoundInPMC(expectedMessage), expectedMessage); if (installationStatus) { Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, packageName, packageVersion1); } VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); Assert.True(VisualStudio.HasNoErrorsInOutputWindows()); // setup again nugetConsole.Clear(); // Act nugetConsole.UpdatePackageFromPMC(packageName, packageVersion2, source); testContext.Project.Build(); // Assert if (installationStatus) { Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, packageName, packageVersion2); Utils.AssertPackageIsNotInstalled(GetNuGetTestService(), testContext.Project, packageName, packageVersion1); } Assert.True(warns == nugetConsole.IsMessageFoundInPMC(expectedMessage), expectedMessage); VisualStudio.AssertNuGetOutputDoesNotHaveErrors(); Assert.True(VisualStudio.HasNoErrorsInOutputWindows()); nugetConsole.Clear(); solutionService.Save(); } }
public void CreateNetCoreProject_RestoresNewProject(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { VisualStudio.AssertNoErrors(); } }
public async Task UpdatePackageForPC_PackageNamespace_WithSingleFeed(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using var simpleTestPathContext = new SimpleTestPathContext(); string solutionDirectory = simpleTestPathContext.SolutionRoot; var privateRepositoryPath = Path.Combine(solutionDirectory, "PrivateRepository"); Directory.CreateDirectory(privateRepositoryPath); var packageName = "Contoso.A"; var packageVersion1 = "1.0.0"; var packageVersion2 = "2.0.0"; await CommonUtility.CreatePackageInSourceAsync(privateRepositoryPath, packageName, packageVersion1); await CommonUtility.CreatePackageInSourceAsync(privateRepositoryPath, packageName, packageVersion2); //Create nuget.config with Package namespace filtering rules. CommonUtility.CreateConfigurationFile(Path.Combine(solutionDirectory, "NuGet.config"), $@"<?xml version=""1.0"" encoding=""utf-8""?> <configuration> <packageSources> <!--To inherit the global NuGet package sources remove the <clear/> line below --> <clear /> <add key=""PrivateRepository"" value=""{privateRepositoryPath}"" /> </packageSources> <packageNamespaces> <packageSource key=""PrivateRepository""> <namespace id=""Contoso.*"" /> <namespace id=""Test.*"" /> </packageSource> </packageNamespaces> //</configuration>"); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger, noAutoRestore: false, addNetStandardFeeds: false, simpleTestPathContext: simpleTestPathContext)) { var nugetConsole = GetConsole(testContext.Project); // Act nugetConsole.InstallPackageFromPMC(packageName, packageVersion1); nugetConsole.UpdatePackageFromPMC(packageName, packageVersion2); // Assert CommonUtility.AssertPackageInPackagesConfig(VisualStudio, testContext.Project, packageName, packageVersion2, XunitLogger); } }
public async Task WithExpiredAuthorCertificateAtCountersigning_InstallFromPMCForPR_WarnAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var timestampService = await _fixture.GetDefaultTrustedTimestampServiceAsync(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) using (var trustedCert = _fixture.TrustedRepositoryTestCertificate) using (var trustedExpiringTestCert = SigningTestUtility.GenerateTrustedTestCertificateThatExpiresIn10Seconds()) { XunitLogger.LogInformation("Creating package"); var package = CommonUtility.CreatePackage("ExpiredTestPackage", "1.0.0"); XunitLogger.LogInformation("Signing package"); var expiredTestPackage = CommonUtility.AuthorSignPackage(package, trustedExpiringTestCert.Source.Cert); await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, expiredTestPackage); var packageFullName = Path.Combine(testContext.PackageSource, expiredTestPackage.PackageName); XunitLogger.LogInformation("Waiting for package to expire"); SigningUtility.WaitForCertificateToExpire(trustedExpiringTestCert.Source.Cert); XunitLogger.LogInformation("Countersigning package"); var countersignedPackage = await SignedArchiveTestUtility.RepositorySignPackageAsync( new X509Certificate2(trustedCert.Source.Cert), packageFullName, testContext.PackageSource, new Uri("https://v3serviceIndexUrl.test/api/index.json"), timestampService.Url); File.Copy(countersignedPackage, packageFullName, overwrite: true); File.Delete(countersignedPackage); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(expiredTestPackage.Id, expiredTestPackage.Version); testContext.SolutionService.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); // TODO: Fix bug where no warnings are shown when package is untrusted but still installed //nugetConsole.IsMessageFoundInPMC("expired certificate").Should().BeTrue("expired certificate warning"); CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.Project, expiredTestPackage.Id, expiredTestPackage.Version, XunitLogger); } }
public void InstallPackageFromPMCWithNoAutoRestoreVerifyAssetsFile(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, noAutoRestore: true)) { var packageName = "TestPackage"; var packageVersion = "1.0.0"; Utils.CreatePackageInSource(testContext.PackageSource, packageName, packageVersion); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(packageName, packageVersion); Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, packageName, packageVersion); } }
public void InstallSignedPackageFromPMCForPC(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var signedPackage = _fixture.SignedTestPackage; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { SimpleTestPackageUtility.CreatePackages(testContext.PackageSource, signedPackage); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(signedPackage.Id, signedPackage.Version); Utils.AssetPackageInPackagesConfig(VisualStudio, testContext.Project, signedPackage.Id, signedPackage.Version, XunitLogger); } }
public async Task InstallFromPMCForPC_SucceedAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var signedPackage = _fixture.AuthorSignedTestPackage; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, signedPackage); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(signedPackage.Id, signedPackage.Version); CommonUtility.AssetPackageInPackagesConfig(VisualStudio, testContext.Project, signedPackage.Id, signedPackage.Version, XunitLogger); } }
public async Task InstallPackageFromPMCVerifyInstallForPCAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { var packageName = "TestPackage"; var packageVersion = "1.0.0"; await CommonUtility.CreatePackageInSourceAsync(testContext.PackageSource, packageName, packageVersion); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(packageName, packageVersion); CommonUtility.AssertPackageInPackagesConfig(VisualStudio, testContext.Project, packageName, packageVersion, XunitLogger); } }
public async Task InstallPackageFromPMCWithNoAutoRestoreVerifyAssetsFileAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger, noAutoRestore: true, addNetStandardFeeds: true)) { var packageName = "TestPackage"; var packageVersion = "1.0.0"; await CommonUtility.CreatePackageInSourceAsync(testContext.PackageSource, packageName, packageVersion); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(packageName, packageVersion); CommonUtility.AssertPackageInAssetsFile(VisualStudio, testContext.Project, packageName, packageVersion, XunitLogger); } }
public void CreateNetCoreProject_AddProjectReference(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate)) { var project2 = testContext.SolutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, ProjectTargetFramework.V46, "TestProject2"); project2.Build(); testContext.Project.References.Dte.AddProjectReference(project2); testContext.SolutionService.SaveAll(); testContext.SolutionService.Build(); Assert.True(testContext.Project.References.TryFindReferenceByName("TestProject2", out var result)); VisualStudio.AssertNoErrors(); } }
public void CreateNetCoreProject_AddProjectReference(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { var project2 = testContext.SolutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, ProjectTargetFramework.V46, "TestProject2"); project2.Build(); testContext.Project.References.Dte.AddProjectReference(project2); testContext.SolutionService.SaveAll(); testContext.SolutionService.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); CommonUtility.AssertPackageInAssetsFile(VisualStudio, testContext.Project, "TestProject2", "1.0.0", XunitLogger); } }
public void UninstallPackageFromPMCForPC(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { var packageName = "TestPackage"; var packageVersion = "1.0.0"; Utils.CreatePackageInSource(testContext.PackageSource, packageName, packageVersion); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(packageName, packageVersion); nugetConsole.UninstallPackageFromPMC(packageName); Utils.AssetPackageNotInPackagesConfig(VisualStudio, testContext.Project, packageName, packageVersion, XunitLogger); } }
public void NetCoreTransitivePackageReferenceLimit(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate)) { var project2 = testContext.SolutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, ProjectTargetFramework.V46, "TestProject2"); project2.Build(); var project3 = testContext.SolutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, ProjectTargetFramework.V46, "TestProject3"); project3.Build(); var projectX = testContext.SolutionService.AddProject(ProjectLanguage.CSharp, projectTemplate, ProjectTargetFramework.V46, "TestProjectX"); projectX.Build(); testContext.SolutionService.Build(); testContext.Project.References.Dte.AddProjectReference(project2); testContext.Project.References.Dte.AddProjectReference(projectX); project2.References.Dte.AddProjectReference(project3); testContext.SolutionService.SaveAll(); testContext.SolutionService.Build(); var nugetConsole = GetConsole(project3); var packageName = "newtonsoft.json"; var packageVersion = "9.0.1"; Utils.CreatePackageInSource(testContext.PackageSource, packageName, packageVersion); nugetConsole.InstallPackageFromPMC(packageName, packageVersion); testContext.Project.Build(); project2.Build(); project3.Build(); projectX.Build(); testContext.SolutionService.Build(); Utils.AssertPackageIsInstalled(GetNuGetTestService(), project3, packageName, packageVersion); // Verify install from project.assets.json Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, packageName, packageVersion); Utils.AssertPackageIsInstalled(GetNuGetTestService(), project2, packageName, packageVersion); Utils.AssertPackageIsNotInstalled(GetNuGetTestService(), projectX, packageName, packageVersion); } }
public void InstallSignedTamperedPackageFromPMCAndFailForPC(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var signedPackage = _fixture.SignedTestPackage; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { SimpleTestPackageUtility.CreatePackages(testContext.PackageSource, signedPackage); SignedArchiveTestUtility.TamperWithPackage(Path.Combine(testContext.PackageSource, signedPackage.PackageName)); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(signedPackage.Id, signedPackage.Version); nugetConsole.IsMessageFoundInPMC("package integrity check failed").Should().BeTrue("Integrity failed message shown."); Utils.AssetPackageNotInPackagesConfig(VisualStudio, testContext.Project, signedPackage.Id, signedPackage.Version, XunitLogger); } }
public void InstallSignedPackageFromPMC(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var signedPackage = _fixture.SignedTestPackage; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate)) { SimpleTestPackageUtility.CreatePackages(testContext.PackageSource, signedPackage); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(signedPackage.Id, signedPackage.Version); // Build before the install check to ensure that everything is up to date. testContext.Project.Build(); Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, signedPackage.Id, signedPackage.Version); } }
public void InstallPackageFromPMCVerifyGetPackageDisplaysPackage(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate)) { var packageName = "TestPackage"; var packageVersion = "1.0.0"; Utils.CreatePackageInSource(testContext.PackageSource, packageName, packageVersion); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(packageName, packageVersion); // Build before the install check to ensure that everything is up to date. testContext.Project.Build(); Utils.AssertPackageIsInstalled(GetNuGetTestService(), testContext.Project, packageName, packageVersion); } }
public async Task InstallFromPMCForPR_SucceedAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var signedPackage = _fixture.RepositoryCountersignedTestPackage; using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) { await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, signedPackage); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(signedPackage.Id, signedPackage.Version); testContext.Project.Build(); testContext.NuGetApexTestService.WaitForAutoRestore(); CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.Project, signedPackage.Id, signedPackage.Version, XunitLogger); } }