# Testing authentication with basic\_auth

**URL:** <https://www.ruby-forum.com/t/testing-authentication-with-basic-auth/191275>\
**Category:** Rails\
**Created:** [July 8, 2010, 6:22pm UTC](https://www.ruby-forum.com/t/testing-authentication-with-basic-auth/191275 "2010-07-08T18:22:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [July 8, 2010, 6:22pm UTC](https://www.ruby-forum.com/t/testing-authentication-with-basic-auth/191275/1 "2010-07-08T18:22:33Z")

</div>

hi, I’ve got an api which is using  
authenticate\_or\_request\_with\_http\_basic

What are you guys using to test this? I’m using rspec, and before I  
was using rspec-rails, I was using authorize from Rack::Test to do the  
authentication. However, authorize clearly doesn’t work when using  
rspec-rails, so I’m wondering what everyone else is doing?

---

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [July 9, 2010, 9:24am UTC](https://www.ruby-forum.com/t/testing-authentication-with-basic-auth/191275/2 "2010-07-09T09:24:02Z")

</div>

Download the Rails source code from Github and look at  
the http\_basic\_authentication\_test.rb to see how to test http basic  
authentication.

In general read the source code of popular plugins, you will learn how  
they  
solve common problems.

Cheers,  
Bala  
RoR Developer Now Available for Hire

On Thu, Jul 8, 2010 at 9:21 AM, anywho [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> “Ruby on Rails: Talk” group.  
> To post to this group, send email to removed\_email\_address@domain.invalid.  
> To unsubscribe from this group, send email to  
> removed\_email\_address@domain.invalid[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> .  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
[http://www.rubyplus.org/](http://www.rubyplus.org/)  
Free Ruby and Rails Screencasts

---

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [July 30, 2010, 5:28am UTC](https://www.ruby-forum.com/t/testing-authentication-with-basic-auth/191275/3 "2010-07-30T05:28:11Z")

</div>

Thanks but that didn’t help. I’ve followed the documentation here:

> **[rails.info](http://api.rails.info/classes/ActionController/HttpAuthentication/Basic.html#M000214)**
>
> Ruby on Rails,Rails Tutorial,Ruby Basics,Rails 4,Bar Rails,Rail

I don’t understand why authorize broke, but nothing else I try seems  
to work either. Help is appriciated.

---

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [July 30, 2010, 7:04am UTC](https://www.ruby-forum.com/t/testing-authentication-with-basic-auth/191275/4 "2010-07-30T07:04:45Z")

</div>

here we go… I filed this ticket:

[https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5246](https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5246)

---

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [July 30, 2010, 5:32am UTC](https://www.ruby-forum.com/t/testing-authentication-with-basic-auth/191275/5 "2010-07-30T05:32:17Z")

</div>

I should probably mention that this is with rails3 and the file you  
refer to doesn’t exist in rails3
