Testing HTTP Authentication
Created at: 01.07.2009 04:44, source: Rail Spikes - Home , tagged: testing tips
If you ever need to test HTTP Authentication in your functional tests, here is how you do it:
1 2 3 4 5 6 |
def test_http_auth @request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials("quentin", "password") get :show, :id => @foobar.id assert_response :success end |
This is much like testing SSL.
Hat tip: Philipp Führer for Functional test for HTTP Basic Authentication in Rails 2.
