VCR and HTTP errors (401)

178 views
Skip to first unread message

Chris Kilmer

unread,
Feb 8, 2013, 1:58:27 PM2/8/13
to VCR Rubygem
I am trying to test how my app responds to basic_auth response. VCR
writes a cassette successfully when I get a 200. However, when basic
auth fails and I get a 401, not file is written with the response.

My URIs are different, so it's not recording over the same file.

https://XXX:BBB@http://www.example.com

https://YYY:CCC@http://www.example.com

I'm using Rspec2, VCR, Webmock and HTTP Client.

Any help would be most appreciated.

Myron Marston

unread,
Feb 8, 2013, 2:12:43 PM2/8/13
to vcr-...@googlegroups.com
There's nothing in VCR that treats responses differently by status code, although you can certainly configure it to do so.  It's next-to-impossible for us to guess what your problem is with the small amount of information you've given us.

Can you come up with an reproducible example we can play with?

You might also try VCR's debug logger option:


That should give you insight into exactly what VCR is doing, and will hopefully give you a clue as to the puzzling behavior you're seeing.

HTH,
Myron



--
You received this message because you are subscribed to the Google Groups "VCR Rubygem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vcr-ruby+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Chris Kilmer

unread,
Feb 8, 2013, 3:02:48 PM2/8/13
to VCR Rubygem
Hi Myron,
That's answer my first question. Does VCR handle status codes
differnently? No.

My vcr log for the problematic request looks like this:

[Cassette: 'credential_check/invalid_me'] Initialized with options:
{:record=>:once, :match_requests_on=>[:method, :uri], :allow_unused_http_interactions=>true, :serialize_with=>:yaml, :persist_with=>:file_system}
[webmock] Handling request: [get https://abcd:X...@dj4paws.highrisehq.com/me.xml]
(disabled: false)
[Cassette: 'credential_check/invalid_me'] Initialized
HTTPInteractionList with request matchers [:method, :uri] and 0
interaction(s): { }
[webmock] Identified request type (recordable) for [get
https://abcd:X...@dj4paws.highrisehq.com/me.xml]
[webmock] Handling request: [get https://abcd:X...@dj4paws.highrisehq.com/me.xml]
(disabled: false)
[webmock] Identified request type (recordable) for [get
https://abcd:X...@dj4paws.highrisehq.com/me.xml]
[webmock] Handling request: [get https://abcd:X...@dj4paws.highrisehq.com/me.xml]
(disabled: false)
[webmock] Identified request type (recordable) for [get
https://abcd:X...@dj4paws.highrisehq.com/me.xml]
[webmock] Handling request: [get https://abcd:X...@dj4paws.highrisehq.com/me.xml]
(disabled: false)
[webmock] Identified request type (recordable) for [get
https://abcd:X...@dj4paws.highrisehq.com/me.xml]
[webmock] Handling request: [get https://abcd:X...@dj4paws.highrisehq.com/me.xml]
(disabled: false)
[webmock] Identified request type (recordable) for [get
https://abcd:X...@dj4paws.highrisehq.com/me.xml]
[webmock] Handling request: [get https://abcd:X...@dj4paws.highrisehq.com/me.xml]
(disabled: false)
[webmock] Identified request type (recordable) for [get
https://abcd:X...@dj4paws.highrisehq.com/me.xml]
[webmock] Handling request: [get https://abcd:X...@dj4paws.highrisehq.com/me.xml]
(disabled: false)
[webmock] Identified request type (recordable) for [get
https://abcd:X...@dj4paws.highrisehq.com/me.xml]
[webmock] Handling request: [get https://abcd:X...@dj4paws.highrisehq.com/me.xml]
(disabled: false)
[webmock] Identified request type (recordable) for [get
https://abcd:X...@dj4paws.highrisehq.com/me.xml]
[webmock] Handling request: [get https://abcd:X...@dj4paws.highrisehq.com/me.xml]
(disabled: false)
[webmock] Identified request type (recordable) for [get
https://abcd:X...@dj4paws.highrisehq.com/me.xml]
[webmock] Handling request: [get https://abcd:X...@dj4paws.highrisehq.com/me.xml]
(disabled: false)
[webmock] Identified request type (recordable) for [get
https://abcd:X...@dj4paws.highrisehq.com/me.xml]

When I curl, I get this:

curl -g -v https://abcd:X...@dj4paws.highrisehq.com/me.xml

< HTTP/1.1 401 Unauthorized
< Server: nginx
< Date: Fri, 08 Feb 2013 20:00:23 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 27
< Connection: keep-alive
< Status: 401 Unauthorized
< X-Throttle-Max: 500
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="Application"
< X-Throttle-Count: 1
< X-Throttle-Horizon: 2013-02-08T20:00:30Z
< X-Runtime: 8
< X-Request-Id: 5ac0ab7f-9778-4779-a846-02dcfd6a08b0
< Cache-Control: no-cache
< Strict-Transport-Security: max-age=31536000
<
HTTP Basic: Access denied.
* Connection #0 to host dj4paws.highrisehq.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):




On Feb 8, 12:12 pm, Myron Marston <myron.mars...@gmail.com> wrote:
> There's nothing in VCR that treats responses differently by status code,
> although you can certainly configure it to do so.  It's next-to-impossible
> for us to guess what your problem is with the small amount of information
> you've given us.
>
> Can you come up with an reproducible example we can play with?
>
> You might also try VCR's debug logger option:
>
> https://relishapp.com/vcr/vcr/v/2-4-0/docs/configuration/debug-logging
>
> That should give you insight into exactly what VCR is doing, and will
> hopefully give you a clue as to the puzzling behavior you're seeing.
>
> HTH,
> Myron
>
> On Fri, Feb 8, 2013 at 10:58 AM, Chris Kilmer
> <christopherkil...@gmail.com>wrote:

Myron Marston

unread,
Feb 12, 2013, 2:11:24 AM2/12/13
to VCR Rubygem
We don't have any way to debug your problem remotely, particularly
with such a little bit of info. VCR doesn't do anything special for
any status codes. It's hard to guess what the problem could be
without seeing an example we can play with. I encourage you to dig
into VCR's source as necessary to understand what's going on.

Myron
Reply all
Reply to author
Forward
0 new messages