##// END OF EJS Templates
Test cleanup....
Jean-Philippe Lang -
r8356:395fe0d777f2
parent child
Show More
@@ -41,8 +41,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
41 41 context "with a valid HTTP authentication" do
42 42 setup do
43 43 @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password')
44 @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'my_password')
45 get "/news.xml", nil, :authorization => @authorization
44 get "/news.xml", nil, :authorization => credentials(@user.login, 'my_password')
46 45 end
47 46
48 47 should_respond_with :unauthorized
@@ -56,8 +55,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
56 55 setup do
57 56 @user = User.generate_with_protected!
58 57 @token = Token.generate!(:user => @user, :action => 'api')
59 @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'X')
60 get "/news.xml", nil, :authorization => @authorization
58 get "/news.xml", nil, :authorization => credentials(@token.value, 'X')
61 59 end
62 60
63 61 should_respond_with :unauthorized
@@ -86,8 +84,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
86 84 context "with a valid HTTP authentication" do
87 85 setup do
88 86 @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password')
89 @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'my_password')
90 get "/news.json", nil, :authorization => @authorization
87 get "/news.json", nil, :authorization => credentials(@user.login, 'my_password')
91 88 end
92 89
93 90 should_respond_with :unauthorized
@@ -101,8 +98,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
101 98 setup do
102 99 @user = User.generate_with_protected!
103 100 @token = Token.generate!(:user => @user, :action => 'api')
104 @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'DoesNotMatter')
105 get "/news.json", nil, :authorization => @authorization
101 get "/news.json", nil, :authorization => credentials(@token.value, 'DoesNotMatter')
106 102 end
107 103
108 104 should_respond_with :unauthorized
@@ -244,8 +244,7 class ActiveSupport::TestCase
244 244 context "with a valid HTTP authentication" do
245 245 setup do
246 246 @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password', :admin => true) # Admin so they can access the project
247 @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'my_password')
248 send(http_method, url, parameters, {:authorization => @authorization})
247 send(http_method, url, parameters, {:authorization => credentials(@user.login, 'my_password')})
249 248 end
250 249
251 250 should_respond_with success_code
@@ -258,8 +257,7 class ActiveSupport::TestCase
258 257 context "with an invalid HTTP authentication" do
259 258 setup do
260 259 @user = User.generate_with_protected!
261 @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'wrong_password')
262 send(http_method, url, parameters, {:authorization => @authorization})
260 send(http_method, url, parameters, {:authorization => credentials(@user.login, 'wrong_password')})
263 261 end
264 262
265 263 should_respond_with failure_code
@@ -301,8 +299,7 class ActiveSupport::TestCase
301 299 setup do
302 300 @user = User.generate_with_protected!(:admin => true)
303 301 @token = Token.generate!(:user => @user, :action => 'api')
304 @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'X')
305 send(http_method, url, parameters, {:authorization => @authorization})
302 send(http_method, url, parameters, {:authorization => credentials(@token.value, 'X')})
306 303 end
307 304
308 305 should_respond_with success_code
@@ -317,8 +314,7 class ActiveSupport::TestCase
317 314 setup do
318 315 @user = User.generate_with_protected!
319 316 @token = Token.generate!(:user => @user, :action => 'feeds')
320 @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'X')
321 send(http_method, url, parameters, {:authorization => @authorization})
317 send(http_method, url, parameters, {:authorization => credentials(@token.value, 'X')})
322 318 end
323 319
324 320 should_respond_with failure_code
General Comments 0
You need to be logged in to leave comments. Login now