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