Mercurial > hg > soundsoftware-site
diff test/integration/api_test/authentication_test.rb @ 1526:404aa68d4227
Merge from live branch
author | Chris Cannam |
---|---|
date | Thu, 11 Sep 2014 12:46:20 +0100 |
parents | dffacf8a6908 |
children |
line wrap: on
line diff
--- a/test/integration/api_test/authentication_test.rb Mon Mar 17 08:57:04 2014 +0000 +++ b/test/integration/api_test/authentication_test.rb Thu Sep 11 12:46:20 2014 +0100 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2012 Jean-Philippe Lang +# Copyright (C) 2006-2014 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,7 +17,7 @@ require File.expand_path('../../../test_helper', __FILE__) -class ApiTest::AuthenticationTest < ActionController::IntegrationTest +class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base fixtures :users def setup @@ -28,6 +28,29 @@ Setting.rest_api_enabled = '0' end + def test_api_should_trigger_basic_http_auth_with_basic_authorization_header + ApplicationController.any_instance.expects(:authenticate_with_http_basic).once + get '/users/current.xml', {}, credentials('jsmith') + assert_response 401 + end + + def test_api_should_not_trigger_basic_http_auth_with_non_basic_authorization_header + ApplicationController.any_instance.expects(:authenticate_with_http_basic).never + get '/users/current.xml', {}, 'HTTP_AUTHORIZATION' => 'Digest foo bar' + assert_response 401 + end + + def test_invalid_utf8_credentials_should_not_trigger_an_error + invalid_utf8 = "\x82" + if invalid_utf8.respond_to?(:force_encoding) + invalid_utf8.force_encoding('UTF-8') + assert !invalid_utf8.valid_encoding? + end + assert_nothing_raised do + get '/users/current.xml', {}, credentials(invalid_utf8, "foo") + end + end + def test_api_request_should_not_use_user_session log_user('jsmith', 'jsmith')