Merge branch '14574-expression-fix' refs #14574
[arvados.git] / apps / workbench / test / controllers / users_controller_test.rb
index 6b9cd6efa647edd391d78ff79a6e8bbd429348c9..393b864dc53a61f3a81a91af6abd49e836a5e831 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 require 'test_helper'
 
 class UsersControllerTest < ActionController::TestCase
@@ -31,26 +35,12 @@ class UsersControllerTest < ActionController::TestCase
     assert_match /\/users\/welcome/, @response.redirect_url
   end
 
-  test "show repositories with read, write, or manage permission" do
-    get :manage_account, {}, session_for(:active)
-    assert_response :success
-    repos = assigns(:my_repositories)
-    assert repos
-    assert_not_empty repos, "my_repositories should not be empty"
-    editables = repos.collect { |r| !!assigns(:repo_writable)[r.uuid] }
-    assert_includes editables, true, "should have a writable repository"
-    assert_includes editables, false, "should have a readonly repository"
-  end
-
-  test "show repositories lists linked as well as owned repositories" do
-    get :manage_account, {}, session_for(:active)
-    assert_response :success
-    repos = assigns(:my_repositories)
-    assert repos
-    repo_writables = assigns(:repo_writable)
-    assert_not_empty repo_writables, "repo_writables should not be empty"
-    assert_includes repo_writables, api_fixture('repositories')['repository4']['uuid']  # writable by active
-    assert_includes repo_writables, api_fixture('repositories')['repository2']['uuid']  # owned by active
+  test "'log in as user' feature uses a v2 token" do
+    post :sudo, {
+      id: api_fixture('users')['active']['uuid']
+    }, session_for('admin_trustedclient')
+    assert_response :redirect
+    assert_match /api_token=v2%2F/, @response.redirect_url
   end
 
   test "request shell access" do
@@ -87,14 +77,14 @@ class UsersControllerTest < ActionController::TestCase
       if username == 'admin'
         assert_match /<a href="\/projects\/#{admin_user['uuid']}">Home<\/a>/, @response.body
         assert_match /<a href="\/projects\/#{active_user['uuid']}">Home<\/a>/, @response.body
-        assert_match /href="\/users\/#{admin_user['uuid']}" title="show user"><i class="fa fa-fw fa-user"><\/i> Show<\/a/, @response.body
-        assert_match /href="\/users\/#{active_user['uuid']}" title="show user"><i class="fa fa-fw fa-user"><\/i> Show<\/a/, @response.body
+        assert_match /href="\/users\/#{admin_user['uuid']}"><i class="fa fa-fw fa-user"><\/i> Show<\/a/, @response.body
+        assert_match /href="\/users\/#{active_user['uuid']}"><i class="fa fa-fw fa-user"><\/i> Show<\/a/, @response.body
         assert_includes @response.body, admin_user['email']
         assert_includes @response.body, active_user['email']
       else
         refute_match  /Home<\/a>/, @response.body
-        refute_match /href="\/users\/#{admin_user['uuid']}" title="show user"><i class="fa fa-fw fa-user"><\/i> Show<\/a/, @response.body
-        assert_match /href="\/users\/#{active_user['uuid']}" title="show user"><i class="fa fa-fw fa-user"><\/i> Show<\/a/, @response.body
+        refute_match /href="\/users\/#{admin_user['uuid']}"><i class="fa fa-fw fa-user"><\/i> Show<\/a/, @response.body
+        assert_match /href="\/users\/#{active_user['uuid']}"><i class="fa fa-fw fa-user"><\/i> Show<\/a/, @response.body
         assert_includes @response.body, active_user['email']
       end
     end