Topic: How to test HTTP-authenticated controller?

Let's say I have three files. For simplicity's sake, I'll include only one action to test.

1. admin_controller.rb, which provides the authentication

class AdminController < ApplicationController
  USERNAME = "username"
  PASSWORD = "password"

  before_filter :authenticate

  private
  
  def authenticate
    authenticate_or_request_with_http_basic do |username, password|
      username == USERNAME && password == PASSWORD
    end
  end
end

2. posts_controller.rb, which inherits from admin_controller.rb

class PostsController < AdminController
  # GET /posts
  # GET /posts.xml
  def index
    @posts = Post.find(:all, :order => "created_at DESC", :limit => 10)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @posts }
    end
  end
end

3. posts_controller_test.rb, which tests posts_controller.rb

require 'test_helper'

class ArtworksControllerTest < ActionController::TestCase
  test "should get index" do
    get :index
    assert_response :success
    assert_not_nil assigns(:artworks)
  end
end

Now whenever I run

ruby functional/posts_controller_test.rb -n test_should_get_index

the test would fail with a HTML 401 (unauthorised) response. Here's what I get at the end of the error message.

Expected response to be a <:success>, but was <401>

What should I do to make the test pass?