As part of an API I am building, there is a user authentication method which upon success, returns a payload of useful user information, API token, etc.
In writing functional tests for the controller that handles this, I am running in to an issue testing HTTP Basic auth; I have found numerous blogs that mention the following code should be used to spoof headers for an authentication attempt:
@request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(email, pass)
The issue is that this has no effect; authenticate_with_http_basic
does not see the headers and therefore is returning false even in the presence of valid credentials.
Am I missing something?
Note that the app is frozen to Rails 2.2.2 if that is useful in answering.