public async Task FeedConfigParserTests6Async() { var buildEngine = new MockBuildEngine(); var task = new PublishArtifactsInManifest { 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" }, { "Internal", "true" } }), }, BuildEngine = buildEngine }; await task.ParseTargetFeedConfigAsync(); Assert.True(!task.Log.HasLoggedErrors); }
public async Task FeedConfigParserTests5Async() { var buildEngine = new MockBuildEngine(); var task = new PublishArtifactsInManifest { 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 Assert.True(task.Log.HasLoggedErrors); Assert.Contains(buildEngine.BuildErrorEvents, 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'")); }
public async Task StableAssetCheck1Async(string assetVersion, bool isIsolatedFeed, bool shouldError, bool skipChecks = false) { var buildEngine = new MockBuildEngine(); var task = new PublishArtifactsInManifest { SkipSafetyChecks = skipChecks, TargetFeedConfig = new Microsoft.Build.Utilities.TaskItem[] { new Microsoft.Build.Utilities.TaskItem("PACKAGE", new Dictionary <string, string> { { "TargetUrl", BlobFeedUrl }, { "Token", RandomToken }, { "Type", "AZURESTORAGEFEED" }, { "AssetSelection", "SHIPPINGONLY" }, { "Internal", "false" }, // Feed is not isolated { "Isolated", isIsolatedFeed.ToString() } }) }, BuildEngine = buildEngine }; const string packageId = "Foo.Package"; BuildModel buildModel = new BuildModel(new BuildIdentity()) { Artifacts = new ArtifactSet { Blobs = new List <BlobArtifactModel>(), Packages = new List <PackageArtifactModel> { new PackageArtifactModel() { Id = packageId, Version = assetVersion } } } }; await task.ParseTargetFeedConfigAsync(); Assert.False(task.Log.HasLoggedErrors); task.SplitArtifactsInCategories(buildModel); Assert.False(task.Log.HasLoggedErrors); task.CheckForStableAssets(); Assert.Equal(shouldError, task.Log.HasLoggedErrors); if (shouldError) { Assert.Contains(buildEngine.BuildErrorEvents, e => e.Message.Equals($"Package '{packageId}' has stable version '{assetVersion}' but is targeted at a non-isolated feed '{BlobFeedUrl}'")); } }
public async Task FeedConfigParserTests3Async() { var buildEngine = new MockBuildEngine(); var task = new PublishArtifactsInManifest { 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(); Assert.True(task.Log.HasLoggedErrors); Assert.Contains(buildEngine.BuildErrorEvents, e => e.Message.Equals("Invalid FeedConfig entry. TargetURL='' Type='' Token=''")); }
public async Task FeedConfigParserTests2Async() { var buildEngine = new MockBuildEngine(); var task = new PublishArtifactsInManifest { 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")); }
public async Task FeedConfigParserTests1Async() { var buildEngine = new MockBuildEngine(); var task = new PublishArtifactsInManifest { // 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("FOOPACKAGES", 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("FOOPACKAGES", 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); }); }); }
public async Task FeedConfigParserTests4Async() { var buildEngine = new MockBuildEngine(); var task = new PublishArtifactsInManifest { TargetFeedConfig = new Microsoft.Build.Utilities.TaskItem[] { new Microsoft.Build.Utilities.TaskItem("FOOPACKAGES", 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("FOOPACKAGES", 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); }); }); }