Skip to content
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

Can Bypass be used for API calls that use Digest Auth? #84

Open
ggwc82 opened this issue Nov 13, 2019 · 2 comments
Open

Can Bypass be used for API calls that use Digest Auth? #84

ggwc82 opened this issue Nov 13, 2019 · 2 comments

Comments

@ggwc82
Copy link

ggwc82 commented Nov 13, 2019

I'm trying to use Bypass in my tests to return two different responses in quick succession. The only difference between the two requests is the Authentication headers; I may be wrong, but from reading the docs it doesn't look like Bypass differentiates responses based on this?

The reason for this is because the API I'm trying to test an API that relies on Digest Authentication, where an initial call to the endpoint returns a 401 Unauthorized with a nonce and realm. The second call involves using this nonce and realm, along with credentials to authenticate, after which a 200/201 is returned.

Is this something I can test with Bypass, or should I use something like Mox instead?

@VitorTrin
Copy link
Contributor

You could let the bypass expect both requests in the same Bypass.expect, and inside the function differentiate based on the header using something like

if Conn.get_req_header( ...) == ....
  resp(200, ...
else
  resp(401, ...
end

@ream88
Copy link
Collaborator

ream88 commented Apr 20, 2020

As this happened to myself as well, I think we should include a proper example in the Readme.

/cc @MSch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants