Hi again.
We have another use case that the library doesn't support and would like to discuss if this is something that makes sense to you.
We don't want to store sensitive information in the recordings of our requests (these files are saved in the repository), such as Authorization headers. To make it completely automatic it would be useful to give the client the possibility to choose what to save in the file.
Since headers are not used to create the hash representation, changing headers doesn't really affect the reading of a request from a file.
We can't add that to the normalizedRequest because that request will also be used to make actual calls when recording is turned on.
- Do you think this is something you'd like to support?
- If so, I'd like to ask you what you think about this:
I have basic working solution for this issue, and would like to ask what you think about it.
In the MockDuckDelegate I added a method:
func updateBeforeSaving(_ request: URLRequest) -> URLRequest
Now in the record method:
func record(requestResponse: MockRequestResponse) {
...
if let delegate = MockDuck.delegate {
requestResponse.request = delegate.updateBeforeSaving(requestResponse.request)
}
....
}
This way I can do whatever I want to my request before it is saved.
Potential Issues:
- If the client changes components that are used for hashing, will fail to get recorded requests.
- This would be a breaking change because the protocol would add a new method.
Let me know what you think.
Thanks
Hi again.
We have another use case that the library doesn't support and would like to discuss if this is something that makes sense to you.
We don't want to store sensitive information in the recordings of our requests (these files are saved in the repository), such as
Authorizationheaders. To make it completely automatic it would be useful to give the client the possibility to choose what to save in the file.Since headers are not used to create the hash representation, changing headers doesn't really affect the reading of a request from a file.
We can't add that to the
normalizedRequestbecause that request will also be used to make actual calls when recording is turned on.I have basic working solution for this issue, and would like to ask what you think about it.
In the MockDuckDelegate I added a method:
func updateBeforeSaving(_ request: URLRequest) -> URLRequestNow in the record method:
This way I can do whatever I want to my request before it is saved.
Potential Issues:
Let me know what you think.
Thanks