Update API test to use token based authentication when twofa is enabled for user (#35001).

git-svn-id: http://svn.redmine.org/redmine/trunk@21441 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu
2022-02-25 07:57:37 +00:00
parent fbca88afc4
commit 1ebb8920d2

View File

@@ -184,8 +184,13 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
end
test "GET /users/:id should not return twofa_scheme for standard user" do
User.find(2).update(twofa_scheme: 'totp')
get '/users/3.xml', :headers => credentials('jsmith')
# User and password authentication is disabled when twofa is enabled
# Use token authentication
user = User.find(2)
token = Token.create!(:user => user, :action => 'api')
user.update(twofa_scheme: 'totp')
get '/users/3.xml', :headers => credentials(token.value, 'X')
assert_response :success
assert_select 'twofa_scheme', 0
end