[Trait("Category", "integration")] // because it uses external nupkg files public async Task PushOneThenSearchPackage() { InitializeClient(MainIndex); var packageResource = await _sourceRepository.GetResourceAsync <PackageUpdateResource>(); await packageResource.Push(TestResources.GetNupkgBagetTest1(), null, 5, false, GetApiKey, GetApiKey, false, logger); PackageSearchResourceV3 search = GetSearch(); var found = await search.SearchAsync("liget-test1", new SearchFilter(true), 0, 10, logger, CancellationToken.None); Assert.NotEmpty(found); var one = found.First(); Assert.Equal(new PackageIdentity("liget-test1", NuGetVersion.Parse("1.0.0")), one.Identity); }
[Trait("Category", "integration")] // because it uses external nupkg files public async Task PushAndDeletePackage() { InitializeClient(MainIndex); var packageResource = await _sourceRepository.GetResourceAsync <PackageUpdateResource>(); await packageResource.Push(TestResources.GetNupkgBagetTest1(), null, 5, false, GetApiKey, GetApiKey, false, logger); await packageResource.Delete( "liget-test1", "1.0.0", GetApiKey, _ => true, false, logger); PackageMetadataResourceV3 packageMetadataRes = GetPackageMetadataResource(); var meta = await packageMetadataRes.GetMetadataAsync("liget-test1", true, true, _cacheContext, logger, CancellationToken.None); Assert.Empty(meta); }
[Trait("Category", "integration")] // because it uses external nupkg files public async Task PushValidPackage() { InitializeClient(MainIndex); var packageResource = await _sourceRepository.GetResourceAsync <PackageUpdateResource>(); await packageResource.Push(TestResources.GetNupkgBagetTest1(), null, 5, false, GetApiKey, GetApiKey, false, logger); PackageMetadataResourceV3 packageMetadataRes = GetPackageMetadataResource(); var meta = await packageMetadataRes.GetMetadataAsync("liget-test1", true, true, _cacheContext, logger, CancellationToken.None); Assert.NotEmpty(meta); var one = meta.First(); Assert.Equal(new PackageIdentity("liget-test1", NuGetVersion.Parse("1.0.0")), one.Identity); }
[Trait("Category", "integration")] // because it uses external nupkg files public async Task PushAndDownloadValidPackage() { InitializeClient(MainIndex); var packageResource = await _sourceRepository.GetResourceAsync <PackageUpdateResource>(); await packageResource.Push(TestResources.GetNupkgBagetTest1(), null, 5, false, GetApiKey, GetApiKey, false, logger); var findByIdRes = new RemoteV3FindPackageByIdResource(_sourceRepository, _httpSource.HttpSource); var downloader = await findByIdRes.GetPackageDownloaderAsync( new PackageIdentity("liget-test1", NuGetVersion.Parse("1.0.0")), _cacheContext, logger, CancellationToken.None); string tempPath = Path.Combine(tempDir.UniqueTempFolder, "test.nupkg"); await downloader.CopyNupkgFileToAsync(tempPath, CancellationToken.None); Assert.Equal(File.ReadAllBytes(TestResources.GetNupkgBagetTest1()), File.ReadAllBytes(tempPath)); }
[Trait("Category", "integration")] // because it uses external nupkg files public async Task GetV2FindPackagesById() { InitializeClient(MainIndex); var packageResource = await _sourceRepository.GetResourceAsync <PackageUpdateResource>(); await packageResource.Push(TestResources.GetNupkgBagetTest1(), null, 5, false, GetApiKey, GetApiKey, false, logger); var response = await _httpClient.GetAsync("/api/v2/FindPackagesById()?id=liget-test1"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var responseText = await response.Content.ReadAsStringAsync(); var entries = XmlFeedHelper.ParsePage(XDocument.Parse(responseText)); var entry = Assert.Single(entries); AssertLiGetTestEntry(entry); }
[Trait("Category", "integration")] // because it uses external nupkg files public async Task PushedPackageShouldExistWithPackageDependenciesInPackageService() { InitializeClient(MainIndex); var packageResource = await _sourceRepository.GetResourceAsync <PackageUpdateResource>(); await packageResource.Push(TestResources.GetNupkgBagetTest1(), null, 5, false, GetApiKey, GetApiKey, false, logger); var packageService = server.Host.Services.GetRequiredService <IPackageService>(); Assert.True(await packageService.ExistsAsync(new PackageIdentity("liget-test1", NuGetVersion.Parse("1.0.0")))); var found = await packageService.FindOrNullAsync(new PackageIdentity("liget-test1", NuGetVersion.Parse("1.0.0")), false, true); Assert.NotNull(found.Dependencies); Assert.NotEmpty(found.Dependencies); var one = found.Dependencies.Single(); Assert.Equal("netstandard2.0", one.TargetFramework); }