##// END OF EJS Templates
Adds missing copyright....
Jean-Philippe Lang -
r11024:5397216190a8
parent child
Show More
@@ -1,62 +1,79
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
1 18 require File.expand_path('../../../test_helper', __FILE__)
2 19
3 20 class Redmine::ApiTest::DisabledRestApiTest < Redmine::ApiTest::Base
4 21 fixtures :projects, :trackers, :issue_statuses, :issues,
5 22 :enumerations, :users, :issue_categories,
6 23 :projects_trackers,
7 24 :roles,
8 25 :member_roles,
9 26 :members,
10 27 :enabled_modules,
11 28 :workflows
12 29
13 30 def setup
14 31 Setting.rest_api_enabled = '0'
15 32 Setting.login_required = '1'
16 33 end
17 34
18 35 def teardown
19 36 Setting.rest_api_enabled = '1'
20 37 Setting.login_required = '0'
21 38 end
22 39
23 40 def test_with_a_valid_api_token
24 41 @user = User.generate!
25 42 @token = Token.create!(:user => @user, :action => 'api')
26 43
27 44 get "/news.xml?key=#{@token.value}"
28 45 assert_response :unauthorized
29 46 assert_equal User.anonymous, User.current
30 47
31 48 get "/news.json?key=#{@token.value}"
32 49 assert_response :unauthorized
33 50 assert_equal User.anonymous, User.current
34 51 end
35 52
36 53 def test_with_valid_username_password_http_authentication
37 54 @user = User.generate! do |user|
38 55 user.password = 'my_password'
39 56 end
40 57
41 58 get "/news.xml", nil, credentials(@user.login, 'my_password')
42 59 assert_response :unauthorized
43 60 assert_equal User.anonymous, User.current
44 61
45 62 get "/news.json", nil, credentials(@user.login, 'my_password')
46 63 assert_response :unauthorized
47 64 assert_equal User.anonymous, User.current
48 65 end
49 66
50 67 def test_with_valid_token_http_authentication
51 68 @user = User.generate!
52 69 @token = Token.create!(:user => @user, :action => 'api')
53 70
54 71 get "/news.xml", nil, credentials(@token.value, 'X')
55 72 assert_response :unauthorized
56 73 assert_equal User.anonymous, User.current
57 74
58 75 get "/news.json", nil, credentials(@token.value, 'X')
59 76 assert_response :unauthorized
60 77 assert_equal User.anonymous, User.current
61 78 end
62 79 end
@@ -1,38 +1,55
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
1 18 require File.expand_path('../../../test_helper', __FILE__)
2 19
3 20 class Redmine::ApiTest::HttpBasicLoginTest < Redmine::ApiTest::Base
4 21 fixtures :projects, :trackers, :issue_statuses, :issues,
5 22 :enumerations, :users, :issue_categories,
6 23 :projects_trackers,
7 24 :roles,
8 25 :member_roles,
9 26 :members,
10 27 :enabled_modules,
11 28 :workflows
12 29
13 30 def setup
14 31 Setting.rest_api_enabled = '1'
15 32 Setting.login_required = '1'
16 33 end
17 34
18 35 def teardown
19 36 Setting.rest_api_enabled = '0'
20 37 Setting.login_required = '0'
21 38 end
22 39
23 40 # Using the NewsController because it's a simple API.
24 41 context "get /news" do
25 42 setup do
26 43 project = Project.find('onlinestore')
27 44 EnabledModule.create(:project => project, :name => 'news')
28 45 end
29 46
30 47 context "in :xml format" do
31 48 should_allow_http_basic_auth_with_username_and_password(:get, "/projects/onlinestore/news.xml")
32 49 end
33 50
34 51 context "in :json format" do
35 52 should_allow_http_basic_auth_with_username_and_password(:get, "/projects/onlinestore/news.json")
36 53 end
37 54 end
38 55 end
@@ -1,34 +1,51
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
1 18 require File.expand_path('../../../test_helper', __FILE__)
2 19
3 20 class Redmine::ApiTest::HttpBasicLoginWithApiTokenTest < Redmine::ApiTest::Base
4 21 fixtures :projects, :trackers, :issue_statuses, :issues,
5 22 :enumerations, :users, :issue_categories,
6 23 :projects_trackers,
7 24 :roles,
8 25 :member_roles,
9 26 :members,
10 27 :enabled_modules,
11 28 :workflows
12 29
13 30 def setup
14 31 Setting.rest_api_enabled = '1'
15 32 Setting.login_required = '1'
16 33 end
17 34
18 35 def teardown
19 36 Setting.rest_api_enabled = '0'
20 37 Setting.login_required = '0'
21 38 end
22 39
23 40 # Using the NewsController because it's a simple API.
24 41 context "get /news" do
25 42
26 43 context "in :xml format" do
27 44 should_allow_http_basic_auth_with_key(:get, "/news.xml")
28 45 end
29 46
30 47 context "in :json format" do
31 48 should_allow_http_basic_auth_with_key(:get, "/news.json")
32 49 end
33 50 end
34 51 end
@@ -1,33 +1,50
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
1 18 require File.expand_path('../../../test_helper', __FILE__)
2 19
3 20 class Redmine::ApiTest::TokenAuthenticationTest < Redmine::ApiTest::Base
4 21 fixtures :projects, :trackers, :issue_statuses, :issues,
5 22 :enumerations, :users, :issue_categories,
6 23 :projects_trackers,
7 24 :roles,
8 25 :member_roles,
9 26 :members,
10 27 :enabled_modules,
11 28 :workflows
12 29
13 30 def setup
14 31 Setting.rest_api_enabled = '1'
15 32 Setting.login_required = '1'
16 33 end
17 34
18 35 def teardown
19 36 Setting.rest_api_enabled = '0'
20 37 Setting.login_required = '0'
21 38 end
22 39
23 40 # Using the NewsController because it's a simple API.
24 41 context "get /news" do
25 42 context "in :xml format" do
26 43 should_allow_key_based_auth(:get, "/news.xml")
27 44 end
28 45
29 46 context "in :json format" do
30 47 should_allow_key_based_auth(:get, "/news.json")
31 48 end
32 49 end
33 50 end
General Comments 0
You need to be logged in to leave comments. Login now