comparison test/integration/api_test/users_test.rb @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents 433d4f72a19b
children
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
14 # You should have received a copy of the GNU General Public License 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 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. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 require File.expand_path('../../../test_helper', __FILE__) 18 require File.expand_path('../../../test_helper', __FILE__)
19 require 'pp' 19
20 class ApiTest::UsersTest < ActionController::IntegrationTest 20 class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
21 fixtures :users, :members, :member_roles, :roles, :projects 21 fixtures :users, :members, :member_roles, :roles, :projects
22 22
23 def setup 23 def setup
24 Setting.rest_api_enabled = '1' 24 Setting.rest_api_enabled = '1'
25 end 25 end
94 :child => {:tag => 'id', :content => '2'} 94 :child => {:tag => 'id', :content => '2'}
95 end 95 end
96 end 96 end
97 end 97 end
98 98
99 test "GET /users/:id should not return login for other user" do
100 get '/users/3.xml', {}, credentials('jsmith')
101 assert_response :success
102 assert_no_tag 'user', :child => {:tag => 'login'}
103 end
104
105 test "GET /users/:id should return login for current user" do
106 get '/users/2.xml', {}, credentials('jsmith')
107 assert_response :success
108 assert_tag 'user', :child => {:tag => 'login', :content => 'jsmith'}
109 end
110
111 test "GET /users/:id should not return api_key for other user" do
112 get '/users/3.xml', {}, credentials('jsmith')
113 assert_response :success
114 assert_no_tag 'user', :child => {:tag => 'api_key'}
115 end
116
117 test "GET /users/:id should return api_key for current user" do
118 get '/users/2.xml', {}, credentials('jsmith')
119 assert_response :success
120 assert_tag 'user', :child => {:tag => 'api_key', :content => User.find(2).api_key}
121 end
122
99 context "POST /users" do 123 context "POST /users" do
100 context "with valid parameters" do 124 context "with valid parameters" do
101 setup do 125 setup do
102 @parameters = { 126 @parameters = {
103 :user => { 127 :user => {