[ARVADOS] created: b6a0ff1443bb40b52df7b30fd269aa6f05591b31

git at public.curoverse.com git at public.curoverse.com
Wed Apr 23 19:30:30 EDT 2014


        at  b6a0ff1443bb40b52df7b30fd269aa6f05591b31 (commit)


commit b6a0ff1443bb40b52df7b30fd269aa6f05591b31
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed Apr 23 19:28:20 2014 -0400

    Remove excess controllers and routes. Add tests to detect accidental future additions.

diff --git a/services/api/app/controllers/api_clients_controller.rb b/services/api/app/controllers/api_clients_controller.rb
deleted file mode 100644
index 684e4e7..0000000
--- a/services/api/app/controllers/api_clients_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class ApiClientsController < ApplicationController
-end
diff --git a/services/api/app/controllers/collections_controller.rb b/services/api/app/controllers/collections_controller.rb
deleted file mode 100644
index 3d8f990..0000000
--- a/services/api/app/controllers/collections_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class CollectionsController < ApplicationController
-end
diff --git a/services/api/app/controllers/commit_ancestors_controller.rb b/services/api/app/controllers/commit_ancestors_controller.rb
deleted file mode 100644
index 0af8473..0000000
--- a/services/api/app/controllers/commit_ancestors_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class CommitAncestorsController < ApplicationController
-end
diff --git a/services/api/app/controllers/commits_controller.rb b/services/api/app/controllers/commits_controller.rb
deleted file mode 100644
index f984912..0000000
--- a/services/api/app/controllers/commits_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class CommitsController < ApplicationController
-end
diff --git a/services/api/app/controllers/nodes_controller.rb b/services/api/app/controllers/nodes_controller.rb
deleted file mode 100644
index 1b4e37d..0000000
--- a/services/api/app/controllers/nodes_controller.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-class NodesController < ApplicationController
-  def index
-    @objects = model_class.order("created_at desc")
-
-    @slurm_state = {}
-    IO.popen('sinfo --noheader --Node || echo "compute[1-3] foo bar DOWN"').readlines.each do |line|
-      tokens = line.strip.split
-      nodestate = tokens.last
-      nodenames = []
-      if (re = tokens.first.match /^([^\[]*)\[([-\d,]+)\]$/)
-        nodeprefix = re[1]
-        re[2].split(',').each do |number_range|
-          if number_range.index('-')
-            range = number_range.split('-').collect(&:to_i)
-            (range[0]..range[1]).each do |n|
-              nodenames << "#{nodeprefix}#{n}"
-            end
-          else
-            nodenames << "#{nodeprefix}#{number_range}"
-          end
-        end
-      else
-        nodenames << tokens.first
-      end
-      nodenames.each do |nodename|
-        @slurm_state[nodename] = nodestate.downcase
-      end
-    end
-  end
-end
diff --git a/services/api/app/controllers/pipeline_instances_controller.rb b/services/api/app/controllers/pipeline_instances_controller.rb
deleted file mode 100644
index afb9949..0000000
--- a/services/api/app/controllers/pipeline_instances_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class PipelineInstancesController < ApplicationController
-end
diff --git a/services/api/app/controllers/users_controller.rb b/services/api/app/controllers/users_controller.rb
deleted file mode 100644
index 3e74dea..0000000
--- a/services/api/app/controllers/users_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class UsersController < ApplicationController
-end
diff --git a/services/api/config/application.rb b/services/api/config/application.rb
index 24648a9..2cd3fc9 100644
--- a/services/api/config/application.rb
+++ b/services/api/config/application.rb
@@ -32,5 +32,7 @@ module Server
 
     # Configure sensitive parameters which will be filtered from the log file.
     config.filter_parameters += [:password]
+
+    I18n.enforce_available_locales = false
   end
 end
diff --git a/services/api/config/routes.rb b/services/api/config/routes.rb
index 211701a..5a11143 100644
--- a/services/api/config/routes.rb
+++ b/services/api/config/routes.rb
@@ -1,126 +1,58 @@
 Server::Application.routes.draw do
   themes_for_rails
 
-  resources :humans
-  resources :traits
-  resources :repositories
-  resources :virtual_machines
-  resources :authorized_keys
-  resources :keep_disks
-  resources :commit_ancestors
-  resources :commits
-  resources :job_tasks
-  resources :jobs
-  resources :api_client_authorizations
-  resources :api_clients
-  resources :logs
-  resources :groups
-  resources :specimens
-  resources :collections
-  resources :links
-  resources :nodes
-  resources :pipeline_templates
-  resources :pipeline_instances
-
-  # The priority is based upon order of creation:
-  # first created -> highest priority.
-
-  # Sample of regular route:
-  #   match 'products/:id' => 'catalog#view'
-  # Keep in mind you can assign values other than :controller and :action
-
-  # Sample of named route:
-  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
-  # This route can be invoked with purchase_url(:id => product.id)
-
-  # Sample resource route (maps HTTP verbs to controller actions automatically):
-  #   resources :products
-
-  # Sample resource route with options:
-  #   resources :products do
-  #     member do
-  #       get 'short'
-  #       post 'toggle'
-  #     end
-  #
-  #     collection do
-  #       get 'sold'
-  #     end
-  #   end
-
-  # Sample resource route with sub-resources:
-  #   resources :products do
-  #     resources :comments, :sales
-  #     resource :seller
-  #   end
-
-  # Sample resource route with more complex sub-resources
-  #   resources :products do
-  #     resources :comments
-  #     resources :sales do
-  #       get 'recent', :on => :collection
-  #     end
-  #   end
-
-  # Sample resource route within a namespace:
-  #   namespace :admin do
-  #     # Directs /admin/products/* to Admin::ProductsController
-  #     # (app/controllers/admin/products_controller.rb)
-  #     resources :products
-  #   end
-
-  # You can have the root of your site routed with "root"
-  # just remember to delete public/index.html.
-  # root :to => 'welcome#index'
-
-  # See how all your routes lay out with "rake routes"
-
-  # This is a legacy wild controller route that's not recommended for RESTful applications.
-  # Note: This route will make all actions in every controller accessible via GET requests.
-  # match ':controller(/:action(/:id(.:format)))'
+  # See http://guides.rubyonrails.org/routing.html
 
   namespace :arvados do
     namespace :v1 do
-      match '/nodes/:uuid/ping' => 'nodes#ping', :as => :ping_node
-      match '/keep_disks/ping' => 'keep_disks#ping', :as => :ping_keep_disk
-      match '/links/from/:tail_uuid' => 'links#index', :as => :arvados_v1_links_from
-      match '/users/current' => 'users#current'
-      match '/users/system' => 'users#system'
-      match '/jobs/queue' => 'jobs#queue'
-      match '/jobs/:uuid/log_tail_follow' => 'jobs#log_tail_follow'
-      post '/jobs/:uuid/cancel' => 'jobs#cancel'
-      match '/users/:uuid/event_stream' => 'users#event_stream'
-      post '/users/:uuid/activate' => 'users#activate'
-      post '/users/setup' => 'users#setup'
-      post '/users/:uuid/unsetup' => 'users#unsetup'
-      match '/virtual_machines/get_all_logins' => 'virtual_machines#get_all_logins'
-      match '/virtual_machines/:uuid/logins' => 'virtual_machines#logins'
-      post '/api_client_authorizations/create_system_auth' => 'api_client_authorizations#create_system_auth'
-      match '/repositories/get_all_permissions' => 'repositories#get_all_permissions'
-      get '/user_agreements/signatures' => 'user_agreements#signatures'
-      post '/user_agreements/sign' => 'user_agreements#sign'
-      get '/collections/:uuid/provenance' => 'collections#provenance'
-      get '/collections/:uuid/used_by' => 'collections#used_by'
-      resources :collections
+      resources :api_client_authorizations do
+        post 'create_system_auth', on: :collection
+      end
+      resources :api_clients
+      resources :authorized_keys
+      resources :collections do
+        get 'provenance', on: :member
+        get 'used_by', on: :member
+      end
+      resources :groups
+      resources :humans
+      resources :job_tasks
+      resources :jobs do
+        get 'queue', on: :collection
+        get 'log_tail_follow', on: :member
+        post 'cancel', on: :member
+      end
+      resources :keep_disks do
+        post 'ping', on: :collection
+      end
       resources :links
-      resources :nodes
-      resources :pipeline_templates
+      resources :logs
+      resources :nodes do
+        post 'ping', on: :member
+      end
       resources :pipeline_instances
+      resources :pipeline_templates
+      resources :repositories do
+        get 'get_all_permissions', on: :collection
+      end
       resources :specimens
-      resources :groups
-      resources :logs
-      resources :users
-      resources :api_clients
-      resources :api_client_authorizations
-      resources :jobs
-      resources :job_tasks
-      resources :keep_disks
-      resources :authorized_keys
-      resources :virtual_machines
-      resources :repositories
       resources :traits
-      resources :humans
-      resources :user_agreements
+      resources :user_agreements do
+        get 'signatures', on: :collection
+        post 'sign', on: :collection
+      end
+      resources :users do
+        get 'current', on: :collection
+        get 'system', on: :collection
+        get 'event_stream', on: :member
+        post 'activate', on: :member
+        post 'setup', on: :collection
+        post 'unsetup', on: :member
+      end
+      resources :virtual_machines do
+        get 'logins', on: :member
+        get 'get_all_logins', on: :collection
+      end
     end
   end
 
@@ -138,7 +70,7 @@ Server::Application.routes.draw do
 
   # Send unroutable requests to an arbitrary controller
   # (ends up at ApplicationController#render_not_found)
-  match '*a', :to => 'arvados/v1/links#render_not_found'
+  match '*a', :to => 'static#render_not_found'
 
   root :to => 'static#home'
 end
diff --git a/services/api/test/functional/admin_notifier_test.rb b/services/api/test/functional/admin_notifier_test.rb
deleted file mode 100644
index e0e6036..0000000
--- a/services/api/test/functional/admin_notifier_test.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class AdminNotifierTest < ActionMailer::TestCase
-  # test "the truth" do
-  #   assert true
-  # end
-end
diff --git a/services/api/test/functional/arvados/v1/collections_controller_test.rb b/services/api/test/functional/arvados/v1/collections_controller_test.rb
index 6990e97..501c5a1 100644
--- a/services/api/test/functional/arvados/v1/collections_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb
@@ -179,7 +179,7 @@ EOS
 
   test "get full provenance for baz file" do
     authorize_with :active
-    get :provenance, uuid: 'ea10d51bcf88862dbcc36eb292017dfd+45'
+    get :provenance, id: 'ea10d51bcf88862dbcc36eb292017dfd+45'
     assert_response :success
     resp = JSON.parse(@response.body)
     assert_not_nil resp['ea10d51bcf88862dbcc36eb292017dfd+45'] # baz
@@ -192,14 +192,14 @@ EOS
   test "get no provenance for foo file" do
     # spectator user cannot even see baz collection
     authorize_with :spectator
-    get :provenance, uuid: '1f4b0bc7583c2a7f9102c395f4ffc5e3+45'
+    get :provenance, id: '1f4b0bc7583c2a7f9102c395f4ffc5e3+45'
     assert_response 404
   end
 
   test "get partial provenance for baz file" do
     # spectator user can see bar->baz job, but not foo->bar job
     authorize_with :spectator
-    get :provenance, uuid: 'ea10d51bcf88862dbcc36eb292017dfd+45'
+    get :provenance, id: 'ea10d51bcf88862dbcc36eb292017dfd+45'
     assert_response :success
     resp = JSON.parse(@response.body)
     assert_not_nil resp['ea10d51bcf88862dbcc36eb292017dfd+45'] # baz
diff --git a/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb b/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb
index 385710e..2cda44f 100644
--- a/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb
@@ -48,7 +48,7 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
 
   test "ping keep disk" do
     post :ping, {
-      uuid: keep_disks(:nonfull).uuid,
+      id: keep_disks(:nonfull).uuid,
       ping_secret: keep_disks(:nonfull).ping_secret,
       filesystem_uuid: keep_disks(:nonfull).filesystem_uuid
     }
diff --git a/services/api/test/functional/arvados/v1/nodes_controller_test.rb b/services/api/test/functional/arvados/v1/nodes_controller_test.rb
index 3e239c3..386c839 100644
--- a/services/api/test/functional/arvados/v1/nodes_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/nodes_controller_test.rb
@@ -42,7 +42,7 @@ class Arvados::V1::NodesControllerTest < ActionController::TestCase
 
   test "node should ping with ping_secret and no token" do
     post :ping, {
-      uuid: 'zzzzz-7ekkf-2z3mc76g2q73aio',
+      id: 'zzzzz-7ekkf-2z3mc76g2q73aio',
       instance_id: 'i-0000000',
       local_ipv4: '172.17.2.174',
       ping_secret: '69udawxvn3zzj45hs8bumvndricrha4lcpi23pd69e44soanc0'
@@ -58,7 +58,7 @@ class Arvados::V1::NodesControllerTest < ActionController::TestCase
 
   test "node should fail ping with invalid ping_secret" do
     post :ping, {
-      uuid: 'zzzzz-7ekkf-2z3mc76g2q73aio',
+      id: 'zzzzz-7ekkf-2z3mc76g2q73aio',
       instance_id: 'i-0000000',
       local_ipv4: '172.17.2.174',
       ping_secret: 'dricrha4lcpi23pd69e44soanc069udawxvn3zzj45hs8bumvn'
diff --git a/services/api/test/functional/arvados/v1/users_controller_test.rb b/services/api/test/functional/arvados/v1/users_controller_test.rb
index b6bb205..1fefcb6 100644
--- a/services/api/test/functional/arvados/v1/users_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/users_controller_test.rb
@@ -13,7 +13,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     get :current
     assert_response :success
     me = JSON.parse(@response.body)
-    post :activate, uuid: me['uuid']
+    post :activate, id: me['uuid']
     assert_response :success
     assert_not_nil assigns(:object)
     me = JSON.parse(@response.body)
@@ -49,7 +49,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     me = JSON.parse(@response.body)
     assert_equal false, me['is_active']
 
-    post :activate, uuid: me['uuid']
+    post :activate, id: me['uuid']
     assert_response 403
 
     get :current
@@ -63,7 +63,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     get :current
     assert_response :success
     me = JSON.parse(@response.body)
-    post :activate, uuid: me['uuid']
+    post :activate, id: me['uuid']
     assert_response :success
     me = JSON.parse(@response.body)
     assert_equal true, me['is_active']
@@ -697,7 +697,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     verify_link_existence created['uuid'], created['email'], true, true, true, true, false
 
     # now unsetup this user
-    post :unsetup, uuid: created['uuid']
+    post :unsetup, id: created['uuid']
     assert_response :success
 
     created2 = JSON.parse(@response.body)
@@ -722,7 +722,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     authorize_with :admin
 
     # now unsetup this user
-    post :unsetup, uuid: active_user['uuid']
+    post :unsetup, id: active_user['uuid']
     assert_response :success
 
     response_user = JSON.parse(@response.body)
diff --git a/services/api/test/functional/commit_ancestors_controller_test.rb b/services/api/test/functional/commit_ancestors_controller_test.rb
deleted file mode 100644
index eb5d1f5..0000000
--- a/services/api/test/functional/commit_ancestors_controller_test.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class CommitAncestorsControllerTest < ActionController::TestCase
-  # test "the truth" do
-  #   assert true
-  # end
-end
diff --git a/services/api/test/functional/commits_controller_test.rb b/services/api/test/functional/commits_controller_test.rb
deleted file mode 100644
index 8e649d3..0000000
--- a/services/api/test/functional/commits_controller_test.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class CommitsControllerTest < ActionController::TestCase
-  # test "the truth" do
-  #   assert true
-  # end
-end
diff --git a/services/api/test/functional/user_notifier_test.rb b/services/api/test/functional/user_notifier_test.rb
deleted file mode 100644
index c06f62e..0000000
--- a/services/api/test/functional/user_notifier_test.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class UserNotifierTest < ActionMailer::TestCase
-  # test "the truth" do
-  #   assert true
-  # end
-end
diff --git a/services/api/test/integration/errors_test.rb b/services/api/test/integration/errors_test.rb
new file mode 100644
index 0000000..3a58e48
--- /dev/null
+++ b/services/api/test/integration/errors_test.rb
@@ -0,0 +1,27 @@
+require 'test_helper'
+
+class ErrorsTest < ActionDispatch::IntegrationTest
+  fixtures :api_client_authorizations
+
+  %w(/arvados/v1/shoes /arvados/shoes /shoes /nodes /users).each do |path|
+    test "non-existent route #{path}" do
+      get path, {:format => :json}, auth(:active)
+      assert_nil assigns(:objects)
+      assert_nil assigns(:object)
+      assert_not_nil jresponse['errors']
+      assert_response 404
+    end
+  end
+
+  n=0
+  Rails.application.routes.routes.each do |route|
+    test "route #{n += 1} '#{route.path.spec.to_s}' is not an accident" do
+      # Generally, new routes should appear under /arvados/v1/. If
+      # they appear elsewhere, that might have been caused by default
+      # rails generator behavior that we don't want.
+      assert_match(/^\/(|\*a|arvados\/v1\/.*|auth\/.*|login|logout|discovery\/.*|static\/.*|themes\/.*)(\(\.:format\))?$/,
+                   route.path.spec.to_s,
+                   "Unexpected new route: #{route.path.spec}")
+    end
+  end
+end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list