Пример #1
0
        public async Task FeedConfigParserTests5Async()
        {
            var buildEngine = new MockBuildEngine();
            var task        = new PublishArtifactsInManifestV2
            {
                InternalBuild    = true,
                TargetFeedConfig = new Microsoft.Build.Utilities.TaskItem[]
                {
                    new Microsoft.Build.Utilities.TaskItem("FOOPACKAGES", new Dictionary <string, string> {
                        { "TargetUrl", BlobFeedUrl },
                        { "Token", RandomToken },
                        { "Type", "AZURESTORAGEFEED" },
                        { "AssetSelection", "SHIPPINGONLY" },
                        { "Internal", "true" }
                    }),
                    new Microsoft.Build.Utilities.TaskItem("FOOPACKAGES", new Dictionary <string, string> {
                        { "TargetUrl", BlobFeedUrl },
                        { "Token", RandomToken },
                        { "Type", "AZURESTORAGEFEED" },
                        { "AssetSelection", "SHIPPINGONLY" }
                    }),
                },
                BuildEngine = buildEngine
            };

            await task.ParseTargetFeedConfigAsync();

            // Verify that the checker errors on attempts to publish internal
            // artifacts to non-internal feeds
            task.Log.HasLoggedErrors.Should().BeTrue();
            buildEngine.BuildErrorEvents.Should().Contain(e => e.Message.Equals($"Use of non-internal feed '{BlobFeedUrl}' is invalid for an internal build. This can be overridden with '{nameof(PublishArtifactsInManifest.SkipSafetyChecks)}= true'"));
        }
Пример #2
0
        public async Task FeedConfigParserTests1Async()
        {
            var buildEngine = new MockBuildEngine();
            var task        = new PublishArtifactsInManifestV2
            {
                // Create a single Microsoft.Build.Utilities.TaskItem for a simple feed config, then parse to FeedConfigs and
                // check the expected values.
                TargetFeedConfig = new Microsoft.Build.Utilities.TaskItem[]
                {
                    new Microsoft.Build.Utilities.TaskItem(TargetFeedContentType.BinaryLayout.ToString(), new Dictionary <string, string> {
                        { "TargetUrl", BlobFeedUrl },
                        { "Token", RandomToken },
                        { "Type", "AzDoNugetFeed" },
                        { "Internal", "false" }
                    }),
                },
                BuildEngine = buildEngine
            };

            await task.ParseTargetFeedConfigAsync();

            task.Log.HasLoggedErrors.Should().BeFalse();

            // This will have set the feed configs.
            task.FeedConfigs.Should().ContainKey(TargetFeedContentType.BinaryLayout).WhichValue.Should().SatisfyRespectively(
                config =>
            {
                config.Token.Should().Be(RandomToken);
                config.TargetURL.Should().Be(BlobFeedUrl);
                config.Internal.Should().BeFalse();
                config.Type.Should().Be(FeedType.AzDoNugetFeed);
                config.AssetSelection.Should().Be(AssetSelection.All);
            });
        }
Пример #3
0
        public async Task FeedConfigParserTests6Async()
        {
            var buildEngine = new MockBuildEngine();
            var task        = new PublishArtifactsInManifestV2
            {
                InternalBuild    = true,
                TargetFeedConfig = new Microsoft.Build.Utilities.TaskItem[]
                {
                    new Microsoft.Build.Utilities.TaskItem(TargetFeedContentType.Checksum.ToString(), new Dictionary <string, string> {
                        { "TargetUrl", BlobFeedUrl },
                        { "Token", RandomToken },
                        { "Type", "AZURESTORAGEFEED" },
                        { "AssetSelection", "SHIPPINGONLY" },
                        { "Internal", "true" }
                    }),
                    new Microsoft.Build.Utilities.TaskItem(TargetFeedContentType.Maven.ToString(), new Dictionary <string, string> {
                        { "TargetUrl", BlobFeedUrl },
                        { "Token", RandomToken },
                        { "Type", "AZURESTORAGEFEED" },
                        { "AssetSelection", "SHIPPINGONLY" },
                        { "Internal", "true" }
                    }),
                },
                BuildEngine = buildEngine
            };

            await task.ParseTargetFeedConfigAsync();

            task.Log.HasLoggedErrors.Should().BeFalse();
        }
Пример #4
0
        public async Task FeedConfigParserTests4Async()
        {
            var buildEngine = new MockBuildEngine();
            var task        = new PublishArtifactsInManifestV2
            {
                TargetFeedConfig = new Microsoft.Build.Utilities.TaskItem[]
                {
                    new Microsoft.Build.Utilities.TaskItem(TargetFeedContentType.BinaryLayout.ToString(), new Dictionary <string, string> {
                        { "TargetUrl", BlobFeedUrl },
                        { "Token", RandomToken },
                        // Use different casing here to make sure that parsing
                        // ignores case.
                        { "Type", "AZURESTORAGEFEED" },
                        { "AssetSelection", "SHIPPINGONLY" },
                        { "Internal", "false" }
                    }),
                },
                BuildEngine = buildEngine
            };

            await task.ParseTargetFeedConfigAsync();

            // This will have set the feed configs.
            task.FeedConfigs.Should().ContainKey(TargetFeedContentType.BinaryLayout).WhichValue.Should().SatisfyRespectively(
                config =>
            {
                config.Token.Should().Be(RandomToken);
                config.TargetURL.Should().Be(BlobFeedUrl);
                config.Type.Should().Be(FeedType.AzureStorageFeed);
                config.AssetSelection.Should().Be(AssetSelection.ShippingOnly);
            });
        }
Пример #5
0
        public async Task StableAssetCheckV2Async(string assetVersion, bool isIsolatedFeed, bool shouldError, bool isReleaseOnlyPackageVersion = false, bool skipChecks = false)
        {
            const string packageId = "Foo.Package";

            BuildIdentity buildIdentity = new BuildIdentity
            {
                IsReleaseOnlyPackageVersion = isReleaseOnlyPackageVersion
            };
            BuildModel buildModel = new BuildModel(buildIdentity)
            {
                Artifacts = new ArtifactSet
                {
                    Blobs    = new List <BlobArtifactModel>(),
                    Packages = new List <PackageArtifactModel>
                    {
                        new PackageArtifactModel()
                        {
                            Id      = packageId,
                            Version = assetVersion
                        }
                    }
                }
            };
            var buildEngine = new MockBuildEngine();
            var task        = new PublishArtifactsInManifestV2
            {
                SkipSafetyChecks = skipChecks,
                TargetFeedConfig = new MsBuildUtils.TaskItem[]
                {
                    new MsBuildUtils.TaskItem("PACKAGE", new Dictionary <string, string> {
                        { "TargetUrl", BlobFeedUrl },
                        { "Token", RandomToken },
                        { "Type", "AZURESTORAGEFEED" },
                        { "AssetSelection", "SHIPPINGONLY" },
                        { "Internal", "false" },
                        { "Isolated", isIsolatedFeed.ToString() }
                    })
                },
                BuildEngine = buildEngine,
                BuildModel  = buildModel
            };

            await task.ParseTargetFeedConfigAsync();

            task.Log.HasLoggedErrors.Should().BeFalse();

            task.SplitArtifactsInCategories(buildModel);
            task.Log.HasLoggedErrors.Should().BeFalse();

            task.CheckForStableAssetsInNonIsolatedFeeds();
            task.Log.HasLoggedErrors.Should().Be(shouldError);
            if (shouldError)
            {
                buildEngine.BuildErrorEvents.Should().Contain(e => e.Message.Equals($"Package '{packageId}' has stable version '{assetVersion}' but is targeted at a non-isolated feed '{BlobFeedUrl}'"));
            }
        }
Пример #6
0
        public async Task FeedConfigParserTests3Async()
        {
            var buildEngine = new MockBuildEngine();
            var task        = new PublishArtifactsInManifestV2
            {
                TargetFeedConfig = new Microsoft.Build.Utilities.TaskItem[]
                {
                    new Microsoft.Build.Utilities.TaskItem("FOOPACKAGES", new Dictionary <string, string> {
                        { "TargetUrl", string.Empty },
                        { "Token", string.Empty },
                        { "Type", string.Empty },
                        { "Internal", "false" }
                    }),
                },
                BuildEngine = buildEngine
            };

            await task.ParseTargetFeedConfigAsync();

            task.Log.HasLoggedErrors.Should().BeTrue();
            buildEngine.BuildErrorEvents.Should().Contain(e => e.Message.Equals("Invalid FeedConfig entry. TargetURL='' Type='' Token=''"));
        }
Пример #7
0
        public async Task FeedConfigParserTests2Async()
        {
            var buildEngine = new MockBuildEngine();
            var task        = new PublishArtifactsInManifestV2
            {
                TargetFeedConfig = new Microsoft.Build.Utilities.TaskItem[]
                {
                    new Microsoft.Build.Utilities.TaskItem("FOOPACKAGES", new Dictionary <string, string> {
                        { "TargetUrl", BlobFeedUrl },
                        { "Token", RandomToken },
                        { "Type", "MyUnknownFeedType" },
                        { "Internal", "false" }
                    }),
                },
                BuildEngine = buildEngine
            };

            await task.ParseTargetFeedConfigAsync();

            Assert.True(task.Log.HasLoggedErrors);
            Assert.Contains(buildEngine.BuildErrorEvents, e => e.Message.Equals("Invalid feed config type 'MyUnknownFeedType'. Possible values are: AzDoNugetFeed, AzureStorageFeed"));
        }
Пример #8
0
        public async Task FeedConfigParserTests1Async()
        {
            var buildEngine = new MockBuildEngine();
            var task        = new PublishArtifactsInManifestV2
            {
                // Create a single Microsoft.Build.Utilities.TaskItem for a simple feed config, then parse to FeedConfigs and
                // check the expected values.
                TargetFeedConfig = new Microsoft.Build.Utilities.TaskItem[]
                {
                    new Microsoft.Build.Utilities.TaskItem(TargetFeedContentType.BinaryLayout.ToString(), new Dictionary <string, string> {
                        { "TargetUrl", BlobFeedUrl },
                        { "Token", RandomToken },
                        { "Type", "AzDoNugetFeed" },
                        { "Internal", "false" }
                    }),
                },
                BuildEngine = buildEngine
            };

            await task.ParseTargetFeedConfigAsync();

            Assert.False(task.Log.HasLoggedErrors);

            // This will have set the feed configs.
            Assert.Collection(task.FeedConfigs,
                              configList =>
            {
                Assert.Equal(TargetFeedContentType.BinaryLayout, configList.Key);
                Assert.Collection(configList.Value, config =>
                {
                    Assert.Equal(RandomToken, config.Token);
                    Assert.Equal(BlobFeedUrl, config.TargetURL);
                    Assert.False(config.Internal);
                    Assert.Equal(FeedType.AzDoNugetFeed, config.Type);
                    Assert.Equal(AssetSelection.All, config.AssetSelection);
                });
            });
        }
Пример #9
0
        public async Task FeedConfigParserTests4Async()
        {
            var buildEngine = new MockBuildEngine();
            var task        = new PublishArtifactsInManifestV2
            {
                TargetFeedConfig = new Microsoft.Build.Utilities.TaskItem[]
                {
                    new Microsoft.Build.Utilities.TaskItem(TargetFeedContentType.BinaryLayout.ToString(), new Dictionary <string, string> {
                        { "TargetUrl", BlobFeedUrl },
                        { "Token", RandomToken },
                        // Use different casing here to make sure that parsing
                        // ignores case.
                        { "Type", "AZURESTORAGEFEED" },
                        { "AssetSelection", "SHIPPINGONLY" },
                        { "Internal", "false" }
                    }),
                },
                BuildEngine = buildEngine
            };

            await task.ParseTargetFeedConfigAsync();

            // This will have set the feed configs.
            Assert.Collection(task.FeedConfigs,
                              configList =>
            {
                Assert.Equal(TargetFeedContentType.BinaryLayout, configList.Key);
                Assert.Collection(configList.Value, config =>
                {
                    Assert.Equal(RandomToken, config.Token);
                    Assert.Equal(BlobFeedUrl, config.TargetURL);
                    Assert.Equal(FeedType.AzureStorageFeed, config.Type);
                    Assert.Equal(AssetSelection.ShippingOnly, config.AssetSelection);
                });
            });
        }