]> source.dussan.org Git - redmine.git/commitdiff
Test cleanup.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 2 Jan 2012 19:49:51 +0000 (19:49 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 2 Jan 2012 19:49:51 +0000 (19:49 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8476 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/integration/api_test/disabled_rest_api_test.rb
test/test_helper.rb

index 798b7973c0f182f71438e3a33c715b83d5a8ec48..22029b9a46e24ecb3a431ffb3dbfdd144fb59e9c 100644 (file)
@@ -41,8 +41,7 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
       context "with a valid HTTP authentication" do
         setup do
           @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password')
-          @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'my_password')
-          get "/news.xml", nil, :authorization => @authorization
+          get "/news.xml", nil, :authorization => credentials(@user.login, 'my_password')
         end
 
         should_respond_with :unauthorized
@@ -56,8 +55,7 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
         setup do
           @user = User.generate_with_protected!
           @token = Token.generate!(:user => @user, :action => 'api')
-          @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'X')
-          get "/news.xml", nil, :authorization => @authorization
+          get "/news.xml", nil, :authorization => credentials(@token.value, 'X')
         end
 
         should_respond_with :unauthorized
@@ -86,8 +84,7 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
       context "with a valid HTTP authentication" do
         setup do
           @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password')
-          @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'my_password')
-          get "/news.json", nil, :authorization => @authorization
+          get "/news.json", nil, :authorization => credentials(@user.login, 'my_password')
         end
 
         should_respond_with :unauthorized
@@ -101,8 +98,7 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
         setup do
           @user = User.generate_with_protected!
           @token = Token.generate!(:user => @user, :action => 'api')
-          @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'DoesNotMatter')
-          get "/news.json", nil, :authorization => @authorization
+          get "/news.json", nil, :authorization => credentials(@token.value, 'DoesNotMatter')
         end
 
         should_respond_with :unauthorized
index c0947efc358b1b06a40c3d69e83bb1862b5abd37..16afd6a79b844f7bb7a3f28295b9a3646583b7d4 100644 (file)
@@ -244,8 +244,7 @@ class ActiveSupport::TestCase
       context "with a valid HTTP authentication" do
         setup do
           @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password', :admin => true) # Admin so they can access the project
-          @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'my_password')
-          send(http_method, url, parameters, {:authorization => @authorization})
+          send(http_method, url, parameters, {:authorization => credentials(@user.login, 'my_password')})
         end
 
         should_respond_with success_code
@@ -258,8 +257,7 @@ class ActiveSupport::TestCase
       context "with an invalid HTTP authentication" do
         setup do
           @user = User.generate_with_protected!
-          @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'wrong_password')
-          send(http_method, url, parameters, {:authorization => @authorization})
+          send(http_method, url, parameters, {:authorization => credentials(@user.login, 'wrong_password')})
         end
 
         should_respond_with failure_code
@@ -301,8 +299,7 @@ class ActiveSupport::TestCase
         setup do
           @user = User.generate_with_protected!(:admin => true)
           @token = Token.generate!(:user => @user, :action => 'api')
-          @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'X')
-          send(http_method, url, parameters, {:authorization => @authorization})
+          send(http_method, url, parameters, {:authorization => credentials(@token.value, 'X')})
         end
 
         should_respond_with success_code
@@ -317,8 +314,7 @@ class ActiveSupport::TestCase
         setup do
           @user = User.generate_with_protected!
           @token = Token.generate!(:user => @user, :action => 'feeds')
-          @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'X')
-          send(http_method, url, parameters, {:authorization => @authorization})
+          send(http_method, url, parameters, {:authorization => credentials(@token.value, 'X')})
         end
 
         should_respond_with failure_code