internal void ExtractHeaderTags_EmptyHeadersReturnsEmptyTagsList(IHeadersCollection headers) { var tagsFromHeader = headers.ExtractHeaderTags(new Dictionary <string, string>(), TestPrefix); Assert.NotNull(tagsFromHeader); Assert.Empty(tagsFromHeader); }
internal void ExtractHeaderTags_MatchesCaseInsensitive(IHeadersCollection headers) { // Initialize constants const string customHeader1Name = "dd-custom-header1"; const string customHeader1Value = "match1"; const string customHeader1TagName = "custom-header1-tag"; const string customHeader2Name = "DD-CUSTOM-HEADER-MISMATCHING-CASE"; const string customHeader2Value = "match2"; const string customHeader2TagName = "custom-header2-tag"; string customHeader2LowercaseHeaderName = customHeader2Name.ToLowerInvariant(); // Add headers headers.Add(customHeader1Name, customHeader1Value); headers.Add(customHeader2Name, customHeader2Value); // Initialize header-tag arguments and expectations var headerTags = new Dictionary <string, string>(); headerTags.Add(customHeader1Name, customHeader1TagName); headerTags.Add(customHeader2LowercaseHeaderName, customHeader2TagName); var expectedResults = new Dictionary <string, string>(); expectedResults.Add(customHeader1TagName, customHeader1Value); expectedResults.Add(customHeader2TagName, customHeader2Value); // Test var tagsFromHeader = headers.ExtractHeaderTags(headerTags, TestPrefix); // Assert Assert.NotNull(tagsFromHeader); Assert.Equal(expectedResults, tagsFromHeader); }
internal void ExtractHeaderTags_ForEmptyStringMappings_CreatesNormalizedTagWithPrefix(IHeadersCollection headers) { string invalidCharacterSequence = "*|&#$%&^`."; string normalizedReplacementSequence = new string('_', invalidCharacterSequence.Length); // Add headers headers.Add("x-header-test-runner", "xunit"); headers.Add($"x-header-1DATADOG-{invalidCharacterSequence}", "true"); // Initialize header-tag arguments and expectations var headerToTagMap = new Dictionary <string, string> { { "x-header-test-runner", string.Empty }, { $"x-header-1DATADOG-{invalidCharacterSequence}", string.Empty }, }; var expectedResults = new Dictionary <string, string> { { TestPrefix + "." + "x-header-test-runner", "xunit" }, { TestPrefix + "." + $"x-header-1datadog-{normalizedReplacementSequence}", "true" } }; // Test var tagsFromHeader = headers.ExtractHeaderTags(headerToTagMap, TestPrefix); // Assert Assert.NotNull(tagsFromHeader); Assert.Equal(expectedResults, tagsFromHeader); }
internal void ExtractHeaderTags_EmptyHeaderTags_AddsNoTags(IHeadersCollection headers) { // Add headers headers.Add("x-header-test-runner", "xunit"); // Initialize header-tag arguments and expectations var headerToTagMap = new Dictionary <string, string>(); var expectedResults = new Dictionary <string, string>(); // Test var tagsFromHeader = headers.ExtractHeaderTags(headerToTagMap, TestPrefix); // Assert Assert.NotNull(tagsFromHeader); Assert.Equal(expectedResults, tagsFromHeader); }