4533: Add more tests for disabling reset feature in config file.
[arvados.git] / services / api / test / integration / database_reset_test.rb
diff --git a/services/api/test/integration/database_reset_test.rb b/services/api/test/integration/database_reset_test.rb
new file mode 100644 (file)
index 0000000..84f8a19
--- /dev/null
@@ -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