Exemplo n.º 1
0
        public async Task V2FeedParser_DownloadFromIdentity()
        {
            // Arrange
            var repo = Repository.Factory.GetCoreV3(TestServers.NuGetV2);

            var httpSource = HttpSource.Create(repo);

            V2FeedParser parser = new V2FeedParser(httpSource, TestServers.NuGetV2);

            // Act & Assert
            using (var packagesFolder = TestDirectory.Create())
                using (var cacheContext = new SourceCacheContext())
                {
                    using (var downloadResult = await parser.DownloadFromIdentity(
                               new PackageIdentity("WindowsAzure.Storage", new NuGetVersion("6.2.0")),
                               new PackageDownloadContext(cacheContext),
                               packagesFolder,
                               NullLogger.Instance,
                               CancellationToken.None))
                    {
                        var packageReader = downloadResult.PackageReader;
                        var files         = packageReader.GetFiles();

                        Assert.Equal(11, files.Count());
                    }
                }
        }
Exemplo n.º 2
0
        public async Task V2FeedParser_DownloadFromIdentityFromDifferentCredentialServer(string packageSource, string feedName)
        {
            // Arrange
            var credential       = Utility.ReadCredential(feedName);
            var source           = new PackageSource(packageSource);
            var sourceCredential = new PackageSourceCredential(packageSource, credential.Item1, credential.Item2, true);

            source.Credentials = sourceCredential;
            var repo = Repository.Factory.GetCoreV2(source);

            var httpSource = HttpSource.Create(repo);

            V2FeedParser parser = new V2FeedParser(httpSource, packageSource);

            // Act & Assert
            using (var packagesFolder = TestDirectory.Create())
                using (var cacheContext = new SourceCacheContext())
                {
                    using (var downloadResult = await parser.DownloadFromIdentity(
                               new PackageIdentity("newtonsoft.json", new NuGetVersion("8.0.3")),
                               new PackageDownloadContext(cacheContext),
                               packagesFolder,
                               NullLogger.Instance,
                               CancellationToken.None))
                    {
                        var packageReader = downloadResult.PackageReader;
                        var files         = packageReader.GetFiles();

                        Assert.Equal(15, files.Count());
                    }
                }
        }
Exemplo n.º 3
0
        public async Task V2FeedParser_DownloadFromIdentityInvalidId()
        {
            // Arrange
            var serviceAddress = TestUtility.CreateServiceAddress();

            var responses = new Dictionary <string, string>();

            responses.Add(serviceAddress + "Packages(Id='xunit',Version='1.0.0-notfound')", string.Empty);
            responses.Add(serviceAddress + "FindPackagesById()?id='xunit'",
                          TestUtility.GetResource("NuGet.Protocol.Core.v3.Tests.compiler.resources.XunitFindPackagesById.xml", GetType()));
            responses.Add(serviceAddress, string.Empty);

            var httpSource = new TestHttpSource(new PackageSource(serviceAddress), responses,
                                                TestUtility.GetResource("NuGet.Protocol.Core.v3.Tests.compiler.resources.500Error.xml", GetType()));
            V2FeedParser parser = new V2FeedParser(httpSource, serviceAddress);

            // Act
            var actual = await parser.DownloadFromIdentity(new PackageIdentity("xunit", new NuGetVersion("1.0.0-notfound")),
                                                           NullSettings.Instance,
                                                           NullLogger.Instance,
                                                           CancellationToken.None);

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(DownloadResourceResultStatus.NotFound, actual.Status);
        }
Exemplo n.º 4
0
        public async Task V2FeedParser_DownloadFromIdentityFromDifferentServer(string packageSource)
        {
            // Arrange
            var repo = Repository.Factory.GetCoreV3(packageSource);

            var httpSource = HttpSource.Create(repo);

            V2FeedParser parser = new V2FeedParser(httpSource, packageSource);

            // Act & Assert
            using (var downloadResult = await parser.DownloadFromIdentity(new PackageIdentity("newtonsoft.json", new NuGetVersion("8.0.3")),
                                                                          Configuration.NullSettings.Instance,
                                                                          NullLogger.Instance,
                                                                          CancellationToken.None))
            {
                var packageReader = downloadResult.PackageReader;
                var files         = packageReader.GetFiles();

                Assert.Equal(15, files.Count());
            }
        }
Exemplo n.º 5
0
        public async Task V2FeedParser_DownloadFromIdentity()
        {
            // Arrange
            var repo = Repository.Factory.GetCoreV3(TestSources.NuGetV2Uri);

            var httpSource = HttpSource.Create(repo);

            var parser = new V2FeedParser(httpSource, TestSources.NuGetV2Uri);

            // Act & Assert
            using (var packagesFolder = TestDirectory.Create())
                using (var cacheContext = new SourceCacheContext())
                {
                    var downloadContext = new PackageDownloadContext(cacheContext)
                    {
                        ExtractionContext = new PackageExtractionContext(
                            PackageSaveMode.Defaultv3,
                            PackageExtractionBehavior.XmlDocFileSaveMode,
                            NullLogger.Instance,
                            signedPackageVerifier: null,
                            signedPackageVerifierSettings: null)
                    };

                    using (var downloadResult = await parser.DownloadFromIdentity(
                               new PackageIdentity("WindowsAzure.Storage", new NuGetVersion("6.2.0")),
                               downloadContext,
                               packagesFolder,
                               cacheContext,
                               NullLogger.Instance,
                               CancellationToken.None))
                    {
                        var packageReader = downloadResult.PackageReader;
                        var files         = packageReader.GetFiles();

                        Assert.Equal(13, files.Count());
                    }
                }
        }