Functional test for HTTP Basic Authentication in Rails 2
If you want to provide a username and password for a HTTP Basic Authentication in one of your functional tests, simply use the following:
def test_should_get_index
@request.env["HTTP_AUTHORIZATION"] = “Basic ” + Base64::encode64(“username:password”)
get :index
assert_response :success
assert_not_nil assigns(:articles)
end
Keywords: rails test, functionals, authorization, basic http authentication, how to test
Filed under: English, Rails 2.0, Rails 2.1, Ruby, Ruby 1.8, Ruby On Rails on Juni 23rd, 2008 | 5 Comments »
