Пример #1
0
        public async Task GivenAStorageAccountVerifyPushSucceeds()
        {
            using (var packagesFolder = new TestFolder())
                using (var testContext = new AzureTestContext())
                {
                    await testContext.InitAsync();

                    var testPackage = new TestNupkg("packageA", "1.0.0");
                    var zipFile     = testPackage.Save(packagesFolder.Root);

                    var result = await InitCommand.RunAsync(testContext.LocalSettings,
                                                            testContext.FileSystem,
                                                            enableCatalog : true,
                                                            enableSymbols : true,
                                                            log : testContext.Logger,
                                                            token : CancellationToken.None);

                    result &= await PushCommand.RunAsync(testContext.LocalSettings,
                                                         testContext.FileSystem,
                                                         new List <string>() { zipFile.FullName },
                                                         force : false,
                                                         skipExisting : false,
                                                         log : testContext.Logger);

                    result &= await ValidateCommand.RunAsync(testContext.LocalSettings,
                                                             testContext.FileSystem,
                                                             testContext.Logger);

                    result.Should().BeTrue();

                    await testContext.CleanupAsync();
                }
        }
Пример #2
0
        public async Task GivenAStorageAccountVerifyContainerOperations()
        {
            using (var testContext = new AzureTestContext())
            {
                testContext.CreateContainerOnInit = false;
                await testContext.InitAsync();

                // Verify at the start
                (await testContext.FileSystem.HasBucket(testContext.Logger, CancellationToken.None)).Should().BeFalse();
                (await testContext.FileSystem.Validate(testContext.Logger, CancellationToken.None)).Should().BeFalse();

                // Create
                await testContext.FileSystem.CreateBucket(testContext.Logger, CancellationToken.None);

                (await testContext.FileSystem.HasBucket(testContext.Logger, CancellationToken.None)).Should().BeTrue();
                (await testContext.FileSystem.Validate(testContext.Logger, CancellationToken.None)).Should().BeTrue();

                // Delete
                await testContext.FileSystem.DeleteBucket(testContext.Logger, CancellationToken.None);

                (await testContext.FileSystem.HasBucket(testContext.Logger, CancellationToken.None)).Should().BeFalse();
                (await testContext.FileSystem.Validate(testContext.Logger, CancellationToken.None)).Should().BeFalse();

                await testContext.CleanupAsync();
            }
        }
Пример #3
0
        public async Task GivenPushCreatesAContainerVerifyNuGetCanRead()
        {
            using (var packagesFolder = new TestFolder())
                using (var testContext = new AzureTestContext())
                    using (var sourceContext = new SourceCacheContext())
                    {
                        // Skip creation and allow it to be done during push.
                        testContext.CreateContainerOnInit = false;
                        await testContext.InitAsync();

                        var testPackage = new TestNupkg("packageA", "1.0.0");
                        var zipFile     = testPackage.Save(packagesFolder.Root);

                        var result = await PushCommand.RunAsync(testContext.LocalSettings,
                                                                testContext.FileSystem,
                                                                new List <string>() { zipFile.FullName },
                                                                force : false,
                                                                skipExisting : false,
                                                                log : testContext.Logger);

                        // Read the feed with NuGet.Protocol
                        var feedIndex = $"{testContext.FileSystem.Root.AbsoluteUri}index.json";
                        var repo      = Repository.Factory.GetCoreV3(feedIndex);
                        var resource  = await repo.GetResourceAsync <FindPackageByIdResource>(CancellationToken.None);

                        var packageResults = (await resource.GetAllVersionsAsync("packageA", sourceContext, NullLogger.Instance, CancellationToken.None)).ToList();
                        packageResults.Count.Should().Be(1);
                        packageResults[0].ToIdentityString().Should().Be("1.0.0");

                        await testContext.CleanupAsync();
                    }
        }
Пример #4
0
        public async Task GivenAStorageAccountWithNoContainerVerifyPushSucceeds()
        {
            using (var packagesFolder = new TestFolder())
                using (var testContext = new AzureTestContext())
                {
                    // Skip creation and allow it to be done during push.
                    testContext.CreateContainerOnInit = false;

                    await testContext.InitAsync();

                    var testPackage = new TestNupkg("packageA", "1.0.0");
                    var zipFile     = testPackage.Save(packagesFolder.Root);

                    var result = await PushCommand.RunAsync(testContext.LocalSettings,
                                                            testContext.FileSystem,
                                                            new List <string>() { zipFile.FullName },
                                                            force : false,
                                                            skipExisting : false,
                                                            log : testContext.Logger);

                    result &= await ValidateCommand.RunAsync(testContext.LocalSettings,
                                                             testContext.FileSystem,
                                                             testContext.Logger);

                    result.Should().BeTrue();

                    await testContext.CleanupAsync();
                }
        }
Пример #5
0
        public async Task SubFeed_InitMultipleFeedsVerifyDestroyDoesNotModifyOthers()
        {
            using (var packagesFolder = new TestFolder())
                using (var testContext = new AzureTestContext())
                    using (var testContext2 = new AzureTestContext())
                    {
                        // Use a subfeed for the filesystem
                        var subFeedName  = "testSubFeedA";
                        var subFeedName2 = "testSubFeedB";
                        var root         = UriUtility.GetPath(testContext.Uri, subFeedName);
                        var root2        = UriUtility.GetPath(testContext.Uri, subFeedName2);
                        testContext.FileSystem  = new AzureFileSystem(testContext.LocalCache, root, root, testContext.StorageAccount, testContext.ContainerName, feedSubPath: subFeedName);
                        testContext2.FileSystem = new AzureFileSystem(testContext.LocalCache, root2, root2, testContext.StorageAccount, testContext.ContainerName, feedSubPath: subFeedName2);

                        await testContext.InitAsync();

                        await testContext2.InitAsync();

                        var testPackage = new TestNupkg("packageA", "1.0.0");
                        var zipFile     = testPackage.Save(packagesFolder.Root);

                        var result = await InitCommand.RunAsync(testContext.LocalSettings,
                                                                testContext.FileSystem,
                                                                enableCatalog : true,
                                                                enableSymbols : true,
                                                                log : testContext.Logger,
                                                                token : CancellationToken.None);

                        result &= await InitCommand.RunAsync(testContext.LocalSettings,
                                                             testContext2.FileSystem,
                                                             enableCatalog : true,
                                                             enableSymbols : true,
                                                             log : testContext2.Logger,
                                                             token : CancellationToken.None);

                        // Destroy feed2
                        result &= await DestroyCommand.RunAsync(testContext.LocalSettings,
                                                                testContext2.FileSystem,
                                                                testContext2.Logger);

                        // Validate feed1
                        result &= await ValidateCommand.RunAsync(testContext.LocalSettings,
                                                                 testContext.FileSystem,
                                                                 testContext.Logger);


                        result.Should().BeTrue();

                        await testContext.CleanupAsync();

                        await testContext2.CleanupAsync();
                    }
        }
Пример #6
0
        public async Task SubFeed_PushAndVerifyNoFilesInRoot()
        {
            using (var packagesFolder = new TestFolder())
                using (var testContext = new AzureTestContext())
                {
                    // Use a subfeed for the filesystem
                    var subFeedName = "testSubFeed";
                    var root        = UriUtility.GetPath(testContext.Uri, subFeedName);
                    testContext.FileSystem = new AzureFileSystem(testContext.LocalCache, root, root, testContext.StorageAccount, testContext.ContainerName, feedSubPath: subFeedName);

                    await testContext.InitAsync();

                    var testPackage = new TestNupkg("packageA", "1.0.0");
                    var zipFile     = testPackage.Save(packagesFolder.Root);

                    var result = await InitCommand.RunAsync(testContext.LocalSettings,
                                                            testContext.FileSystem,
                                                            enableCatalog : true,
                                                            enableSymbols : true,
                                                            log : testContext.Logger,
                                                            token : CancellationToken.None);

                    result &= await PushCommand.RunAsync(testContext.LocalSettings,
                                                         testContext.FileSystem,
                                                         new List <string>() { zipFile.FullName },
                                                         force : false,
                                                         skipExisting : false,
                                                         log : testContext.Logger);

                    result &= await ValidateCommand.RunAsync(testContext.LocalSettings,
                                                             testContext.FileSystem,
                                                             testContext.Logger);

                    result.Should().BeTrue();

                    var token = new BlobContinuationToken();
                    var files = await GetFiles(testContext.Container);

                    files.Where(e => e.AbsoluteUri.IndexOf(subFeedName, StringComparison.OrdinalIgnoreCase) < 0).Should().BeEmpty();
                    files.Where(e => e.AbsoluteUri.IndexOf(subFeedName, StringComparison.OrdinalIgnoreCase) > -1).Should().NotBeEmpty();

                    await testContext.CleanupAsync();
                }
        }
Пример #7
0
        public async Task GivenAStorageAccountVerifyPushWithBaseURI()
        {
            using (var packagesFolder = new TestFolder())
                using (var testContext = new AzureTestContext())
                {
                    var baseUri    = new Uri("http://tempuri.org/abc/");
                    var fileSystem = new AzureFileSystem(testContext.LocalCache, testContext.Uri, baseUri, testContext.StorageAccount, testContext.ContainerName);
                    testContext.FileSystem = fileSystem;

                    await testContext.InitAsync();

                    var testPackage = new TestNupkg("packageA", "1.0.0");
                    var zipFile     = testPackage.Save(packagesFolder.Root);

                    var result = await InitCommand.RunAsync(testContext.LocalSettings,
                                                            testContext.FileSystem,
                                                            enableCatalog : true,
                                                            enableSymbols : true,
                                                            log : testContext.Logger,
                                                            token : CancellationToken.None);

                    result &= await PushCommand.RunAsync(testContext.LocalSettings,
                                                         testContext.FileSystem,
                                                         new List <string>() { zipFile.FullName },
                                                         force : false,
                                                         skipExisting : false,
                                                         log : testContext.Logger);

                    result &= await ValidateCommand.RunAsync(testContext.LocalSettings,
                                                             testContext.FileSystem,
                                                             testContext.Logger);

                    result.Should().BeTrue();

                    // Check baseURIs
                    await BaseURITestUtil.VerifyBaseUris(testContext.FileSystem.Files.Values, baseUri);

                    await testContext.CleanupAsync();
                }
        }
Пример #8
0
        public async Task GivenAStorageAccountVerifyInitSucceeds()
        {
            using (var testContext = new AzureTestContext())
            {
                await testContext.InitAsync();

                var result = await InitCommand.RunAsync(testContext.LocalSettings,
                                                        testContext.FileSystem,
                                                        enableCatalog : true,
                                                        enableSymbols : true,
                                                        log : testContext.Logger,
                                                        token : CancellationToken.None);

                result &= await ValidateCommand.RunAsync(testContext.LocalSettings,
                                                         testContext.FileSystem,
                                                         testContext.Logger);

                result.Should().BeTrue();

                await testContext.CleanupAsync();
            }
        }
Пример #9
0
        public async Task SubFeed_PushAndVerifyWithNestedFeedsVerifySuccess()
        {
            using (var packagesFolder = new TestFolder())
                using (var testContext = new AzureTestContext())
                    using (var testContext2 = new AzureTestContext())
                    {
                        // Use a subfeed for the filesystem
                        var subFeedName = "testSubFeed";
                        var root        = UriUtility.GetPath(testContext.Uri, subFeedName);
                        testContext.FileSystem = new AzureFileSystem(testContext.LocalCache, root, root, testContext.StorageAccount, testContext.ContainerName, feedSubPath: subFeedName);

                        await testContext.InitAsync();

                        await testContext2.InitAsync();

                        var testPackage = new TestNupkg("packageA", "1.0.0");
                        var zipFile     = testPackage.Save(packagesFolder.Root);

                        var result = await InitCommand.RunAsync(testContext.LocalSettings,
                                                                testContext.FileSystem,
                                                                enableCatalog : true,
                                                                enableSymbols : true,
                                                                log : testContext.Logger,
                                                                token : CancellationToken.None);

                        result &= await InitCommand.RunAsync(testContext.LocalSettings,
                                                             testContext2.FileSystem,
                                                             enableCatalog : true,
                                                             enableSymbols : true,
                                                             log : testContext2.Logger,
                                                             token : CancellationToken.None);

                        result &= await PushCommand.RunAsync(testContext.LocalSettings,
                                                             testContext.FileSystem,
                                                             new List <string>() { zipFile.FullName },
                                                             force : false,
                                                             skipExisting : false,
                                                             log : testContext.Logger);

                        result &= await PushCommand.RunAsync(testContext.LocalSettings,
                                                             testContext2.FileSystem,
                                                             new List <string>() { zipFile.FullName },
                                                             force : false,
                                                             skipExisting : false,
                                                             log : testContext2.Logger);

                        result &= await ValidateCommand.RunAsync(testContext.LocalSettings,
                                                                 testContext.FileSystem,
                                                                 testContext.Logger);

                        result &= await ValidateCommand.RunAsync(testContext.LocalSettings,
                                                                 testContext2.FileSystem,
                                                                 testContext2.Logger);

                        result.Should().BeTrue();

                        await testContext.CleanupAsync();

                        await testContext2.CleanupAsync();
                    }
        }