question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Help converting a slightly more complex Wiremock.org template

See original GitHub issue

I’m experimenting using this instead of wiremock.org and am doing some POC stuff. I’ve hit a couple of problems with Body matching using XPath, and I could use some guidance on how to accomplish the response request->response items and dynamically created response parts. I have a template here (cnp.json config.zip ) and a partially converted one along with what to post. https://localhost:9443/vap/communicator/online

The current issue is that my XPath matching rules both have to fail for it to fail to match, but I need ANY rule to cause it to fail. As it stands, if I change one of the values in the post but not the second it still says it’s a match. Also, any help with building the response would be great.

cnp.json

{
	"Title": "Authorization",
	"Request": {
		"Path": {
			"Matchers": [
				{
					"Name": "WildcardMatcher",
					"Pattern": "/vap/communicator/online"
				}
			]
		},
		"Methods": [
			"post"
		],
		"Body": {
			"Matchers": [
				{
					"Name": "XPathMatcher",
					"Pattern": "//*[local-name() = 'amount']/text() = 100000"
				},
				{
					"Name": "XPathMatcher",
					"Pattern": "//*[local-name() = 'name']/text() = 'Jane John'"
				}
			]
		}
	},
	"Response": {
		"StatusCode": 200,
		"Body": "<xml>ok</xml>",
		"UseTransformer": false,
		"Headers": {
			"Content-Type": "application/xml"
		}
	}
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mattiskingcommented, May 20, 2022

I will be testing it this weekend. Overwhelmed with a large release the past few days. Thanks a lot for looking into this.

0reactions
StefHcommented, Jun 11, 2022

Maybe a good use case to build this in .net Maui 😀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mock API Response Templating
This enables attributes of the request to be used in generating the response e.g. to pass the value of a request ID header...
Read more >
Returning stubbed HTTP responses to specific requests
A core feature of WireMock is the ability to return canned HTTP responses for requests matching criteria. These are described in detail in...
Read more >
WireMock API Templates Library
The library.wiremock.org site provides a catalog of API Templates that can be used with both WireMock or WireMock Cloud.
Read more >
WireMock Overview and Basics
WireMock is a popular open-source tool for API mock testing with over 5 million downloads per month. It can help you to create...
Read more >
Extending WireMock via custom code
Via WireMock's extension mechanism it is possible to dynamically modify responses, allowing header re-writing and templated responses amongst other things.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found