From 1ebb8920d2400f7e505a8508ef17aa6eaf76b5d3 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Fri, 25 Feb 2022 07:57:37 +0000 Subject: 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 --- test/integration/api_test/users_test.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb index 12198db19..26473356a 100644 --- a/test/integration/api_test/users_test.rb +++ b/test/integration/api_test/users_test.rb @@ -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 -- cgit v1.2.3