-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Externalize parsing of access token response #79
Conversation
@@ -544,6 +662,8 @@ class HeimdallrSpec: QuickSpec { | |||
}, withStubResponse: { request in | |||
return OHHTTPStubsResponse(data: NSData(contentsOfFile: self.bundle.pathForResource("request-valid", ofType: "json")!)!, statusCode: 200, headers: [ "Content-Type": "application/json" ]) | |||
}) | |||
|
|||
accessTokenParser.reset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the reset here? If I comment this line out, the test still succeeds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bckr: the test succeeds because the first request (that returns an expired access token) already triggered the flag. The reset is there to ensure that the parser is called a second time with the second request. If this is too fragile I can change the flag for a counter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think the current way doesn't really verify that it is only called once for the initial request. I think a counter would work here. We could also think about introducing Dobby here for recording the invocations. What do you think @hffmnn?
Update: If you want to have a look at Dobby for simple invocation recording, feel free to add it as a dependency and try it out. I would also be fine with a counter 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I'll update the PR ASAP!
@poislagarde Thank you very much for the quick pull request 🎉 At a first glance I would say that this seams like a good approach of externalising the access token parsing. I've made a few notes on code that might need a bit of fine tuning. Maybe one of the other team members want to have a look at this as well. |
Hey @bckr, I answered to your notes. Let me know if you want me to make those changes or not. Thanks! |
Sorry for the delay. I pushed and squashed the changes we talked about. Let me know if you need me to change something else. |
@poislagarde Nice work! I think we can merge this 🚀 |
Closes #76