[ARVADOS] updated: 3167e5659918f4679d48bcc7f1fda4c3e4ef096f

git at public.curoverse.com git at public.curoverse.com
Tue Nov 18 14:39:23 EST 2014


Summary of changes:
 .../api/test/functional/database_controller_test.rb | 15 +++++++++++++++
 .../api/test/integration/database_reset_test.rb     | 21 +++++++++++++++++++++
 services/api/test/test_helper.rb                    |  4 ++++
 3 files changed, 40 insertions(+)
 create mode 100644 services/api/test/integration/database_reset_test.rb

       via  3167e5659918f4679d48bcc7f1fda4c3e4ef096f (commit)
      from  8bb852474590b57c2476b0972100c4659dc60815 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 3167e5659918f4679d48bcc7f1fda4c3e4ef096f
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Nov 18 10:08:35 2014 -0500

    4533: Add more tests for disabling reset feature in config file.

diff --git a/services/api/test/functional/database_controller_test.rb b/services/api/test/functional/database_controller_test.rb
index 7909e60..1953aa1 100644
--- a/services/api/test/functional/database_controller_test.rb
+++ b/services/api/test/functional/database_controller_test.rb
@@ -3,6 +3,12 @@ require 'test_helper'
 class DatabaseControllerTest < ActionController::TestCase
   include CurrentApiClient
 
+  teardown do
+    restore_configuration
+    # We made configuration changes here that affect routing.
+    Rails.application.reload_routes!
+  end
+
   test "reset fails with non-admin token" do
     authorize_with :active
     post :reset
@@ -18,6 +24,15 @@ class DatabaseControllerTest < ActionController::TestCase
     ENV['RAILS_ENV'] = env_was
   end
 
+  test "reset fails when not configured" do
+    Rails.configuration.enable_remote_database_reset = false
+    Rails.application.reload_routes!
+    authorize_with :admin
+    assert_raise ActionController::RoutingError do
+      post :reset
+    end
+  end
+
   test "reset succeeds with admin token" do
     new_uuid = nil
     act_as_system_user do
diff --git a/services/api/test/integration/database_reset_test.rb b/services/api/test/integration/database_reset_test.rb
new file mode 100644
index 0000000..84f8a19
--- /dev/null
+++ b/services/api/test/integration/database_reset_test.rb
@@ -0,0 +1,21 @@
+require 'test_helper'
+
+class DatabaseResetTest < ActionDispatch::IntegrationTest
+  teardown do
+    restore_configuration
+    # We made configuration changes here that affect routing.
+    Rails.application.reload_routes!
+  end
+
+  test "reset fails when not configured" do
+    Rails.configuration.enable_remote_database_reset = false
+    Rails.application.reload_routes!
+    post '/database/reset', {}, auth(:admin)
+    assert_response 404
+  end
+
+  test "reset fails with non-admin token" do
+    post '/database/reset', {}, auth(:active)
+    assert_response 403
+  end
+end
diff --git a/services/api/test/test_helper.rb b/services/api/test/test_helper.rb
index d59b449..216dd2d 100644
--- a/services/api/test/test_helper.rb
+++ b/services/api/test/test_helper.rb
@@ -49,6 +49,10 @@ class ActiveSupport::TestCase
     Thread.current[:api_client_uuid] = nil
     Thread.current[:api_client] = nil
     Thread.current[:user] = nil
+    restore_configuration
+  end
+
+  def restore_configuration
     # Restore configuration settings changed during tests
     $application_config.each do |k,v|
       if k.match /^[^.]*$/

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list