14988: Fixes anonymous config & token usage issues on tests.
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Mon, 6 May 2019 20:12:30 +0000 (17:12 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Mon, 6 May 2019 20:12:30 +0000 (17:12 -0300)
After calling post/get it seems that the token is reset, so on tests with
multiple controller/api calls there were some problems with authentication.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

apps/workbench/test/controllers/collections_controller_test.rb
apps/workbench/test/controllers/projects_controller_test.rb

index 302820057a62a0830920f565941f8bb03b76c36c..88287cd3f3d1cd0b5e65ed980b4c58b6ce4b13dd 100644 (file)
@@ -612,6 +612,7 @@ class CollectionsControllerTest < ActionController::TestCase
     }, session: session_for(:active)
     assert_response :success
 
+    use_token :active
     # verify no 'file1' in the updated collection
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
     assert_not_includes(collection['manifest_text'], "0:0:file1")
@@ -637,6 +638,7 @@ class CollectionsControllerTest < ActionController::TestCase
     assert_response :success
 
     # verify that "./dir1" no longer exists in this collection's manifest text
+    use_token :active
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
     assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1 0:0:file2\n$/, collection['manifest_text']
     assert_not_includes(collection['manifest_text'], 'dir1')
@@ -661,6 +663,7 @@ class CollectionsControllerTest < ActionController::TestCase
     }, session: session_for(:active)
     assert_response :success
 
+    use_token :active
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
     assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed 0:0:file2\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1 0:0:dir1file2 0:0:dir1imagefile.png\n$/, collection['manifest_text']
 
@@ -675,6 +678,7 @@ class CollectionsControllerTest < ActionController::TestCase
     }, session: session_for(:active)
     assert_response :success
 
+    use_token :active
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
     assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1 0:0:dir1file2 0:0:dir1imagefile.png 0:0:file2\n$/, collection['manifest_text']
 
@@ -689,6 +693,7 @@ class CollectionsControllerTest < ActionController::TestCase
     }, session: session_for(:active)
     assert_response :success
 
+    use_token :active
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
     assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file2 0:0:dir1imagefile.png 0:0:file2\n.\/dir2\/dir3 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1moved\n$/, collection['manifest_text']
 
@@ -703,6 +708,7 @@ class CollectionsControllerTest < ActionController::TestCase
     }, session: session_for(:active)
     assert_response :success
 
+    use_token :active
     collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
     assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file2 0:0:dir1imagefilerenamed.png 0:0:file2\n.\/dir2\/dir3 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1moved\n$/, collection['manifest_text']
   end
index 82b5dd06145ef791aac03a5eca137e54810263e3..09a6950cead6fad12ce20262c3eda4a6d978d91c 100644 (file)
@@ -276,6 +276,8 @@ class ProjectsControllerTest < ActionController::TestCase
   end
 
   test "visit public projects page when anon config is not enabled as active user and expect 404" do
+    Rails.configuration.anonymous_user_token = nil
+    Rails.configuration.enable_public_projects_page = false
     get :public, params: {}, session: session_for(:active)
     assert_response 404
   end
@@ -288,6 +290,8 @@ class ProjectsControllerTest < ActionController::TestCase
   end
 
   test "visit public projects page when anon config is not enabled as anonymous and expect login page" do
+    Rails.configuration.anonymous_user_token = nil
+    Rails.configuration.enable_public_projects_page = false
     get :public
     assert_response :redirect
     assert_match /\/users\/welcome/, @response.redirect_url