From: Peter Amstutz Date: Tue, 20 May 2014 18:11:15 +0000 (-0400) Subject: 2776: Added test for keep_services/accessable route. X-Git-Tag: 1.1.0~2612^2~1^2~1^2~2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/040f1c94dfa1a53356d24e77afdbc0f2e5cfe91c?ds=sidebyside 2776: Added test for keep_services/accessable route. --- diff --git a/services/api/app/controllers/arvados/v1/keep_services_controller.rb b/services/api/app/controllers/arvados/v1/keep_services_controller.rb index 43ce94d490..8c7ae7a829 100644 --- a/services/api/app/controllers/arvados/v1/keep_services_controller.rb +++ b/services/api/app/controllers/arvados/v1/keep_services_controller.rb @@ -1,5 +1,8 @@ class Arvados::V1::KeepServicesController < ApplicationController + skip_before_filter :find_object_by_uuid, only: :accessable + skip_before_filter :render_404_if_no_object, only: :accessable + def find_objects_for_index # all users can list all keep services @objects = model_class.where('1=1') @@ -7,12 +10,15 @@ class Arvados::V1::KeepServicesController < ApplicationController end def accessable + puts "Hello world" if request.headers['X-Keep-Proxy-Required'] @objects = model_class.where('service_type=?', 'proxy') else @objects = model_class.where('service_type=?', 'disk') end + puts "Rendering list now" + render_list end diff --git a/services/api/test/fixtures/keep_services.yml b/services/api/test/fixtures/keep_services.yml index d3b1b2ad6a..84ac316d0e 100644 --- a/services/api/test/fixtures/keep_services.yml +++ b/services/api/test/fixtures/keep_services.yml @@ -12,4 +12,12 @@ keep1: service_host: keep1.qr1hi.arvadosapi.com service_port: 25107 service_ssl_flag: false - service_type: disk \ No newline at end of file + service_type: disk + +proxy: + uuid: zzzzz-bi6l4-h0a0xwut9qa6g3a + owner_uuid: zzzzz-tpzed-d9tiejq69daie8f + service_host: keep.qr1hi.arvadosapi.com + service_port: 25333 + service_ssl_flag: true + service_type: proxy diff --git a/services/api/test/integration/keep_proxy_test.rb b/services/api/test/integration/keep_proxy_test.rb new file mode 100644 index 0000000000..130b2527ab --- /dev/null +++ b/services/api/test/integration/keep_proxy_test.rb @@ -0,0 +1,25 @@ +require 'test_helper' + +class KeepProxyTest < ActionDispatch::IntegrationTest + test "request keep disks" do + get "/arvados/v1/keep_services/accessable", {:format => :json}, auth(:active) + assert_response :success + services = json_response['items'] + + assert_equal 2, services.length + assert_equal 'disk', services[0]['service_type'] + assert_equal 'disk', services[1]['service_type'] + + get "/arvados/v1/keep_services/accessable", {:format => :json}, auth(:active).merge({'HTTP_X_KEEP_PROXY_REQUIRED' => true}) + assert_response :success + services = json_response['items'] + + assert_equal 1, services.length + + assert_equal "zzzzz-bi6l4-h0a0xwut9qa6g3a", services[0]['uuid'] + assert_equal "keep.qr1hi.arvadosapi.com", services[0]['service_host'] + assert_equal 25333, services[0]['service_port'] + assert_equal true, services[0]['service_ssl_flag'] + assert_equal 'proxy', services[0]['service_type'] + end +end