diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-07-06 12:00:26 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-07-06 12:00:26 +0100 |
commit | 732b3e5c430a83f72adb44dc621d48edb86f081f (patch) | |
tree | 63e77046c96d31081579853decc1b8cef2affc94 /spec/spec_helper.rb | |
parent | 737f5967131120adab322adf3dbdbd4f40426499 (diff) |
fix up basic auth for admin settings: get credentials from config, cause default (where no config) to skip authorization completely, add tests for these
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ceb566680..56b1fd92a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,6 +5,11 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environ require 'spec/autorun' require 'spec/rails' +# set a default username and password so we can test +config = MySociety::Config.load_default() +config['ADMIN_USERNAME'] = 'foo' +config['ADMIN_PASSWORD'] = 'baz' + # Uncomment the next line to use webrat's matchers #require 'webrat/integrations/rspec-rails' @@ -104,8 +109,8 @@ def validate_as_body(html) end def basic_auth_login(request) - username = MySociety::Config.get('ADMIN_USERNAME', '') - password = MySociety::Config.get('ADMIN_PASSWORD', '') + username = MySociety::Config.get('ADMIN_USERNAME') + password = MySociety::Config.get('ADMIN_PASSWORD') request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("#{username}:#{password}") end |