]> source.dussan.org Git - redmine.git/commitdiff
Update API test to use token based authentication when twofa is enabled for user...
authorMarius Balteanu <marius.balteanu@zitec.com>
Fri, 25 Feb 2022 07:57:37 +0000 (07:57 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Fri, 25 Feb 2022 07:57:37 +0000 (07:57 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@21441 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/integration/api_test/users_test.rb

index 12198db195c6abd937b119f41eb852ba3b385a97..26473356ae299f3299d7f88f700ea46cedcdc375 100644 (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