rest-assured-net: ResponseLogLevel cannot be overridden at a response level
Hey,
We’re using the ability to set the Request and Response by default on all tests to All using the static configuration in the Dsl class, e.g.
RestAssuredConfig = new RestAssuredConfiguration
{
RequestLogLevel = RequestLogLevel.All,
ResponseLogLevel = ResponseLogLevel.All
};
However for some tests we don’t want to log everything, or we want to pass in sensitive headers. So we are attempting to configure logging per test e.g.:
.Log(ResponseLogLevel.None)
This works for the request logging, but not response logging.
It seems we have already logged the response by the time we get the VerifiableResponse back, so when calling Log this has no effect. (https://github.com/basdijkstra/rest-assured-net/blob/8f3a46635ae3a702f8ad4f5e9a4292dcdd25747f/RestAssured.Net/Request/ExecutableRequest.cs#L676)
Could you confirm if my thinking is correct, or if there are any other ways we could do this please? Alternatively I am happy to contribute if you point me in the direction you’d want to take to implement this.
Thanks, Jack
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (10 by maintainers)
@basdijkstra Tested this today and it’s working perfectly for our use case. Thank you!
Addressed in https://github.com/basdijkstra/rest-assured-net/commit/a83796fbd5ca22c846f28c6b320b92233008781a.
@sqh-jack-starkey, I’m releasing 4.5.0 soon (hopefully later today), could you please test this by using the new
Log()method that takes aLogConfiguration(and update yourRequestSpecificationor static RestAssured configuration and let me know if that addresses your logging issues?Please remove all references to obsolete
Log()methods to make sure you don’t get duplicate logging.@sqh-jack-starkey I’ve decided to introduce the breaking change, i.e., I’m going to move the specification of the response log level to the
Given()section. It will simplify the logging logic, too, which is a nice added bonus.I’ll add that to the next release (including deprecating the current methods), which is due to come out soon anyway because I want to add support for .NET 9, too. This means everyone can start moving their
Log()statements to the new place without breaking any existing code yet.Thank you for thinking along here. I appreciate it. I’ll add another comment when this new version released so you can confirm that it now works as expected.
Hey @sqh-jack-starkey, thank you for reporting this. Let me have a good look at it in the next couple of days and see what I can do. It might just be just a matter of incorrect priorities when setting the response log level but I’ll have to dive into that. I’ll get back to you somewhere next week if that’s OK.