6466:Added config parameter to disable public projects page and added a test to proje...
authorManoj <jonam33@gmail.com>
Fri, 3 Jul 2015 16:06:22 +0000 (12:06 -0400)
committerManoj <jonam33@gmail.com>
Fri, 3 Jul 2015 16:06:22 +0000 (12:06 -0400)
apps/workbench/app/controllers/projects_controller.rb
apps/workbench/config/application.default.yml
apps/workbench/test/controllers/projects_controller_test.rb

index 4087b59fdbeede3f399a965a9e73360626203268..44c85185c7c316a3f7d5efbb1c5566016b14348d 100644 (file)
@@ -319,7 +319,7 @@ class ProjectsController < ApplicationController
   end
 
   def public  # Yes 'public' is the name of the action for public projects
-    return render_not_found if not Rails.configuration.anonymous_user_token
+    return render_not_found if not Rails.configuration.anonymous_user_token or not Rails.configuration.enable_public_projects_page
     @objects = using_specific_api_token Rails.configuration.anonymous_user_token do
       Group.where(group_class: 'project').order("updated_at DESC")
     end
index cae7b19d8d03562aa1d2e2c80116f4b5e1ff6074..4ade8b49b6b86767482e29f6b99bf739bfddaed6 100644 (file)
@@ -209,5 +209,8 @@ common:
   # in the directory where your API server is running.
   anonymous_user_token: false
 
+  # when anonymous_user_token is configured, show public projects page
+  enable_public_projects_page: true
+
   # Ask Arvados API server to compress its response payloads.
   api_response_compression: true
index d7fb8f2a0081a4ec13fc2a5a2747460d1e1cb1b6..41ed7277f8e46e7e390e5d6ee2702be50e3e1177 100644 (file)
@@ -275,6 +275,13 @@ class ProjectsControllerTest < ActionController::TestCase
     assert_response 404
   end
 
+  test "visit public projects page when anon config is enabled but public projects page is disabled and expect 404" do
+    Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
+    Rails.configuration.enable_public_projects_page = false
+    get :public, {}, session_for(:active)
+    assert_response 404
+  end
+
   test "visit public projects page when anon config is not enabled as anonymous and expect login page" do
     get :public
     assert_response :redirect