summaryrefslogtreecommitdiffstats
path: root/test/integration/api_test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-12-23 02:58:49 +0000
committerGo MAEDA <maeda@farend.jp>2020-12-23 02:58:49 +0000
commit5eb4b6af7948d1690942ba2f5fb8d0ffd90257be (patch)
tree9c02ea62dbb985e332bac187cfa87c6e4b2051fd /test/integration/api_test
parent843f13f7e207b6c0dffeb582db47176fd9fc1fa9 (diff)
downloadredmine-5eb4b6af7948d1690942ba2f5fb8d0ffd90257be.tar.gz
redmine-5eb4b6af7948d1690942ba2f5fb8d0ffd90257be.zip
Include two-factor authentication scheme in users API response (#34242).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@20686 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration/api_test')
-rw-r--r--test/integration/api_test/users_test.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb
index 1c669c9f5..b79791a7c 100644
--- a/test/integration/api_test/users_test.rb
+++ b/test/integration/api_test/users_test.rb
@@ -23,25 +23,35 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
fixtures :users, :email_addresses, :members, :member_roles, :roles, :projects
test "GET /users.xml should return users" do
+ users = User.active.order('login')
+ users.last.update(twofa_scheme: 'totp')
get '/users.xml', :headers => credentials('admin')
assert_response :success
assert_equal 'application/xml', response.media_type
assert_select 'users' do
- users = User.active.order('login')
assert_select 'user', :count => users.size do |nodeset|
nodeset.zip(users) do |user_element, user|
assert_select user_element, 'id', :text => user.id.to_s
assert_select user_element, 'updated_on', :text => user.updated_on.iso8601
+ assert_select user_element, 'twofa_scheme', :text => user.twofa_scheme.to_s
# No one has changed password.
assert_select user_element, 'passwd_changed_on', :text => ''
+
+ if user == users.last
+ assert_select user_element, 'twofa_scheme', :text => 'totp'
+ else
+ assert_select user_element, 'twofa_scheme', :text => ''
+ end
end
end
end
end
test "GET /users.json should return users" do
+ users = User.active.order('login')
+ users.last.update(twofa_scheme: 'totp')
get '/users.json', :headers => credentials('admin')
assert_response :success
@@ -58,6 +68,12 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
# No one has changed password.
assert_nil user_json['passwd_changed_on']
+
+ if user == users.last
+ assert_equal 'totp', user_json['twofa_scheme']
+ else
+ assert_nil user_json['twofa_scheme']
+ end
end
end
@@ -68,6 +84,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
assert_select 'user id', :text => '2'
assert_select 'user updated_on', :text => Time.zone.parse('2006-07-19T20:42:15Z').iso8601
assert_select 'user passwd_changed_on', :text => ''
+ assert_select 'user twofa_scheme', :text => ''
end
test "GET /users/:id.json should return the user" do
@@ -80,6 +97,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
assert_equal 2, json['user']['id']
assert_equal Time.zone.parse('2006-07-19T20:42:15Z').iso8601, json['user']['updated_on']
assert_nil json['user']['passwd_changed_on']
+ assert_nil json['user']['twofa_scheme']
end
test "GET /users/:id.xml with include=memberships should include memberships" do