Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9042139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:24:44+00:00 2026-06-16T10:24:44+00:00

I have a pretty basic HTTP Digest Authentication setup on my Rails 3 app.

  • 0

I have a pretty basic HTTP Digest Authentication setup on my Rails 3 app. It mostly follows examples found in the Rails Controller Guide:

My ApplicationController has a before_filter:

def digest_authenticate
  success = authenticate_or_request_with_http_digest("Application") do |username|
    APP_CONFIG["admin"]
  end
end

This all works great. Pages are protected as they should be.

I’m now trying to test this in RSpec and failing miserably.

I followed this SO accepted answer and put the authenticate_with_http_digest method in a support file. Here’s my actual test:

describe DashboardController do
  describe "GET 'index'" do
    it "returns http success" do
      authenticate_with_http_digest(foo, bar, baz)

      visit root_path
      response.should be_success
      response.code.should == '200'
    end
  end
end

A few problems:

  1. The tests are passing every time, whether or not I call authenticate_with_http_digest
  2. The arguments I’m passing to authenticate_with_http_digest are bogus, and don’t seem to matter. Shouldn’t these need to match what I have stored in APP_CONFIG["admin"]?
  3. If I print out the value of success from my digest_authenticate before_filter, it always prints out 401, even if I do pass the correct parameters to my rspec helper.

Any ideas how to effectively test HTTP Digest Authentication?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:24:45+00:00Added an answer on June 16, 2026 at 10:24 am

    For controller tests you should use the get :index call rather than the visit root_path call. This will work for any valid combination of HTTP verbs and Rails actions you are controller testing.

    The visit method is part of Capybara and should be used in request specs only.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that communicates with a server that uses HTTP Digest authentication.
I have a pretty basic setup of a map with openlayers, and just 3
This a pretty basic question. Let's say I have this iPhone/iPad app that, at
Having just implemented this, I have a pretty basic question about how authentication and
I have this pretty basic view: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent
I have a pretty basic tiles1 setup with header, menu, and content as so:
I might have pretty basic question about regex. I have the following regex, which
I have a pretty basic challenge-based iPhone game, and I wanted to know what
I have a pretty basic doubt on dirty read/writes to a value stored in
I have a pretty basic problem but I can't seem to figure it out...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.