Add ability to use auth header as part of file name #38
Add ability to use auth header as part of file name #38designatednerd wants to merge 7 commits intovokal:masterfrom
Conversation
VOKMockUrlProtocol.m
Outdated
| if (authHeader) { | ||
| NSString *encodedHeader = [authHeader stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | ||
| NSString *authString = [NSString stringWithFormat:@"&authorization=%@", encodedHeader]; | ||
| [resourceName appendString:authString]; |
There was a problem hiding this comment.
@vokal-isaac Pretty sure there's more I should be doing here in terms of sha256'ing this to work better with the bEncoding stuff, but I'm not 100% clear on what I need to do here to make it work. Any direction would be most appreciated.
|
Build errored, but tests are passing locally, fwiw. I believe if someone kicks the build it'll pass. |
|
Since this affects the names of the mock data files, the change should be documented in MockDataNaming.md. I think the way you're doing it, a request that had an |
|
Ah, good catch on the mock naming file. Once we hammer this out I'll update that as well. I'd like to restrict which headers actually contribute to the filename, so that not every single header winds up as part of the filename for files where we want this. To narrow that down, how about changing the BOOL to an array of Strings which are HTTP header fields? Then, we can use the field names as keys and values as...values. Trying to think of a good way to split out the headers from the query params and the JSON keys/values, and coming up a little blank. Any suggestions? |
|
The current naming is something like I'm not sure there's a way to add a (Having the |
|
@vokal-isaac Take a look at my proposed change here - This adds an additional pipe-separated section specifically for any headers if headers are expected. If you think it'd be useful from a readability I could also add some kind of indicator of whether a given section is the headers section (maybe |
| { | ||
| [self verifyRequestWithURLString:@"http://example.com/DoesntExist.html" | ||
| additionalHeaders:nil | ||
| bodyData:nil |
There was a problem hiding this comment.
Would it make sense to have a convenience wrapper method like
- (void)verifyRequestWithURLString:(NSString *)urlString
completion:(void (^)(NSData *data, NSHTTPURLResponse *response, NSError *error))completion
{
[self verifyRequestWithURLString:urlString
additionalHeaders:nil
bodyData:nil
completion:completion];
}to avoid adding these two lines in a bunch of places?
|
Still need to update MockDataNaming.md. |
|
One day I'll come back to this, I swear. It's literally been on my todo list for months. |
Allows verification of auth header if the consumer so desires.