Store Mapping per POST request ignores "IgnoreCase" property of HeaderModel #545

Closed
opened 2025-12-29 08:29:51 +01:00 by adam · 4 comments
Owner

Originally created by @cal-schleupen on GitHub (Sep 26, 2023).

Originally assigned to: @StefH on GitHub.

Describe the bug

When storing a mapping via https://localhost:54544/__admin/mappings using the following request

{
    "Guid": "905dca41-a045-4b63-9298-e0fe956c972b",
    "SaveToFile": true,
    "Title": "mytest",
    "Request": {
        "Path": {
            "Matchers": [
                {
                    "Name": "WildcardMatcher",
                    "Pattern": "/Sample"
                }
            ]
        },
        "Methods": [
            "post"
        ],
				"Headers": [
					{
						"Name": "Content-Type",
						"Matchers": [
							{
								"Name": "WildcardMatcher",
								"Pattern": "text/xml; charset=utf-8",
								"IgnoreCase": true
							}
						],
						"IgnoreCase": true
					},
					{
						"Name": "SOAPAction",
						"Matchers": [
							{
								"Name": "WildcardMatcher",
								"Pattern": "mypattern",
								"IgnoreCase": true
							}
						],
						"IgnoreCase": true
					}
				]
    },
    "Response": {
        "StatusCode": 200,
        "Body": "{ ... }",
        "Headers": {
            "Content-Type": "text/xml"
        }
    }
}

the following mapping is persisted in the file mytest.json:

{
  "Guid": "905dca41-a045-4b63-9298-e0fe956c972b",
  "UpdatedAt": "2023-09-26T11:39:54.6342741Z",
  "Title": "mytest",
  "Request": {
    "Path": {
      "Matchers": [
        {
          "Name": "WildcardMatcher",
          "Pattern": "/Sample",
          "IgnoreCase": false
        }
      ]
    },
    "Methods": [
      "post"
    ],
    "Headers": [
      {
        "Name": "Content-Type",
        "Matchers": [
          {
            "Name": "WildcardMatcher",
            "Pattern": "text/xml; charset=utf-8",
            "IgnoreCase": true
          }
        ]
      },
      {
        "Name": "SOAPAction",
        "Matchers": [
          {
            "Name": "WildcardMatcher",
            "Pattern": "mypattern",
            "IgnoreCase": true
          }
        ]
      }
    ]
  },
  "Response": {
    "StatusCode": 200,
    "Body": "{ ... }",
    "Headers": {
      "Content-Type": "text/xml"
    }
  }
}

Expected behavior:

Expectation: The attribute "IgnoreCase": true of the HeaderModel is stored.

Test to reproduce

See above.

The bug is located in class MappingConverter:

                Headers = headerMatchers.Any() ? headerMatchers.Select(hm => new HeaderModel
                {
                    Name = hm.Name,
                    Matchers = _mapper.Map(hm.Matchers),
// -> is missing                    IgnoreCase = hm.IgnoreCase
                }).ToList() : null,

To me not as important this, the same problem exists with RejectOnMatch, which cannot be solved as easy as IgnoreCase.

Originally created by @cal-schleupen on GitHub (Sep 26, 2023). Originally assigned to: @StefH on GitHub. ### Describe the bug When storing a mapping via https://localhost:54544/__admin/mappings using the following request ``` json { "Guid": "905dca41-a045-4b63-9298-e0fe956c972b", "SaveToFile": true, "Title": "mytest", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/Sample" } ] }, "Methods": [ "post" ], "Headers": [ { "Name": "Content-Type", "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "text/xml; charset=utf-8", "IgnoreCase": true } ], "IgnoreCase": true }, { "Name": "SOAPAction", "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "mypattern", "IgnoreCase": true } ], "IgnoreCase": true } ] }, "Response": { "StatusCode": 200, "Body": "{ ... }", "Headers": { "Content-Type": "text/xml" } } } ``` the following mapping is persisted in the file mytest.json: ``` json { "Guid": "905dca41-a045-4b63-9298-e0fe956c972b", "UpdatedAt": "2023-09-26T11:39:54.6342741Z", "Title": "mytest", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/Sample", "IgnoreCase": false } ] }, "Methods": [ "post" ], "Headers": [ { "Name": "Content-Type", "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "text/xml; charset=utf-8", "IgnoreCase": true } ] }, { "Name": "SOAPAction", "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "mypattern", "IgnoreCase": true } ] } ] }, "Response": { "StatusCode": 200, "Body": "{ ... }", "Headers": { "Content-Type": "text/xml" } } } ``` ### Expected behavior: Expectation: The attribute "IgnoreCase": true of the HeaderModel is stored. ### Test to reproduce See above. ### Other related info The bug is located in class MappingConverter: ``` c# Headers = headerMatchers.Any() ? headerMatchers.Select(hm => new HeaderModel { Name = hm.Name, Matchers = _mapper.Map(hm.Matchers), // -> is missing IgnoreCase = hm.IgnoreCase }).ToList() : null, ``` To me not as important this, the same problem exists with RejectOnMatch, which cannot be solved as easy as IgnoreCase.
adam added the bug label 2025-12-29 08:29:51 +01:00
adam closed this issue 2025-12-29 08:29:51 +01:00
Author
Owner

@StefH commented on GitHub (Sep 26, 2023):

https://github.com/WireMock-Net/WireMock.Net/pull/1004

@StefH commented on GitHub (Sep 26, 2023): https://github.com/WireMock-Net/WireMock.Net/pull/1004
Author
Owner

@StefH commented on GitHub (Sep 26, 2023):

Fixed

@StefH commented on GitHub (Sep 26, 2023): Fixed
Author
Owner

@cal-schleupen commented on GitHub (Sep 27, 2023):

Thanx a lot!

@cal-schleupen commented on GitHub (Sep 27, 2023): Thanx a lot!
Author
Owner

@StefH commented on GitHub (Sep 27, 2023):

New NuGet will be released later today

@StefH commented on GitHub (Sep 27, 2023): New NuGet will be released later today
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#545