From fefdb915c4cdf2c2d92061d9221eacd7cac4682f Mon Sep 17 00:00:00 2001 From: Radhika Chippada Date: Wed, 4 Feb 2015 09:22:05 -0500 Subject: [PATCH 1/1] 2659: Do not turn on anonymous config by default in test mode; instead make the tests set it as needed. Also convert some of the simple integration tests into controller tests. --- apps/workbench/config/application.default.yml | 1 - .../controllers/projects_controller_test.rb | 14 ++++++++++++++ .../test/integration/anonymous_access_test.rb | 19 ------------------- .../workbench/test/integration/errors_test.rb | 6 ------ 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/apps/workbench/config/application.default.yml b/apps/workbench/config/application.default.yml index ab81032e23..f43e8c6e09 100644 --- a/apps/workbench/config/application.default.yml +++ b/apps/workbench/config/application.default.yml @@ -120,7 +120,6 @@ test: - Software developer - IT - Other - anonymous_user_token: 4kg6k6lzmp9kj4cpkcoxie964cmvjahbt4fod9zru44k4jqdmi common: assets.js_compressor: false diff --git a/apps/workbench/test/controllers/projects_controller_test.rb b/apps/workbench/test/controllers/projects_controller_test.rb index 5d7b1e27b3..c2089ad18d 100644 --- a/apps/workbench/test/controllers/projects_controller_test.rb +++ b/apps/workbench/test/controllers/projects_controller_test.rb @@ -207,4 +207,18 @@ class ProjectsControllerTest < ActionController::TestCase }] get :show, encoded_params, session_for(:active) end + + test "visit non-public project as anonymous when anonymous browsing is enabled and expect page not found" do + Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token'] + get(:show, {id: api_fixture('groups')['aproject']['uuid']}) + assert_response 404 + assert_includes @response.inspect, 'you are not logged in' + end + + test "visit home page as anonymous when anonymous browsing is enabled and expect login" do + Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token'] + get(:index) + assert_response :redirect + assert_match /\/users\/welcome/, @response.redirect_url + end end diff --git a/apps/workbench/test/integration/anonymous_access_test.rb b/apps/workbench/test/integration/anonymous_access_test.rb index 0a850188df..2e6366215c 100644 --- a/apps/workbench/test/integration/anonymous_access_test.rb +++ b/apps/workbench/test/integration/anonymous_access_test.rb @@ -52,19 +52,6 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest end end - test "visit non-public project as anonymous when anonymous browsing is enabled and expect page not found" do - visit "/projects/#{api_fixture('groups')['aproject']['uuid']}" - assert_text 'Not Found' - end - - test "anonymous user clicking on topnav sees login page" do - visit PUBLIC_PROJECT - - # click on topnav - click_link 'workbench:test' - assert_text 'Please log in' - end - test "selection actions when anonymous user accesses shared project" do visit PUBLIC_PROJECT @@ -171,10 +158,4 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest assert_text 'script version' assert_no_selector 'a', text: 'Run this pipeline' end - - test "visit public project as anonymous when anonymous browsing is not enabled and expect login page" do - Rails.configuration.anonymous_user_token = false - visit "/projects/#{api_fixture('groups')['aproject']['uuid']}" - assert_text 'Please log in' - end end diff --git a/apps/workbench/test/integration/errors_test.rb b/apps/workbench/test/integration/errors_test.rb index 1cac667b22..1897a03858 100644 --- a/apps/workbench/test/integration/errors_test.rb +++ b/apps/workbench/test/integration/errors_test.rb @@ -125,10 +125,4 @@ class ErrorsTest < ActionDispatch::IntegrationTest Rails.configuration.arvados_v1_base = original_arvados_v1_base end end - - test "404 page checks if user not logged in and makes suggestion" do - visit "/collections/#{BAD_UUID}" - assert_text 'you are not logged in' - end - end -- 2.30.2