public async Task Symbols_AddAndRemovePackagesMultipleTimesVerifyValidation() { using (var testContext = new SleetTestContext()) { var context = testContext.SleetContext; context.SourceSettings.SymbolsEnabled = true; // Create package var identity = new PackageIdentity("a", NuGetVersion.Parse("1.0.0")); var pkgA = new TestNupkg("a", "1.0.0"); pkgA.Files.Clear(); pkgA.AddFile("lib/net45/a.dll", TestUtility.GetResource("SymbolsTestAdll").GetBytes()); pkgA.AddFile("lib/net45/a.pdb", TestUtility.GetResource("SymbolsTestApdb").GetBytes()); var zip = pkgA.Save(testContext.Packages); var pkgInput = testContext.GetPackageInput(zip); var symPkgA = new TestNupkg("a", "1.0.0"); symPkgA.Files.Clear(); symPkgA.AddFile("lib/net45/a.dll", TestUtility.GetResource("SymbolsTestAdll").GetBytes()); symPkgA.AddFile("lib/net45/a.pdb", TestUtility.GetResource("SymbolsTestApdb").GetBytes()); symPkgA.Nuspec.IsSymbolPackage = true; var symZip = symPkgA.Save(testContext.Packages); var symPkgInput = testContext.GetPackageInput(symZip); // Init var success = await InitCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, enableCatalog : true, enableSymbols : true, log : testContext.SleetContext.Log, token : CancellationToken.None); // Push success &= await PushCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, new List <string>() { zip.FullName, symZip.FullName }, force : false, skipExisting : false, log : testContext.SleetContext.Log); // Validate 1 success &= await ValidateCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, log : testContext.SleetContext.Log); // Remove success &= await DeleteCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, "a", "1.0.0", "reason", force : false, log : testContext.SleetContext.Log); // Validate 2 success &= await ValidateCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, log : testContext.SleetContext.Log); // Push Again success &= await PushCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, new List <string>() { zip.FullName, symZip.FullName }, force : false, skipExisting : false, log : testContext.SleetContext.Log); // Validate 3 success &= await ValidateCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, log : testContext.SleetContext.Log); // Remove Again success &= await DeleteCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, "a", "1.0.0", "reason", force : false, log : testContext.SleetContext.Log); // Validate 4 success &= await ValidateCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, log : testContext.SleetContext.Log); success.Should().BeTrue(); } }
public async Task Symbols_ForcePushPackageShouldNotAffectOtherType(bool isSymbols) { using (var testContext = new SleetTestContext()) { var log = (TestLogger)testContext.SleetContext.Log; var context = testContext.SleetContext; context.SourceSettings.SymbolsEnabled = true; // Create package var identity = new PackageIdentity("a", NuGetVersion.Parse("1.0.0")); var pkgA = new TestNupkg("a", "1.0.0"); pkgA.Files.Clear(); pkgA.AddFile("lib/net45/a.dll", TestUtility.GetResource("SymbolsTestAdll").GetBytes()); pkgA.AddFile("lib/net45/a.pdb", TestUtility.GetResource("SymbolsTestApdb").GetBytes()); var zip = pkgA.Save(testContext.Packages); var pkgInput = testContext.GetPackageInput(zip); var symPkgA = new TestNupkg("a", "1.0.0"); symPkgA.Files.Clear(); symPkgA.AddFile("lib/net45/a.dll", TestUtility.GetResource("SymbolsTestAdll").GetBytes()); symPkgA.AddFile("lib/net45/a.pdb", TestUtility.GetResource("SymbolsTestApdb").GetBytes()); symPkgA.Nuspec.IsSymbolPackage = true; var symZip = symPkgA.Save(testContext.Packages); var symPkgInput = testContext.GetPackageInput(symZip); var forcePushZip = zip.FullName; if (isSymbols) { forcePushZip = symZip.FullName; } // Init var success = await InitCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, enableCatalog : true, enableSymbols : true, log : testContext.SleetContext.Log, token : CancellationToken.None); success.Should().BeTrue("Init failed: " + log.GetMessages(LogLevel.Information)); // Push success &= await PushCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, new List <string>() { zip.FullName, symZip.FullName }, force : false, skipExisting : false, log : testContext.SleetContext.Log); success.Should().BeTrue("Push failed: " + log.GetMessages(LogLevel.Information)); // Force push success &= await PushCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, new List <string>() { forcePushZip }, force : true, skipExisting : false, log : testContext.SleetContext.Log); success.Should().BeTrue("Force push failed: " + log.GetMessages(LogLevel.Information)); // Validate success &= await ValidateCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, log : testContext.SleetContext.Log); success.Should().BeTrue("Validate failed: " + log.GetMessages(LogLevel.Information)); // Both packages should exist, force should not delete one or the other. var index = new PackageIndex(context); (await index.Exists(identity)).Should().BeTrue($"{identity} does not exist in the index"); (await index.SymbolsExists(identity)).Should().BeTrue($"symbols: {identity} does not exist in the index"); } }
public async Task Symbols_AddSymbolsPackagesContainingTheSameFilesVerifyDeleteDoesNotRemove() { using (var testContext = new SleetTestContext()) { var context = testContext.SleetContext; context.SourceSettings.SymbolsEnabled = true; // Create package var identity = new PackageIdentity("a", NuGetVersion.Parse("1.0.0")); var pkgA = new TestNupkg("a", "1.0.0"); pkgA.Files.Clear(); pkgA.AddFile("lib/net45/a.dll", TestUtility.GetResource("SymbolsTestAdll").GetBytes()); pkgA.AddFile("lib/net45/a.pdb", TestUtility.GetResource("SymbolsTestApdb").GetBytes()); pkgA.Nuspec.IsSymbolPackage = true; var zip = pkgA.Save(testContext.Packages); var pkgInput = testContext.GetPackageInput(zip); var identityB = new PackageIdentity("b", NuGetVersion.Parse("1.0.0")); var pkgB = new TestNupkg("b", "1.0.0"); pkgB.Files.Clear(); pkgB.AddFile("lib/net45/a.dll", TestUtility.GetResource("SymbolsTestAdll").GetBytes()); pkgB.AddFile("lib/net45/a.pdb", TestUtility.GetResource("SymbolsTestApdb").GetBytes()); pkgB.Nuspec.IsSymbolPackage = true; var zipB = pkgB.Save(testContext.Packages); var pkgInputB = testContext.GetPackageInput(zipB); // File path var dllPath = Path.Combine(testContext.Target, "symbols", "a.dll", "A7F83EF08000", "a.dll"); var dllPackagesJsonPath = Path.Combine(testContext.Target, "symbols", "a.dll", "A7F83EF08000", "packages.json"); var pdbPath = Path.Combine(testContext.Target, "symbols", "a.pdb", "B1680B8315F8485EA0A10F55AF08B565ffffffff", "a.pdb"); var pdbPackagesJsonPath = Path.Combine(testContext.Target, "symbols", "a.pdb", "B1680B8315F8485EA0A10F55AF08B565ffffffff", "packages.json"); var files = new List <string> { dllPath, dllPackagesJsonPath, pdbPath, pdbPackagesJsonPath }; // Init var success = await InitCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, enableCatalog : true, enableSymbols : true, log : testContext.SleetContext.Log, token : CancellationToken.None); // Push success &= await PushCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, new List <string>() { zip.FullName, zipB.FullName }, force : false, skipExisting : false, log : testContext.SleetContext.Log); // Verify files are present files.ForEach(e => File.Exists(e).Should().BeTrue(e)); // Remove success &= await DeleteCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, "a", "1.0.0", "reason", force : false, log : testContext.SleetContext.Log); // Verify files are still present files.ForEach(e => File.Exists(e).Should().BeTrue(e)); // Validate success &= await ValidateCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, log : testContext.SleetContext.Log); success.Should().BeTrue(); } }
public async Task Symbols_RemovePackageVerifySymbolsRemoved() { using (var testContext = new SleetTestContext()) { var context = testContext.SleetContext; context.SourceSettings.SymbolsEnabled = true; // Create package var identity = new PackageIdentity("a", NuGetVersion.Parse("1.0.0")); var pkgA = new TestNupkg("a", "1.0.0"); pkgA.Files.Clear(); pkgA.AddFile("lib/net45/a.dll", TestUtility.GetResource("SymbolsTestAdll").GetBytes()); pkgA.AddFile("lib/net45/a.pdb", TestUtility.GetResource("SymbolsTestApdb").GetBytes()); pkgA.Nuspec.IsSymbolPackage = true; var zip = pkgA.Save(testContext.Packages); var pkgInput = testContext.GetPackageInput(zip); // File path var nupkgPath = Path.Combine(testContext.Target, ToLocalPath(SymbolsIndexUtility.GetSymbolsNupkgPath(identity))); var detailsPath = Path.Combine(testContext.Target, ToLocalPath(SymbolsIndexUtility.GetSymbolsPackageDetailsPath(identity))); var dllPath = Path.Combine(testContext.Target, "symbols", "a.dll", "A7F83EF08000", "a.dll"); var dllPackagesJsonPath = Path.Combine(testContext.Target, "symbols", "a.dll", "A7F83EF08000", "packages.json"); var pdbPath = Path.Combine(testContext.Target, "symbols", "a.pdb", "B1680B8315F8485EA0A10F55AF08B565ffffffff", "a.pdb"); var pdbPackagesJsonPath = Path.Combine(testContext.Target, "symbols", "a.pdb", "B1680B8315F8485EA0A10F55AF08B565ffffffff", "packages.json"); var packageAssetsPath = Path.Combine(testContext.Target, ToLocalPath(SymbolsIndexUtility.GetPackageToAssemblyIndexPath(identity))); var files = new List <string> { nupkgPath, detailsPath, dllPath, dllPackagesJsonPath, pdbPath, pdbPackagesJsonPath, packageAssetsPath }; // Init var success = await InitCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, enableCatalog : true, enableSymbols : true, log : testContext.SleetContext.Log, token : CancellationToken.None); // Push success &= await PushCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, new List <string>() { zip.FullName }, force : false, skipExisting : false, log : testContext.SleetContext.Log); // Verify files are present files.ForEach(e => File.Exists(e).Should().BeTrue(e)); // Remove success &= await DeleteCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, "a", "1.0.0", "reason", force : false, log : testContext.SleetContext.Log); // Verify files are gone files.ForEach(e => File.Exists(e).Should().BeFalse(e)); // Validate success &= await ValidateCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, log : testContext.SleetContext.Log); success.Should().BeTrue(); var testLogger = (TestLogger)testContext.SleetContext.Log; testLogger.GetMessages().Should().Contain("Removing symbols package a.1.0.0"); } }
public async Task Symbols_AddSymbolsPackageVerifyFeed() { using (var testContext = new SleetTestContext()) { var context = testContext.SleetContext; context.SourceSettings.SymbolsEnabled = true; // Create package var pkgA = new TestNupkg("a", "1.0.0"); pkgA.Files.Clear(); pkgA.AddFile("lib/net45/a.dll", TestUtility.GetResource("SymbolsTestAdll").GetBytes()); pkgA.AddFile("lib/net45/a.pdb", TestUtility.GetResource("SymbolsTestApdb").GetBytes()); pkgA.Nuspec.IsSymbolPackage = true; var zip = pkgA.Save(testContext.Packages); var pkgInput = testContext.GetPackageInput(zip); // Init var success = await InitCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, enableCatalog : true, enableSymbols : true, log : testContext.SleetContext.Log, token : CancellationToken.None); // Push success &= await PushCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, new List <string>() { zip.FullName }, force : false, skipExisting : false, log : testContext.SleetContext.Log); // Validate success &= await ValidateCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, testContext.SleetContext.Log); success.Should().BeTrue(); var symbols = new Symbols(context); var packageIndex = new PackageIndex(context); var catalog = new Catalog(context); var autoComplete = new AutoComplete(context); var flatContainer = new FlatContainer(context); var registrations = new Registrations(context); var search = new Search(context); // Exists under symbols (await symbols.GetSymbolsPackagesAsync()).Should().NotBeEmpty(); (await packageIndex.GetSymbolsPackagesAsync()).Should().NotBeEmpty(); // Does not exist in non-symbols (await symbols.GetPackagesAsync()).Should().BeEmpty(); (await packageIndex.GetPackagesAsync()).Should().BeEmpty(); // Verify it does not appear in other services (await catalog.GetPackagesAsync()).Should().BeEmpty(); (await autoComplete.GetPackageIds()).Should().BeEmpty(); (await flatContainer.GetPackagesByIdAsync("a")).Should().BeEmpty(); (await registrations.GetPackagesByIdAsync("a")).Should().BeEmpty(); (await search.GetPackagesAsync()).Should().BeEmpty(); // Verify nupkg exists var nupkgPath = Path.Combine(testContext.Target, "symbols", "packages", "a", "1.0.0", "a.1.0.0.symbols.nupkg"); File.Exists(nupkgPath).Should().BeTrue(); // Verify package details var detailsPath = Path.Combine(testContext.Target, "symbols", "packages", "a", "1.0.0", "package.json"); File.Exists(detailsPath).Should().BeTrue(); } }
public async Task Symbols_AddPackageWithSymbolsVerifyInIndex(string isSymbolsString) { var isSymbols = bool.Parse(isSymbolsString); using (var testContext = new SleetTestContext()) { var context = testContext.SleetContext; context.SourceSettings.SymbolsEnabled = true; // Create package var pkgA = new TestNupkg("a", "1.0.0"); pkgA.Files.Clear(); pkgA.AddFile("lib/net45/a.dll", TestUtility.GetResource("SymbolsTestAdll").GetBytes()); pkgA.AddFile("lib/net45/a.pdb", TestUtility.GetResource("SymbolsTestApdb").GetBytes()); pkgA.Nuspec.IsSymbolPackage = isSymbols; var zip = pkgA.Save(testContext.Packages); var pkgInput = testContext.GetPackageInput(zip); // Init var success = await InitCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, enableCatalog : true, enableSymbols : true, log : testContext.SleetContext.Log, token : CancellationToken.None); // Push success &= await PushCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, new List <string>() { zip.FullName }, force : false, skipExisting : false, log : testContext.SleetContext.Log); // Validate success &= await ValidateCommand.RunAsync( testContext.SleetContext.LocalSettings, testContext.SleetContext.Source, testContext.SleetContext.Log); var symbolsIndex = new HashSet <PackageIdentity>(); var packageIndexPkgs = new HashSet <PackageIdentity>(); var symbols = new Symbols(context); var packageIndex = new PackageIndex(context); if (isSymbols) { symbolsIndex.UnionWith(await symbols.GetSymbolsPackagesAsync()); packageIndexPkgs.UnionWith(await packageIndex.GetSymbolsPackagesAsync()); } else { symbolsIndex.UnionWith(await symbols.GetPackagesAsync()); packageIndexPkgs.UnionWith(await packageIndex.GetPackagesAsync()); } // Verify package does not show up in symbols index symbolsIndex.Should().BeEquivalentTo(new[] { new PackageIdentity("a", NuGetVersion.Parse("1.0.0")) }); packageIndexPkgs.Should().BeEquivalentTo(new[] { new PackageIdentity("a", NuGetVersion.Parse("1.0.0")) }); // Validate success.Should().BeTrue(); } }
public async Task Feed_VerifyBaseUriIsAppliedToLocal(string baseUriString) { // Arrange using (var packagesFolder = new TestFolder()) using (var target = new TestFolder()) using (var cache = new LocalCache()) { var log = new TestLogger(); var fileSystemRoot = UriUtility.CreateUri(target.Root); var baseUri = new Uri(baseUriString); var fileSystem = new PhysicalFileSystem(cache, fileSystemRoot, baseUri); var settings = new LocalSettings(); var context = new SleetContext() { Token = CancellationToken.None, LocalSettings = settings, Log = log, Source = fileSystem, SourceSettings = new FeedSettings() { CatalogEnabled = true, SymbolsEnabled = true } }; var testPackage = new TestNupkg("packageA", "1.0.0"); var zipFile = testPackage.Save(packagesFolder.Root); using (var zip = new ZipArchive(File.OpenRead(zipFile.FullName), ZipArchiveMode.Read, false)) { var input = PackageInput.Create(zipFile.FullName); // Act // run commands await InitCommand.InitAsync(context); await PushCommand.RunAsync(context.LocalSettings, context.Source, new List <string>() { zipFile.FullName }, false, false, context.Log); var validateOutput = await ValidateCommand.RunAsync(context.LocalSettings, context.Source, context.Log); // read outputs var catalog = new Catalog(context); var registration = new Registrations(context); var packageIndex = new PackageIndex(context); var search = new Search(context); var autoComplete = new AutoComplete(context); var catalogEntries = await catalog.GetIndexEntriesAsync(); var catalogExistingEntries = await catalog.GetExistingPackagesIndexAsync(); var catalogLatest = await catalog.GetLatestEntryAsync(input.Identity); var regPackages = await registration.GetPackagesByIdAsync(input.Identity.Id); var indexPackages = await packageIndex.GetPackagesAsync(); var searchPackages = await search.GetPackagesAsync(); var autoCompletePackages = await autoComplete.GetPackageIds(); // Assert Assert.True(validateOutput); Assert.Equal(1, catalogEntries.Count); Assert.Equal(1, catalogExistingEntries.Count); Assert.Equal(1, regPackages.Count); Assert.Equal(1, indexPackages.Count); Assert.Equal(1, searchPackages.Count); Assert.Equal(1, autoCompletePackages.Count); // Walk json to check for bad urls await TestUtility.WalkJsonAsync(target.Root, (file, json, toCheck) => { // Check only URLs found if (toCheck.IndexOf("://") > -1) { var cleanUriSchema = toCheck.Replace(":///", string.Empty).Replace("://", string.Empty); var doubleSlash = cleanUriSchema.IndexOf("//") > -1; Assert.False(doubleSlash, toCheck); } }); } } }