# testing authentication with basic\_auth

**URL:** <https://discuss.rubyonrails.org/t/testing-authentication-with-basic-auth/52825>\
**Category:** rubyonrails-talk\
**Created:** [July 8, 2010, 4:21pm UTC](https://discuss.rubyonrails.org/t/testing-authentication-with-basic-auth/52825 "2010-07-08T16:21:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anywho](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@anywho](https://discuss.rubyonrails.org/u/anywho)\
**Post date:** [July 8, 2010, 4:21pm UTC](https://discuss.rubyonrails.org/t/testing-authentication-with-basic-auth/52825/1 "2010-07-08T16:21:03Z")

</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:** ![Bala\_Paranj](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@Bala\_Paranj](https://discuss.rubyonrails.org/u/Bala_Paranj)\
**Post date:** [July 8, 2010, 11:57pm UTC](https://discuss.rubyonrails.org/t/testing-authentication-with-basic-auth/52825/2 "2010-07-08T23:57:38Z")

</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

---

<div class="post-metadata">

**Author:** ![anywho](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@anywho](https://discuss.rubyonrails.org/u/anywho)\
**Post date:** [July 30, 2010, 3:27am UTC](https://discuss.rubyonrails.org/t/testing-authentication-with-basic-auth/52825/3 "2010-07-30T03:27:04Z")

</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://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@anywho](https://discuss.rubyonrails.org/u/anywho)\
**Post date:** [July 30, 2010, 3:31am UTC](https://discuss.rubyonrails.org/t/testing-authentication-with-basic-auth/52825/4 "2010-07-30T03:31:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anywho](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@anywho](https://discuss.rubyonrails.org/u/anywho)\
**Post date:** [July 30, 2010, 5:03am UTC](https://discuss.rubyonrails.org/t/testing-authentication-with-basic-auth/52825/5 "2010-07-30T05:03:35Z")

</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)
