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
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
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
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
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
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
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
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