Add a signed method to ActiveSupport::TestCase#67
Add a signed method to ActiveSupport::TestCase#67kevintyll wants to merge 5 commits intomgomes:masterfrom
Conversation
…n requests so controller tests can be written when api_auth is used to authenticate.
I can see why you don't want to "short-circuit the security layer" but what about stubbing the |
|
Also, |
Wouldn't the request spec have the same problem of signing the request? Where would it get signed in the request spec? I'll commit a fix for rails 2.3.2. |
…the file unless Rails 3 or higher.
… gem is in a Rails app.
|
Any update on this? |
When api_auth is used for authentication, you can no longer write controller tests without mocking or stubbing your authenticate method, but this may hide some bugs or unexpected behavior and short circuits the security layer of your API.
You can't sign the request directly in you test because before you call your action because headers aren't set yet so authentication will still fail.
I've added a signed method that accepts the access_id and secret_key as parameters and will sign the request after the headers have been set. I modeled it after the xhr method, so you you have to pass the verb as well.