Mercurial > hg > soundsoftware-site
comparison test/integration/api_test/authentication_test.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
| author | Chris Cannam |
|---|---|
| date | Tue, 09 Sep 2014 09:29:00 +0100 |
| parents | e248c7af89ec |
| children |
comparison
equal
deleted
inserted
replaced
| 1516:b450a9d58aed | 1517:dffacf8a6908 |
|---|---|
| 24 Setting.rest_api_enabled = '1' | 24 Setting.rest_api_enabled = '1' |
| 25 end | 25 end |
| 26 | 26 |
| 27 def teardown | 27 def teardown |
| 28 Setting.rest_api_enabled = '0' | 28 Setting.rest_api_enabled = '0' |
| 29 end | |
| 30 | |
| 31 def test_api_should_trigger_basic_http_auth_with_basic_authorization_header | |
| 32 ApplicationController.any_instance.expects(:authenticate_with_http_basic).once | |
| 33 get '/users/current.xml', {}, credentials('jsmith') | |
| 34 assert_response 401 | |
| 35 end | |
| 36 | |
| 37 def test_api_should_not_trigger_basic_http_auth_with_non_basic_authorization_header | |
| 38 ApplicationController.any_instance.expects(:authenticate_with_http_basic).never | |
| 39 get '/users/current.xml', {}, 'HTTP_AUTHORIZATION' => 'Digest foo bar' | |
| 40 assert_response 401 | |
| 41 end | |
| 42 | |
| 43 def test_invalid_utf8_credentials_should_not_trigger_an_error | |
| 44 invalid_utf8 = "\x82" | |
| 45 if invalid_utf8.respond_to?(:force_encoding) | |
| 46 invalid_utf8.force_encoding('UTF-8') | |
| 47 assert !invalid_utf8.valid_encoding? | |
| 48 end | |
| 49 assert_nothing_raised do | |
| 50 get '/users/current.xml', {}, credentials(invalid_utf8, "foo") | |
| 51 end | |
| 29 end | 52 end |
| 30 | 53 |
| 31 def test_api_request_should_not_use_user_session | 54 def test_api_request_should_not_use_user_session |
| 32 log_user('jsmith', 'jsmith') | 55 log_user('jsmith', 'jsmith') |
| 33 | 56 |
