[ARVADOS] updated: 1.3.0-557-g82d7893e9
Git user
git at public.curoverse.com
Tue Mar 26 18:34:43 UTC 2019
Summary of changes:
.../api/app/controllers/application_controller.rb | 2 +-
.../app/controllers/user_sessions_controller.rb | 2 +-
.../api_client_authorizations_api_test.rb | 52 +--
.../api_client_authorizations_scopes_test.rb | 22 +-
.../api/test/integration/collections_api_test.rb | 226 ++++++-----
.../integration/collections_performance_test.rb | 20 +-
.../api/test/integration/container_auth_test.rb | 46 +--
services/api/test/integration/cross_origin_test.rb | 12 +-
.../api/test/integration/crunch_dispatch_test.rb | 20 +-
.../api/test/integration/database_reset_test.rb | 29 +-
services/api/test/integration/errors_test.rb | 2 +-
services/api/test/integration/groups_test.rb | 104 ++---
services/api/test/integration/jobs_api_test.rb | 16 +-
services/api/test/integration/keep_proxy_test.rb | 8 +-
.../api/test/integration/login_workflow_test.rb | 15 +-
.../api/test/integration/noop_deep_munge_test.rb | 35 +-
services/api/test/integration/permissions_test.rb | 430 ++++++++++++---------
services/api/test/integration/pipeline_test.rb | 10 +-
.../api/test/integration/reader_tokens_test.rb | 10 +-
services/api/test/integration/remote_user_test.rb | 116 +++---
services/api/test/integration/select_test.rb | 34 +-
.../test/integration/serialized_encoding_test.rb | 3 +-
.../api/test/integration/user_sessions_test.rb | 4 +-
services/api/test/integration/users_test.rb | 156 ++++----
services/api/test/integration/valid_links_test.rb | 48 ++-
25 files changed, 842 insertions(+), 580 deletions(-)
via 82d7893e9b0816896885b3486b5e388002ec8bcb (commit)
from 261543dfc3ef9c8c6d425e591007bf065ecb254d (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 82d7893e9b0816896885b3486b5e388002ec8bcb
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Tue Mar 26 15:33:15 2019 -0300
14873: Fixes deprecation warnings on integration tests.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb
index 572531a3a..28da97f9e 100644
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@ -283,7 +283,7 @@ class ApplicationController < ActionController::Base
@objects = @objects.order(@orders.join ", ") if @orders.any?
@objects = @objects.limit(@limit)
@objects = @objects.offset(@offset)
- @objects = @objects.uniq(@distinct) if not @distinct.nil?
+ @objects = @objects.distinct(@distinct) if not @distinct.nil?
end
# limit_database_read ensures @objects (which must be an
diff --git a/services/api/app/controllers/user_sessions_controller.rb b/services/api/app/controllers/user_sessions_controller.rb
index 845149fc8..237156f11 100644
--- a/services/api/app/controllers/user_sessions_controller.rb
+++ b/services/api/app/controllers/user_sessions_controller.rb
@@ -13,7 +13,7 @@ class UserSessionsController < ApplicationController
# omniauth callback method
def create
- omniauth = env['omniauth.auth']
+ omniauth = request.env['omniauth.auth']
identity_url_ok = (omniauth['info']['identity_url'].length > 0) rescue false
unless identity_url_ok
diff --git a/services/api/test/integration/api_client_authorizations_api_test.rb b/services/api/test/integration/api_client_authorizations_api_test.rb
index e42a4ef10..b9bfd3a39 100644
--- a/services/api/test/integration/api_client_authorizations_api_test.rb
+++ b/services/api/test/integration/api_client_authorizations_api_test.rb
@@ -8,43 +8,51 @@ class ApiClientAuthorizationsApiTest < ActionDispatch::IntegrationTest
fixtures :all
test "create system auth" do
- post "/arvados/v1/api_client_authorizations/create_system_auth", {:format => :json, :scopes => ['test'].to_json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin_trustedclient).api_token}"}
+ post "/arvados/v1/api_client_authorizations/create_system_auth",
+ params: {:format => :json, :scopes => ['test'].to_json},
+ headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin_trustedclient).api_token}"}
assert_response :success
end
test "create token for different user" do
- post "/arvados/v1/api_client_authorizations", {
- :format => :json,
- :api_client_authorization => {
- :owner_uuid => users(:spectator).uuid
- }
- }, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin_trustedclient).api_token}"}
+ post "/arvados/v1/api_client_authorizations",
+ params: {
+ :format => :json,
+ :api_client_authorization => {
+ :owner_uuid => users(:spectator).uuid
+ }
+ },
+ headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin_trustedclient).api_token}"}
assert_response :success
- get "/arvados/v1/users/current", {
- :format => :json
- }, {'HTTP_AUTHORIZATION' => "OAuth2 #{json_response['api_token']}"}
+ get "/arvados/v1/users/current",
+ params: {:format => :json},
+ headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{json_response['api_token']}"}
@json_response = nil
assert_equal users(:spectator).uuid, json_response['uuid']
end
test "refuse to create token for different user if not trusted client" do
- post "/arvados/v1/api_client_authorizations", {
- :format => :json,
- :api_client_authorization => {
- :owner_uuid => users(:spectator).uuid
- }
- }, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin).api_token}"}
+ post "/arvados/v1/api_client_authorizations",
+ params: {
+ :format => :json,
+ :api_client_authorization => {
+ :owner_uuid => users(:spectator).uuid
+ }
+ },
+ headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin).api_token}"}
assert_response 403
end
test "refuse to create token for different user if not admin" do
- post "/arvados/v1/api_client_authorizations", {
- :format => :json,
- :api_client_authorization => {
- :owner_uuid => users(:spectator).uuid
- }
- }, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active_trustedclient).api_token}"}
+ post "/arvados/v1/api_client_authorizations",
+ params: {
+ :format => :json,
+ :api_client_authorization => {
+ :owner_uuid => users(:spectator).uuid
+ }
+ },
+ headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active_trustedclient).api_token}"}
assert_response 403
end
diff --git a/services/api/test/integration/api_client_authorizations_scopes_test.rb b/services/api/test/integration/api_client_authorizations_scopes_test.rb
index dfb57496a..d015e450a 100644
--- a/services/api/test/integration/api_client_authorizations_scopes_test.rb
+++ b/services/api/test/integration/api_client_authorizations_scopes_test.rb
@@ -16,7 +16,7 @@ class ApiTokensScopeTest < ActionDispatch::IntegrationTest
end
test "user list token can only list users" do
- get_args = [{}, auth(:active_userlist)]
+ get_args = [params: {}, headers: auth(:active_userlist)]
get(v1_url('users'), *get_args)
assert_response :success
get(v1_url('users', ''), *get_args) # Add trailing slash.
@@ -28,9 +28,9 @@ class ApiTokensScopeTest < ActionDispatch::IntegrationTest
end
test "narrow + wide scoped tokens for different users" do
- get_args = [{
+ get_args = [params: {
reader_tokens: [api_client_authorizations(:anonymous).api_token]
- }, auth(:active_userlist)]
+ }, headers: auth(:active_userlist)]
get(v1_url('users'), *get_args)
assert_response :success
get(v1_url('users', ''), *get_args) # Add trailing slash.
@@ -42,7 +42,7 @@ class ApiTokensScopeTest < ActionDispatch::IntegrationTest
end
test "specimens token can see exactly owned specimens" do
- get_args = [{}, auth(:active_specimens)]
+ get_args = [params: {}, headers: auth(:active_specimens)]
get(v1_url('specimens'), *get_args)
assert_response 403
get(v1_url('specimens', specimens(:owned_by_active_user).uuid), *get_args)
@@ -55,7 +55,9 @@ class ApiTokensScopeTest < ActionDispatch::IntegrationTest
test "token with multiple scopes can use them all" do
def get_token_count
- get(v1_url('api_client_authorizations'), {}, auth(:active_apitokens))
+ get(v1_url('api_client_authorizations'),
+ params: {},
+ headers: auth(:active_apitokens))
assert_response :success
token_count = JSON.parse(@response.body)['items_available']
assert_not_nil(token_count, "could not find token count")
@@ -65,22 +67,22 @@ class ApiTokensScopeTest < ActionDispatch::IntegrationTest
token_count = get_token_count
# Test the POST scope.
post(v1_url('api_client_authorizations'),
- {api_client_authorization: {user_id: users(:active).id}},
- auth(:active_apitokens))
+ params: {api_client_authorization: {user_id: users(:active).id}},
+ headers: auth(:active_apitokens))
assert_response :success
assert_equal(token_count + 1, get_token_count,
"token count suggests POST was not accepted")
# Test other requests are denied.
get(v1_url('api_client_authorizations',
api_client_authorizations(:active_apitokens).uuid),
- {}, auth(:active_apitokens))
+ params: {}, headers: auth(:active_apitokens))
assert_response 403
end
test "token without scope has no access" do
# Logs are good for this test, because logs have relatively
# few access controls enforced at the model level.
- req_args = [{}, auth(:admin_noscope)]
+ req_args = [params: {}, headers: auth(:admin_noscope)]
get(v1_url('logs'), *req_args)
assert_response 403
get(v1_url('logs', logs(:noop).uuid), *req_args)
@@ -95,7 +97,7 @@ class ApiTokensScopeTest < ActionDispatch::IntegrationTest
def vm_logins_url(name)
v1_url('virtual_machines', virtual_machines(name).uuid, 'logins')
end
- get_args = [{}, auth(:admin_vm)]
+ get_args = [params: {}, headers: auth(:admin_vm)]
get(vm_logins_url(:testvm), *get_args)
assert_response :success
get(vm_logins_url(:testvm2), *get_args)
diff --git a/services/api/test/integration/collections_api_test.rb b/services/api/test/integration/collections_api_test.rb
index ac1ca6637..709657534 100644
--- a/services/api/test/integration/collections_api_test.rb
+++ b/services/api/test/integration/collections_api_test.rb
@@ -8,96 +8,120 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
fixtures :all
test "should get index" do
- get "/arvados/v1/collections", {:format => :json}, auth(:active)
+ get "/arvados/v1/collections",
+ params: {:format => :json},
+ headers: auth(:active)
assert_response :success
assert_equal "arvados#collectionList", json_response['kind']
end
test "get index with filters= (empty string)" do
- get "/arvados/v1/collections", {:format => :json, :filters => ''}, auth(:active)
+ get "/arvados/v1/collections",
+ params: {:format => :json, :filters => ''},
+ headers: auth(:active)
assert_response :success
assert_equal "arvados#collectionList", json_response['kind']
end
test "get index with invalid filters (array of strings) responds 422" do
- get "/arvados/v1/collections", {
- :format => :json,
- :filters => ['uuid', '=', 'ad02e37b6a7f45bbe2ead3c29a109b8a+54'].to_json
- }, auth(:active)
+ get "/arvados/v1/collections",
+ params: {
+ :format => :json,
+ :filters => ['uuid', '=', 'ad02e37b6a7f45bbe2ead3c29a109b8a+54'].to_json
+ },
+ headers: auth(:active)
assert_response 422
assert_match(/nvalid element.*not an array/, json_response['errors'].join(' '))
end
test "get index with invalid filters (unsearchable column) responds 422" do
- get "/arvados/v1/collections", {
- :format => :json,
- :filters => [['this_column_does_not_exist', '=', 'bogus']].to_json
- }, auth(:active)
+ get "/arvados/v1/collections",
+ params: {
+ :format => :json,
+ :filters => [['this_column_does_not_exist', '=', 'bogus']].to_json
+ },
+ headers: auth(:active)
assert_response 422
assert_match(/nvalid attribute/, json_response['errors'].join(' '))
end
test "get index with invalid filters (invalid operator) responds 422" do
- get "/arvados/v1/collections", {
- :format => :json,
- :filters => [['uuid', ':-(', 'displeased']].to_json
- }, auth(:active)
+ get "/arvados/v1/collections",
+ params: {
+ :format => :json,
+ :filters => [['uuid', ':-(', 'displeased']].to_json
+ },
+ headers: auth(:active)
assert_response 422
assert_match(/nvalid operator/, json_response['errors'].join(' '))
end
test "get index with invalid filters (invalid operand type) responds 422" do
- get "/arvados/v1/collections", {
- :format => :json,
- :filters => [['uuid', '=', {foo: 'bar'}]].to_json
- }, auth(:active)
+ get "/arvados/v1/collections",
+ params: {
+ :format => :json,
+ :filters => [['uuid', '=', {foo: 'bar'}]].to_json
+ },
+ headers: auth(:active)
assert_response 422
assert_match(/nvalid operand type/, json_response['errors'].join(' '))
end
test "get index with where= (empty string)" do
- get "/arvados/v1/collections", {:format => :json, :where => ''}, auth(:active)
+ get "/arvados/v1/collections",
+ params: {:format => :json, :where => ''},
+ headers: auth(:active)
assert_response :success
assert_equal "arvados#collectionList", json_response['kind']
end
test "get index with select= (valid attribute)" do
- get "/arvados/v1/collections", {
- :format => :json,
- :select => ['portable_data_hash'].to_json
- }, auth(:active)
+ get "/arvados/v1/collections",
+ params: {
+ :format => :json,
+ :select => ['portable_data_hash'].to_json
+ },
+ headers: auth(:active)
assert_response :success
assert json_response['items'][0].keys.include?('portable_data_hash')
assert not(json_response['items'][0].keys.include?('uuid'))
end
test "get index with select= (invalid attribute) responds 422" do
- get "/arvados/v1/collections", {
- :format => :json,
- :select => ['bogus'].to_json
- }, auth(:active)
+ get "/arvados/v1/collections",
+ params: {
+ :format => :json,
+ :select => ['bogus'].to_json
+ },
+ headers: auth(:active)
assert_response 422
assert_match(/Invalid attribute.*bogus/, json_response['errors'].join(' '))
end
test "get index with select= (invalid attribute type) responds 422" do
- get "/arvados/v1/collections", {
- :format => :json,
- :select => [['bogus']].to_json
- }, auth(:active)
+ get "/arvados/v1/collections",
+ params: {
+ :format => :json,
+ :select => [['bogus']].to_json
+ },
+ headers: auth(:active)
assert_response 422
assert_match(/Invalid attribute.*bogus/, json_response['errors'].join(' '))
end
test "controller 404 response is json" do
- get "/arvados/v1/thingsthatdonotexist", {:format => :xml}, auth(:active)
+ get "/arvados/v1/thingsthatdonotexist",
+ params: {:format => :xml},
+ headers: auth(:active)
assert_response 404
assert_equal 1, json_response['errors'].length
assert_equal true, json_response['errors'][0].is_a?(String)
end
test "object 404 response is json" do
- get "/arvados/v1/groups/zzzzz-j7d0g-o5ba971173cup4f", {}, auth(:active)
+ get "/arvados/v1/groups/zzzzz-j7d0g-o5ba971173cup4f",
+ params: {},
+ headers: auth(:active)
assert_response 404
assert_equal 1, json_response['errors'].length
assert_equal true, json_response['errors'][0].is_a?(String)
@@ -110,10 +134,12 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
}
signed_locator = Blob.sign_locator('bad42fa702ae3ea7d888fef11b46f450+44',
signing_opts)
- post "/arvados/v1/collections", {
- format: :json,
- collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\",\"portable_data_hash\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}"
- }, auth(:active)
+ post "/arvados/v1/collections",
+ params: {
+ format: :json,
+ collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\",\"portable_data_hash\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}"
+ },
+ headers: auth(:active)
assert_response 200
assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash']
end
@@ -125,10 +151,12 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
}
signed_locator = Blob.sign_locator('bad42fa702ae3ea7d888fef11b46f450+44',
signing_opts)
- post "/arvados/v1/collections", {
- format: :json,
- collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\"}"
- }, auth(:active)
+ post "/arvados/v1/collections",
+ params: {
+ format: :json,
+ collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\"}"
+ },
+ headers: auth(:active)
assert_response 200
assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash']
end
@@ -140,25 +168,29 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
}
signed_locator = Blob.sign_locator('bad42fa702ae3ea7d888fef11b46f450+44',
signing_opts)
- post "/arvados/v1/collections", {
- format: :json,
- collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\",\"portable_data_hash\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}"
- }, auth(:active)
+ post "/arvados/v1/collections",
+ params: {
+ format: :json,
+ collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\",\"portable_data_hash\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}"
+ },
+ headers: auth(:active)
assert_response 200
assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash']
- put "/arvados/v1/collections/#{json_response['uuid']}", {
- format: :json,
- collection: { name: "a name" }
- }, auth(:active)
+ put "/arvados/v1/collections/#{json_response['uuid']}",
+ params: {
+ format: :json,
+ collection: { name: "a name" }
+ },
+ headers: auth(:active)
assert_response 200
assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash']
assert_equal 'a name', json_response['name']
- get "/arvados/v1/collections/#{json_response['uuid']}", {
- format: :json,
- }, auth(:active)
+ get "/arvados/v1/collections/#{json_response['uuid']}",
+ params: {format: :json},
+ headers: auth(:active)
assert_response 200
assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash']
@@ -169,17 +201,19 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
collection = collections(:multilevel_collection_1)
# update collection's description
- put "/arvados/v1/collections/#{collection['uuid']}", {
- format: :json,
- collection: { description: "something specific" }
- }, auth(:active)
+ put "/arvados/v1/collections/#{collection['uuid']}",
+ params: {
+ format: :json,
+ collection: { description: "something specific" }
+ },
+ headers: auth(:active)
assert_response :success
assert_equal 'something specific', json_response['description']
# get the collection and verify newly added description
- get "/arvados/v1/collections/#{collection['uuid']}", {
- format: :json,
- }, auth(:active)
+ get "/arvados/v1/collections/#{collection['uuid']}",
+ params: {format: :json},
+ headers: auth(:active)
assert_response 200
assert_equal 'something specific', json_response['description']
@@ -191,10 +225,12 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
test "create collection, update manifest, and search with filename" do
# create collection
signed_manifest = Collection.sign_manifest(". bad42fa702ae3ea7d888fef11b46f450+44 0:44:my_test_file.txt\n", api_token(:active))
- post "/arvados/v1/collections", {
- format: :json,
- collection: {manifest_text: signed_manifest}.to_json,
- }, auth(:active)
+ post "/arvados/v1/collections",
+ params: {
+ format: :json,
+ collection: {manifest_text: signed_manifest}.to_json,
+ },
+ headers: auth(:active)
assert_response :success
assert_equal true, json_response['manifest_text'].include?('my_test_file.txt')
assert_includes json_response['manifest_text'], 'my_test_file.txt'
@@ -206,10 +242,12 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
# update the collection's manifest text
signed_manifest = Collection.sign_manifest(". bad42fa702ae3ea7d888fef11b46f450+44 0:44:my_updated_test_file.txt\n", api_token(:active))
- put "/arvados/v1/collections/#{created['uuid']}", {
- format: :json,
- collection: {manifest_text: signed_manifest}.to_json,
- }, auth(:active)
+ put "/arvados/v1/collections/#{created['uuid']}",
+ params: {
+ format: :json,
+ collection: {manifest_text: signed_manifest}.to_json,
+ },
+ headers: auth(:active)
assert_response :success
assert_equal created['uuid'], json_response['uuid']
assert_includes json_response['manifest_text'], 'my_updated_test_file.txt'
@@ -222,9 +260,9 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
end
def search_using_filter search_filter, expected_items
- get '/arvados/v1/collections', {
- :filters => [['any', 'ilike', "%#{search_filter}%"]].to_json
- }, auth(:active)
+ get '/arvados/v1/collections',
+ params: {:filters => [['any', 'ilike', "%#{search_filter}%"]].to_json},
+ headers: auth(:active)
assert_response :success
response_items = json_response['items']
assert_not_nil response_items
@@ -240,10 +278,12 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
test "search collection using full text search" do
# create collection to be searched for
signed_manifest = Collection.sign_manifest(". 85877ca2d7e05498dd3d109baf2df106+95+A3a4e26a366ee7e4ed3e476ccf05354761be2e4ae at 545a9920 0:95:file_in_subdir1\n./subdir2/subdir3 2bbc341c702df4d8f42ec31f16c10120+64+A315d7e7bad2ce937e711fc454fae2d1194d14d64 at 545a9920 0:32:file1_in_subdir3.txt 32:32:file2_in_subdir3.txt\n./subdir2/subdir3/subdir4 2bbc341c702df4d8f42ec31f16c10120+64+A315d7e7bad2ce937e711fc454fae2d1194d14d64 at 545a9920 0:32:file3_in_subdir4.txt 32:32:file4_in_subdir4.txt\n", api_token(:active))
- post "/arvados/v1/collections", {
- format: :json,
- collection: {description: 'specific collection description', manifest_text: signed_manifest}.to_json,
- }, auth(:active)
+ post "/arvados/v1/collections",
+ params: {
+ format: :json,
+ collection: {description: 'specific collection description', manifest_text: signed_manifest}.to_json,
+ },
+ headers: auth(:active)
assert_response :success
assert_equal true, json_response['manifest_text'].include?('file4_in_subdir4.txt')
@@ -260,9 +300,9 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
end
def search_using_full_text_search search_filter, expected_items
- get '/arvados/v1/collections', {
- :filters => [['any', '@@', search_filter]].to_json
- }, auth(:active)
+ get '/arvados/v1/collections',
+ params: {:filters => [['any', '@@', search_filter]].to_json},
+ headers: auth(:active)
assert_response :success
response_items = json_response['items']
assert_not_nil response_items
@@ -277,9 +317,9 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
# search for the filename in the file_names column and expect error
test "full text search not supported for individual columns" do
- get '/arvados/v1/collections', {
- :filters => [['name', '@@', 'General']].to_json
- }, auth(:active)
+ get '/arvados/v1/collections',
+ params: {:filters => [['name', '@@', 'General']].to_json},
+ headers: auth(:active)
assert_response 422
end
@@ -292,9 +332,9 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
test "full text search ignores special characters and finds with filter #{search_filter}" do
# description: The quick_brown_fox jumps over the lazy_dog
# full text search treats '_' as space apparently
- get '/arvados/v1/collections', {
- :filters => [['any', '@@', search_filter]].to_json
- }, auth(:active)
+ get '/arvados/v1/collections',
+ params: {:filters => [['any', '@@', search_filter]].to_json},
+ headers: auth(:active)
assert_response 200
response_items = json_response['items']
assert_not_nil response_items
@@ -307,20 +347,24 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
test "create and get collection with properties" do
# create collection to be searched for
signed_manifest = Collection.sign_manifest(". bad42fa702ae3ea7d888fef11b46f450+44 0:44:my_test_file.txt\n", api_token(:active))
- post "/arvados/v1/collections", {
- format: :json,
- collection: {manifest_text: signed_manifest}.to_json,
- }, auth(:active)
+ post "/arvados/v1/collections",
+ params: {
+ format: :json,
+ collection: {manifest_text: signed_manifest}.to_json,
+ },
+ headers: auth(:active)
assert_response 200
assert_not_nil json_response['uuid']
assert_not_nil json_response['properties']
assert_empty json_response['properties']
# update collection's description
- put "/arvados/v1/collections/#{json_response['uuid']}", {
- format: :json,
- collection: { properties: {'property_1' => 'value_1'} }
- }, auth(:active)
+ put "/arvados/v1/collections/#{json_response['uuid']}",
+ params: {
+ format: :json,
+ collection: { properties: {'property_1' => 'value_1'} }
+ },
+ headers: auth(:active)
assert_response :success
assert_equal 'value_1', json_response['properties']['property_1']
end
diff --git a/services/api/test/integration/collections_performance_test.rb b/services/api/test/integration/collections_performance_test.rb
index 3d13d144b..b925fbf77 100644
--- a/services/api/test/integration/collections_performance_test.rb
+++ b/services/api/test/integration/collections_performance_test.rb
@@ -22,24 +22,30 @@ class CollectionsApiPerformanceTest < ActionDispatch::IntegrationTest
SafeJSON.dump({"manifest_text" => bigmanifest})
end
time_block 'create' do
- post '/arvados/v1/collections', {collection: json}, auth(:active)
+ post '/arvados/v1/collections',
+ params: {collection: json},
+ headers: auth(:active)
assert_response :success
end
uuid = json_response['uuid']
time_block 'read' do
- get '/arvados/v1/collections/' + uuid, {}, auth(:active)
+ get '/arvados/v1/collections/' + uuid, params: {}, headers: auth(:active)
assert_response :success
end
time_block 'list' do
- get '/arvados/v1/collections', {select: ['manifest_text'], filters: [['uuid', '=', uuid]].to_json}, auth(:active)
+ get '/arvados/v1/collections',
+ params: {select: ['manifest_text'], filters: [['uuid', '=', uuid]].to_json},
+ headers: auth(:active)
assert_response :success
end
time_block 'update' do
- put '/arvados/v1/collections/' + uuid, {collection: json}, auth(:active)
+ put '/arvados/v1/collections/' + uuid,
+ params: {collection: json},
+ headers: auth(:active)
assert_response :success
end
time_block 'delete' do
- delete '/arvados/v1/collections/' + uuid, {}, auth(:active)
+ delete '/arvados/v1/collections/' + uuid, params: {}, headers: auth(:active)
end
end
@@ -53,7 +59,9 @@ class CollectionsApiPerformanceTest < ActionDispatch::IntegrationTest
SafeJSON.dump({manifest_text: hugemanifest})
end
vmpeak "post" do
- post '/arvados/v1/collections', {collection: json}, auth(:active)
+ post '/arvados/v1/collections',
+ params: {collection: json},
+ headers: auth(:active)
end
end
end
diff --git a/services/api/test/integration/container_auth_test.rb b/services/api/test/integration/container_auth_test.rb
index 552cce44b..2a1ebabc0 100644
--- a/services/api/test/integration/container_auth_test.rb
+++ b/services/api/test/integration/container_auth_test.rb
@@ -8,57 +8,59 @@ class ContainerAuthTest < ActionDispatch::IntegrationTest
fixtures :all
test "container token validate, Running, regular auth" do
- get "/arvados/v1/containers/current", {
- :format => :json
- }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:running_container_auth).token}/#{containers(:running).uuid}"}
+ get "/arvados/v1/containers/current",
+ params: {:format => :json},
+ headers: {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:running_container_auth).token}/#{containers(:running).uuid}"}
# Container is Running, token can be used
assert_response :success
assert_equal containers(:running).uuid, json_response['uuid']
end
test "container token validate, Locked, runtime_token" do
- get "/arvados/v1/containers/current", {
- :format => :json
- }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:runtime_token).uuid}"}
+ get "/arvados/v1/containers/current",
+ params: {:format => :json},
+ headers: {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:runtime_token).uuid}"}
# Container is Running, token can be used
assert_response :success
assert_equal containers(:runtime_token).uuid, json_response['uuid']
end
test "container token validate, Cancelled, runtime_token" do
- put "/arvados/v1/containers/#{containers(:runtime_token).uuid}", {
- :format => :json,
- :container => {:state => "Cancelled"}
- }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:dispatch1).token}"}
+ put "/arvados/v1/containers/#{containers(:runtime_token).uuid}",
+ params: {
+ :format => :json,
+ :container => {:state => "Cancelled"}
+ },
+ headers: {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:dispatch1).token}"}
assert_response :success
- get "/arvados/v1/containers/current", {
- :format => :json
- }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:runtime_token).uuid}"}
+ get "/arvados/v1/containers/current",
+ params: {:format => :json},
+ headers: {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:runtime_token).uuid}"}
# Container is Queued, token cannot be used
assert_response 401
end
test "container token validate, Running, without optional portion" do
- get "/arvados/v1/containers/current", {
- :format => :json
- }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:running_container_auth).token}"}
+ get "/arvados/v1/containers/current",
+ params: {:format => :json},
+ headers: {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:running_container_auth).token}"}
# Container is Running, token can be used
assert_response :success
assert_equal containers(:running).uuid, json_response['uuid']
end
test "container token validate, Locked, runtime_token, without optional portion" do
- get "/arvados/v1/containers/current", {
- :format => :json
- }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}"}
+ get "/arvados/v1/containers/current",
+ params: {:format => :json},
+ headers: {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}"}
# runtime_token without container uuid won't return 'current'
assert_response 404
end
test "container token validate, wrong container uuid" do
- get "/arvados/v1/containers/current", {
- :format => :json
- }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:running).uuid}"}
+ get "/arvados/v1/containers/current",
+ params: {:format => :json},
+ headers: {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:running).uuid}"}
# Container uuid mismatch, token can't be used
assert_response 401
end
diff --git a/services/api/test/integration/cross_origin_test.rb b/services/api/test/integration/cross_origin_test.rb
index 5109ea46a..e3099f157 100644
--- a/services/api/test/integration/cross_origin_test.rb
+++ b/services/api/test/integration/cross_origin_test.rb
@@ -15,19 +15,19 @@ class CrossOriginTest < ActionDispatch::IntegrationTest
%w(/login /logout /auth/example/callback /auth/joshid).each do |path|
test "OPTIONS requests are refused at #{path}" do
- options path, {}, {}
+ options path, params: {}, headers: {}
assert_no_cors_headers
end
test "CORS headers do not exist at GET #{path}" do
- get path, {}, {}
+ get path, params: {}, headers: {}
assert_no_cors_headers
end
end
%w(/discovery/v1/apis/arvados/v1/rest).each do |path|
test "CORS headers are set at GET #{path}" do
- get path, {}, {}
+ get path, params: {}, headers: {}
assert_response :success
assert_cors_headers
end
@@ -37,14 +37,14 @@ class CrossOriginTest < ActionDispatch::IntegrationTest
'/arvados/v1/users',
'/arvados/v1/api_client_authorizations'].each do |path|
test "CORS headers are set and body is empty at OPTIONS #{path}" do
- options path, {}, {}
+ options path, params: {}, headers: {}
assert_response :success
assert_cors_headers
assert_equal '', response.body
end
test "CORS headers are set at authenticated GET #{path}" do
- get path, {}, auth(:active_trustedclient)
+ get path, params: {}, headers: auth(:active_trustedclient)
assert_response :success
assert_cors_headers
end
@@ -55,7 +55,7 @@ class CrossOriginTest < ActionDispatch::IntegrationTest
# does not grant access to any resources.
['GET', 'POST'].each do |method|
test "Session does not work at #{method} #{path}" do
- send method.downcase, path, {format: 'json'}, {user_id: 1}
+ send method.downcase, path, params: {format: 'json'}, headers: {user_id: 1}
assert_response 401
assert_cors_headers
end
diff --git a/services/api/test/integration/crunch_dispatch_test.rb b/services/api/test/integration/crunch_dispatch_test.rb
index dc215f2a3..479bda40c 100644
--- a/services/api/test/integration/crunch_dispatch_test.rb
+++ b/services/api/test/integration/crunch_dispatch_test.rb
@@ -28,15 +28,17 @@ class CrunchDispatchIntegrationTest < ActionDispatch::IntegrationTest
end
test "job runs" do
- post "/arvados/v1/jobs", {
- format: "json",
- job: {
- script: "log",
- repository: "active/crunchdispatchtest",
- script_version: "f35f99b7d32bac257f5989df02b9f12ee1a9b0d6",
- script_parameters: "{}"
- }
- }, auth(:admin)
+ post "/arvados/v1/jobs",
+ params: {
+ format: "json",
+ job: {
+ script: "log",
+ repository: "active/crunchdispatchtest",
+ script_version: "f35f99b7d32bac257f5989df02b9f12ee1a9b0d6",
+ script_parameters: "{}"
+ }
+ },
+ headers: auth(:admin)
assert_response :success
end
end
diff --git a/services/api/test/integration/database_reset_test.rb b/services/api/test/integration/database_reset_test.rb
index 430474ea0..7015453a9 100644
--- a/services/api/test/integration/database_reset_test.rb
+++ b/services/api/test/integration/database_reset_test.rb
@@ -10,7 +10,7 @@ class DatabaseResetTest < ActionDispatch::IntegrationTest
begin
Rails.env = 'production'
Rails.application.reload_routes!
- post '/database/reset', {}, auth(:admin)
+ post '/database/reset', params: {}, headers: auth(:admin)
assert_response 404
ensure
Rails.env = rails_env_was
@@ -19,7 +19,7 @@ class DatabaseResetTest < ActionDispatch::IntegrationTest
end
test "reset fails with non-admin token" do
- post '/database/reset', {}, auth(:active)
+ post '/database/reset', params: {}, headers: auth(:active)
assert_response 403
end
@@ -28,24 +28,25 @@ class DatabaseResetTest < ActionDispatch::IntegrationTest
admin_auth = auth(:admin)
authorize_with :admin
- post '/database/reset', {}, admin_auth
+ post '/database/reset', params: {}, headers: admin_auth
assert_response :success
- post '/arvados/v1/specimens', {specimen: '{}'}, active_auth
+ post '/arvados/v1/specimens', params: {specimen: '{}'}, headers: active_auth
assert_response :success
new_uuid = json_response['uuid']
- get '/arvados/v1/specimens/'+new_uuid, {}, active_auth
+ get '/arvados/v1/specimens/'+new_uuid, params: {}, headers: active_auth
assert_response :success
put('/arvados/v1/specimens/'+new_uuid,
- {specimen: '{"properties":{}}'}, active_auth)
+ params: {specimen: '{"properties":{}}'},
+ headers: active_auth)
assert_response :success
- delete '/arvados/v1/specimens/'+new_uuid, {}, active_auth
+ delete '/arvados/v1/specimens/'+new_uuid, params: {}, headers: active_auth
assert_response :success
- get '/arvados/v1/specimens/'+new_uuid, {}, active_auth
+ get '/arvados/v1/specimens/'+new_uuid, params: {}, headers: active_auth
assert_response 404
end
@@ -55,23 +56,23 @@ class DatabaseResetTest < ActionDispatch::IntegrationTest
old_uuid = specimens(:owned_by_active_user).uuid
authorize_with :admin
- post '/database/reset', {}, admin_auth
+ post '/database/reset', params: {}, headers: admin_auth
assert_response :success
- delete '/arvados/v1/specimens/' + old_uuid, {}, active_auth
+ delete '/arvados/v1/specimens/' + old_uuid, params: {}, headers: active_auth
assert_response :success
- post '/arvados/v1/specimens', {specimen: '{}'}, active_auth
+ post '/arvados/v1/specimens', params: {specimen: '{}'}, headers: active_auth
assert_response :success
new_uuid = json_response['uuid']
# Reset to fixtures.
- post '/database/reset', {}, admin_auth
+ post '/database/reset', params: {}, headers: admin_auth
assert_response :success
# New specimen should disappear. Old specimen should reappear.
- get '/arvados/v1/specimens/'+new_uuid, {}, active_auth
+ get '/arvados/v1/specimens/'+new_uuid, params: {}, headers: active_auth
assert_response 404
- get '/arvados/v1/specimens/'+old_uuid, {}, active_auth
+ get '/arvados/v1/specimens/'+old_uuid, params: {}, headers: active_auth
assert_response :success
end
end
diff --git a/services/api/test/integration/errors_test.rb b/services/api/test/integration/errors_test.rb
index 142455880..d04e38383 100644
--- a/services/api/test/integration/errors_test.rb
+++ b/services/api/test/integration/errors_test.rb
@@ -9,7 +9,7 @@ class ErrorsTest < ActionDispatch::IntegrationTest
%w(/arvados/v1/shoes /arvados/shoes /shoes /nodes /users).each do |path|
test "non-existent route #{path}" do
- get path, {:format => :json}, auth(:active)
+ get path, params: {:format => :json}, headers: auth(:active)
assert_nil assigns(:objects)
assert_nil assigns(:object)
assert_not_nil json_response['errors']
diff --git a/services/api/test/integration/groups_test.rb b/services/api/test/integration/groups_test.rb
index cf0261585..3789ac7fb 100644
--- a/services/api/test/integration/groups_test.rb
+++ b/services/api/test/integration/groups_test.rb
@@ -9,12 +9,14 @@ class GroupsTest < ActionDispatch::IntegrationTest
test "results are consistent when provided orders #{orders} is incomplete" do
last = nil
(0..20).each do
- get '/arvados/v1/groups/contents', {
- id: groups(:aproject).uuid,
- filters: [["uuid", "is_a", "arvados#collection"]].to_json,
- orders: orders.to_json,
- format: :json,
- }, auth(:active)
+ get '/arvados/v1/groups/contents',
+ params: {
+ id: groups(:aproject).uuid,
+ filters: [["uuid", "is_a", "arvados#collection"]].to_json,
+ orders: orders.to_json,
+ format: :json,
+ },
+ headers: auth(:active)
assert_response :success
if last.nil?
last = json_response['items']
@@ -32,12 +34,14 @@ class GroupsTest < ActionDispatch::IntegrationTest
uuid_received = {}
owner_received = {}
while true
- get "/arvados/v1/groups/contents", {
- id: groups(:aproject).uuid,
- limit: limit,
- offset: offset,
- format: :json,
- }, auth(:active)
+ get "/arvados/v1/groups/contents",
+ params: {
+ id: groups(:aproject).uuid,
+ limit: limit,
+ offset: offset,
+ format: :json,
+ },
+ headers: auth(:active)
assert_response :success
assert_operator(0, :<, json_response['items'].count,
@@ -71,11 +75,13 @@ class GroupsTest < ActionDispatch::IntegrationTest
['no-such-thing', false], # script_parameter of pipeline instances
].each do |search_filter, expect_results|
test "full text search of group-owned objects for #{search_filter}" do
- get "/arvados/v1/groups/contents", {
- id: groups(:aproject).uuid,
- limit: 5,
- :filters => [['any', '@@', search_filter]].to_json
- }, auth(:active)
+ get "/arvados/v1/groups/contents",
+ params: {
+ id: groups(:aproject).uuid,
+ limit: 5,
+ :filters => [['any', '@@', search_filter]].to_json
+ },
+ headers: auth(:active)
assert_response :success
if expect_results
refute_empty json_response['items']
@@ -90,18 +96,22 @@ class GroupsTest < ActionDispatch::IntegrationTest
end
test "full text search is not supported for individual columns" do
- get "/arvados/v1/groups/contents", {
- :filters => [['name', '@@', 'Private']].to_json
- }, auth(:active)
+ get "/arvados/v1/groups/contents",
+ params: {
+ :filters => [['name', '@@', 'Private']].to_json
+ },
+ headers: auth(:active)
assert_response 422
end
test "group contents with include trash collections" do
- get "/arvados/v1/groups/contents", {
- include_trash: "true",
- filters: [["uuid", "is_a", "arvados#collection"]].to_json,
- limit: 1000
- }, auth(:active)
+ get "/arvados/v1/groups/contents",
+ params: {
+ include_trash: "true",
+ filters: [["uuid", "is_a", "arvados#collection"]].to_json,
+ limit: 1000
+ },
+ headers: auth(:active)
assert_response 200
coll_uuids = []
@@ -111,10 +121,12 @@ class GroupsTest < ActionDispatch::IntegrationTest
end
test "group contents without trash collections" do
- get "/arvados/v1/groups/contents", {
- filters: [["uuid", "is_a", "arvados#collection"]].to_json,
- limit: 1000
- }, auth(:active)
+ get "/arvados/v1/groups/contents",
+ params: {
+ filters: [["uuid", "is_a", "arvados#collection"]].to_json,
+ limit: 1000
+ },
+ headers: auth(:active)
assert_response 200
coll_uuids = []
@@ -134,7 +146,7 @@ class NonTransactionalGroupsTest < ActionDispatch::IntegrationTest
teardown do
# Explicitly reset the database after each test.
- post '/database/reset', {}, auth(:admin)
+ post '/database/reset', params: {}, headers: auth(:admin)
assert_response :success
end
@@ -144,29 +156,35 @@ class NonTransactionalGroupsTest < ActionDispatch::IntegrationTest
assert_equal nil, Group.find_by_name(name)
# Trigger the asynchronous permission update by using async=true parameter.
- post "/arvados/v1/groups", {
- group: {
- name: name
+ post "/arvados/v1/groups",
+ params: {
+ group: {
+ name: name
+ },
+ async: true
},
- async: true
- }, auth(:active)
+ headers: auth(:active)
assert_response 202
# The group exists on the database, but it's not accessible yet.
assert_not_nil Group.find_by_name(name)
- get "/arvados/v1/groups", {
- filters: [["name", "=", name]].to_json,
- limit: 10
- }, auth(:active)
+ get "/arvados/v1/groups",
+ params: {
+ filters: [["name", "=", name]].to_json,
+ limit: 10
+ },
+ headers: auth(:active)
assert_response 200
assert_equal 0, json_response['items_available']
# Wait a bit and try again.
sleep(1)
- get "/arvados/v1/groups", {
- filters: [["name", "=", name]].to_json,
- limit: 10
- }, auth(:active)
+ get "/arvados/v1/groups",
+ params: {
+ filters: [["name", "=", name]].to_json,
+ limit: 10
+ },
+ headers: auth(:active)
assert_response 200
assert_equal 1, json_response['items_available']
end
diff --git a/services/api/test/integration/jobs_api_test.rb b/services/api/test/integration/jobs_api_test.rb
index b8b338f14..4499a92cd 100644
--- a/services/api/test/integration/jobs_api_test.rb
+++ b/services/api/test/integration/jobs_api_test.rb
@@ -8,29 +8,35 @@ class JobsApiTest < ActionDispatch::IntegrationTest
fixtures :all
test "cancel job" do
- post "/arvados/v1/jobs/#{jobs(:running).uuid}/cancel", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+ post "/arvados/v1/jobs/#{jobs(:running).uuid}/cancel",
+ params: {:format => :json},
+ headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
assert_response :success
assert_equal "arvados#job", json_response['kind']
assert_not_nil json_response['cancelled_at']
end
test "cancel someone else's visible job" do
- post "/arvados/v1/jobs/#{jobs(:runningbarbaz).uuid}/cancel", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:spectator).api_token}"}
+ post "/arvados/v1/jobs/#{jobs(:runningbarbaz).uuid}/cancel",
+ params: {:format => :json},
+ headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:spectator).api_token}"}
assert_response 403
end
test "cancel someone else's invisible job" do
- post "/arvados/v1/jobs/#{jobs(:running).uuid}/cancel", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:spectator).api_token}"}
+ post "/arvados/v1/jobs/#{jobs(:running).uuid}/cancel",
+ params: {:format => :json},
+ headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:spectator).api_token}"}
assert_response 404
end
test "task qsequence values automatically increase monotonically" do
post_args = ["/arvados/v1/job_tasks",
- {job_task: {
+ params: {job_task: {
job_uuid: jobs(:running).uuid,
sequence: 1,
}},
- auth(:active)]
+ headers: auth(:active)]
last_qsequence = -1
(1..3).each do |task_num|
@response = nil
diff --git a/services/api/test/integration/keep_proxy_test.rb b/services/api/test/integration/keep_proxy_test.rb
index 8c286eab4..664295175 100644
--- a/services/api/test/integration/keep_proxy_test.rb
+++ b/services/api/test/integration/keep_proxy_test.rb
@@ -6,7 +6,9 @@ require 'test_helper'
class KeepProxyTest < ActionDispatch::IntegrationTest
test "request keep disks" do
- get "/arvados/v1/keep_services/accessible", {:format => :json}, auth(:active)
+ get "/arvados/v1/keep_services/accessible",
+ params: {:format => :json},
+ headers: auth(:active)
assert_response :success
services = json_response['items']
@@ -17,7 +19,9 @@ class KeepProxyTest < ActionDispatch::IntegrationTest
end
test "request keep proxy" do
- get "/arvados/v1/keep_services/accessible", {:format => :json}, auth(:active).merge({'HTTP_X_EXTERNAL_CLIENT' => '1'})
+ get "/arvados/v1/keep_services/accessible",
+ params: {:format => :json},
+ headers: auth(:active).merge({'HTTP_X_EXTERNAL_CLIENT' => '1'})
assert_response :success
services = json_response['items']
diff --git a/services/api/test/integration/login_workflow_test.rb b/services/api/test/integration/login_workflow_test.rb
index 85b4cb746..8691030e9 100644
--- a/services/api/test/integration/login_workflow_test.rb
+++ b/services/api/test/integration/login_workflow_test.rb
@@ -6,22 +6,25 @@ require 'test_helper'
class LoginWorkflowTest < ActionDispatch::IntegrationTest
test "default prompt to login is JSON" do
- post('/arvados/v1/specimens', {specimen: {}},
- {'HTTP_ACCEPT' => ''})
+ post('/arvados/v1/specimens',
+ params: {specimen: {}},
+ headers: {'HTTP_ACCEPT' => ''})
assert_response 401
assert_includes(json_response['errors'], "Not logged in")
end
test "login prompt respects JSON Accept header" do
- post('/arvados/v1/specimens', {specimen: {}},
- {'HTTP_ACCEPT' => 'application/json'})
+ post('/arvados/v1/specimens',
+ params: {specimen: {}},
+ headers: {'HTTP_ACCEPT' => 'application/json'})
assert_response 401
assert_includes(json_response['errors'], "Not logged in")
end
test "login prompt respects HTML Accept header" do
- post('/arvados/v1/specimens', {specimen: {}},
- {'HTTP_ACCEPT' => 'text/html'})
+ post('/arvados/v1/specimens',
+ params: {specimen: {}},
+ headers: {'HTTP_ACCEPT' => 'text/html'})
assert_response 302
assert_match(%r{/auth/joshid$}, @response.headers['Location'],
"HTML login prompt did not include expected redirect")
diff --git a/services/api/test/integration/noop_deep_munge_test.rb b/services/api/test/integration/noop_deep_munge_test.rb
index 13b0fa66f..a94898ba2 100644
--- a/services/api/test/integration/noop_deep_munge_test.rb
+++ b/services/api/test/integration/noop_deep_munge_test.rb
@@ -21,22 +21,25 @@ class NoopDeepMungeTest < ActionDispatch::IntegrationTest
def check(val)
post "/arvados/v1/container_requests",
- {
- :container_request => {
- :name => "workflow",
- :state => "Uncommitted",
- :command => ["echo"],
- :container_image => "arvados/jobs",
- :output_path => "/",
- :mounts => {
- :foo => {
- :kind => "json",
- :content => JSON.parse(SafeJSON.dump(val)),
- }
- }
- }
- }.to_json, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin).api_token}",
- 'CONTENT_TYPE' => 'application/json'}
+ params: {
+ :container_request => {
+ :name => "workflow",
+ :state => "Uncommitted",
+ :command => ["echo"],
+ :container_image => "arvados/jobs",
+ :output_path => "/",
+ :mounts => {
+ :foo => {
+ :kind => "json",
+ :content => JSON.parse(SafeJSON.dump(val)),
+ }
+ }
+ }
+ }.to_json,
+ headers: {
+ 'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin).api_token}",
+ 'CONTENT_TYPE' => 'application/json'
+ }
assert_response :success
assert_equal "arvados#containerRequest", json_response['kind']
assert_equal val, json_response['mounts']['foo']['content']
diff --git a/services/api/test/integration/permissions_test.rb b/services/api/test/integration/permissions_test.rb
index 49fa473b6..eec41aa08 100644
--- a/services/api/test/integration/permissions_test.rb
+++ b/services/api/test/integration/permissions_test.rb
@@ -11,100 +11,128 @@ class PermissionsTest < ActionDispatch::IntegrationTest
test "adding and removing direct can_read links" do
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response 404
# try to add permission as spectator
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: users(:spectator).uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: collections(:foo_file).uuid,
- properties: {}
- }
- }, auth(:spectator)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: users(:spectator).uuid,
+ link_class: 'permission',
+ name: 'can_read',
+ head_uuid: collections(:foo_file).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:spectator)
assert_response 422
# add permission as admin
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: users(:spectator).uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: collections(:foo_file).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: users(:spectator).uuid,
+ link_class: 'permission',
+ name: 'can_read',
+ head_uuid: collections(:foo_file).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
u = json_response['uuid']
assert_response :success
# read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response :success
# try to delete permission as spectator
- delete "/arvados/v1/links/#{u}", {:format => :json}, auth(:spectator)
+ delete "/arvados/v1/links/#{u}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response 403
# delete permission as admin
- delete "/arvados/v1/links/#{u}", {:format => :json}, auth(:admin)
+ delete "/arvados/v1/links/#{u}",
+ params: {:format => :json},
+ headers: auth(:admin)
assert_response :success
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response 404
end
test "adding can_read links from user to group, group to collection" do
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response 404
# add permission for spectator to read group
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: users(:spectator).uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: groups(:private).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: users(:spectator).uuid,
+ link_class: 'permission',
+ name: 'can_read',
+ head_uuid: groups(:private).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
assert_response :success
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response 404
# add permission for group to read collection
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: groups(:private).uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: collections(:foo_file).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: groups(:private).uuid,
+ link_class: 'permission',
+ name: 'can_read',
+ head_uuid: collections(:foo_file).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
u = json_response['uuid']
assert_response :success
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response :success
# delete permission for group to read collection
- delete "/arvados/v1/links/#{u}", {:format => :json}, auth(:admin)
+ delete "/arvados/v1/links/#{u}",
+ params: {:format => :json},
+ headers: auth(:admin)
assert_response :success
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response 404
end
@@ -112,141 +140,175 @@ class PermissionsTest < ActionDispatch::IntegrationTest
test "adding can_read links from group to collection, user to group" do
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response 404
# add permission for group to read collection
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: groups(:private).uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: collections(:foo_file).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: groups(:private).uuid,
+ link_class: 'permission',
+ name: 'can_read',
+ head_uuid: collections(:foo_file).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
assert_response :success
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response 404
# add permission for spectator to read group
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: users(:spectator).uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: groups(:private).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: users(:spectator).uuid,
+ link_class: 'permission',
+ name: 'can_read',
+ head_uuid: groups(:private).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
u = json_response['uuid']
assert_response :success
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response :success
# delete permission for spectator to read group
- delete "/arvados/v1/links/#{u}", {:format => :json}, auth(:admin)
+ delete "/arvados/v1/links/#{u}",
+ params: {:format => :json},
+ headers: auth(:admin)
assert_response :success
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response 404
end
test "adding can_read links from user to group, group to group, group to collection" do
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response 404
# add permission for user to read group
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: users(:spectator).uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: groups(:private).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: users(:spectator).uuid,
+ link_class: 'permission',
+ name: 'can_read',
+ head_uuid: groups(:private).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
assert_response :success
# add permission for group to read group
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: groups(:private).uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: groups(:empty_lonely_group).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: groups(:private).uuid,
+ link_class: 'permission',
+ name: 'can_read',
+ head_uuid: groups(:empty_lonely_group).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
assert_response :success
# add permission for group to read collection
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: groups(:empty_lonely_group).uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: collections(:foo_file).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: groups(:empty_lonely_group).uuid,
+ link_class: 'permission',
+ name: 'can_read',
+ head_uuid: collections(:foo_file).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
u = json_response['uuid']
assert_response :success
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response :success
# delete permission for group to read collection
- delete "/arvados/v1/links/#{u}", {:format => :json}, auth(:admin)
+ delete "/arvados/v1/links/#{u}",
+ params: {:format => :json},
+ headers: auth(:admin)
assert_response :success
# try to read collection as spectator
- get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
+ get "/arvados/v1/collections/#{collections(:foo_file).uuid}",
+ params: {:format => :json},
+ headers: auth(:spectator)
assert_response 404
end
test "read-only group-admin cannot modify administered user" do
- put "/arvados/v1/users/#{users(:active).uuid}", {
- :user => {
- first_name: 'KilroyWasHere'
+ put "/arvados/v1/users/#{users(:active).uuid}",
+ params: {
+ :user => {
+ first_name: 'KilroyWasHere'
+ },
+ :format => :json
},
- :format => :json
- }, auth(:rominiadmin)
+ headers: auth(:rominiadmin)
assert_response 403
end
test "read-only group-admin cannot read or update non-administered user" do
- get "/arvados/v1/users/#{users(:spectator).uuid}", {
- :format => :json
- }, auth(:rominiadmin)
+ get "/arvados/v1/users/#{users(:spectator).uuid}",
+ params: {:format => :json},
+ headers: auth(:rominiadmin)
assert_response 404
- put "/arvados/v1/users/#{users(:spectator).uuid}", {
- :user => {
- first_name: 'KilroyWasHere'
+ put "/arvados/v1/users/#{users(:spectator).uuid}",
+ params: {
+ :user => {
+ first_name: 'KilroyWasHere'
+ },
+ :format => :json
},
- :format => :json
- }, auth(:rominiadmin)
+ headers: auth(:rominiadmin)
assert_response 404
end
test "RO group-admin finds user's specimens, RW group-admin can update" do
[[:rominiadmin, false],
[:miniadmin, true]].each do |which_user, update_should_succeed|
- get "/arvados/v1/specimens", {:format => :json}, auth(which_user)
+ get "/arvados/v1/specimens",
+ params: {:format => :json},
+ headers: auth(which_user)
assert_response :success
resp_uuids = json_response['items'].collect { |i| i['uuid'] }
[[true, specimens(:owned_by_active_user).uuid],
@@ -258,14 +320,16 @@ class PermissionsTest < ActionDispatch::IntegrationTest
[which_user.to_s,
should_find ? '' : 'not ',
uuid])
- put "/arvados/v1/specimens/#{uuid}", {
- :specimen => {
- properties: {
- miniadmin_was_here: true
- }
+ put "/arvados/v1/specimens/#{uuid}",
+ params: {
+ :specimen => {
+ properties: {
+ miniadmin_was_here: true
+ }
+ },
+ :format => :json
},
- :format => :json
- }, auth(which_user)
+ headers: auth(which_user)
if !should_find
assert_response 404
elsif !update_should_succeed
@@ -279,55 +343,63 @@ class PermissionsTest < ActionDispatch::IntegrationTest
test "get_permissions returns list" do
# First confirm that user :active cannot get permissions on group :public
- get "/arvados/v1/permissions/#{groups(:public).uuid}", nil, auth(:active)
+ get "/arvados/v1/permissions/#{groups(:public).uuid}",
+ params: nil,
+ headers: auth(:active)
assert_response 404
# add some permissions, including can_manage
# permission for user :active
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: users(:spectator).uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: groups(:public).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: users(:spectator).uuid,
+ link_class: 'permission',
+ name: 'can_read',
+ head_uuid: groups(:public).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
assert_response :success
can_read_uuid = json_response['uuid']
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: users(:inactive).uuid,
- link_class: 'permission',
- name: 'can_write',
- head_uuid: groups(:public).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: users(:inactive).uuid,
+ link_class: 'permission',
+ name: 'can_write',
+ head_uuid: groups(:public).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
assert_response :success
can_write_uuid = json_response['uuid']
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- tail_uuid: users(:active).uuid,
- link_class: 'permission',
- name: 'can_manage',
- head_uuid: groups(:public).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: users(:active).uuid,
+ link_class: 'permission',
+ name: 'can_manage',
+ head_uuid: groups(:public).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
assert_response :success
can_manage_uuid = json_response['uuid']
# Now user :active should be able to retrieve permissions
# on group :public.
get("/arvados/v1/permissions/#{groups(:public).uuid}",
- { :format => :json },
- auth(:active))
+ params: { :format => :json },
+ headers: auth(:active))
assert_response :success
perm_uuids = json_response['items'].map { |item| item['uuid'] }
@@ -339,26 +411,30 @@ class PermissionsTest < ActionDispatch::IntegrationTest
test "get_permissions returns 404 for nonexistent uuid" do
nonexistent = Group.generate_uuid
# make sure it really doesn't exist
- get "/arvados/v1/groups/#{nonexistent}", nil, auth(:admin)
+ get "/arvados/v1/groups/#{nonexistent}", params: nil, headers: auth(:admin)
assert_response 404
- get "/arvados/v1/permissions/#{nonexistent}", nil, auth(:active)
+ get "/arvados/v1/permissions/#{nonexistent}", params: nil, headers: auth(:active)
assert_response 404
end
test "get_permissions returns 403 if user can read but not manage" do
- post "/arvados/v1/links", {
- :link => {
- tail_uuid: users(:active).uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: groups(:public).uuid,
- properties: {}
- }
- }, auth(:admin)
+ post "/arvados/v1/links",
+ params: {
+ :link => {
+ tail_uuid: users(:active).uuid,
+ link_class: 'permission',
+ name: 'can_read',
+ head_uuid: groups(:public).uuid,
+ properties: {}
+ }
+ },
+ headers: auth(:admin)
assert_response :success
- get "/arvados/v1/permissions/#{groups(:public).uuid}", nil, auth(:active)
+ get "/arvados/v1/permissions/#{groups(:public).uuid}",
+ params: nil,
+ headers: auth(:active)
assert_response 403
end
@@ -366,8 +442,8 @@ class PermissionsTest < ActionDispatch::IntegrationTest
# The active user should be able to read the empty collection.
get("/arvados/v1/collections/#{empty_collection_uuid}",
- { :format => :json },
- auth(:active))
+ params: {:format => :json},
+ headers: auth(:active))
assert_response :success
assert_empty json_response['manifest_text'], "empty collection manifest_text is not empty"
end
diff --git a/services/api/test/integration/pipeline_test.rb b/services/api/test/integration/pipeline_test.rb
index 1e9a4d5c6..d4f7eba30 100644
--- a/services/api/test/integration/pipeline_test.rb
+++ b/services/api/test/integration/pipeline_test.rb
@@ -28,13 +28,17 @@ class PipelineIntegrationTest < ActionDispatch::IntegrationTest
}
post("/arvados/v1/pipeline_instances",
- {pipeline_instance: {components: {comp_name => component}}.to_json},
- auth(:active))
+ params: {
+ pipeline_instance: {
+ components: {comp_name => component}
+ }.to_json
+ },
+ headers: auth(:active))
check_component_match(comp_name, component)
pi_uuid = json_response["uuid"]
@response = nil
- get("/arvados/v1/pipeline_instances/#{pi_uuid}", {}, auth(:active))
+ get("/arvados/v1/pipeline_instances/#{pi_uuid}", params: {}, headers: auth(:active))
check_component_match(comp_name, component)
end
end
diff --git a/services/api/test/integration/reader_tokens_test.rb b/services/api/test/integration/reader_tokens_test.rb
index a60be093a..e8e8c910c 100644
--- a/services/api/test/integration/reader_tokens_test.rb
+++ b/services/api/test/integration/reader_tokens_test.rb
@@ -16,7 +16,7 @@ class ReaderTokensTest < ActionDispatch::IntegrationTest
params[:reader_tokens] = [api_token(read_auth)].send(formatter) if read_auth
headers = {}
headers.merge!(auth(main_auth)) if main_auth
- get('/arvados/v1/specimens', params, headers)
+ get('/arvados/v1/specimens', params: params, headers: headers)
end
def get_specimen_uuids(main_auth, read_auth, formatter=:to_a)
@@ -34,8 +34,8 @@ class ReaderTokensTest < ActionDispatch::IntegrationTest
expected = 401
end
post('/arvados/v1/specimens.json',
- {specimen: {}, reader_tokens: [api_token(read_auth)].send(formatter)},
- headers)
+ params: {specimen: {}, reader_tokens: [api_token(read_auth)].send(formatter)},
+ headers: headers)
assert_response expected
end
@@ -65,8 +65,8 @@ class ReaderTokensTest < ActionDispatch::IntegrationTest
test "scopes are still limited with reader tokens" do
get('/arvados/v1/collections',
- {reader_tokens: [api_token(:spectator_specimens)]},
- auth(:active_noscope))
+ params: {reader_tokens: [api_token(:spectator_specimens)]},
+ headers: auth(:active_noscope))
assert_response 403
end
diff --git a/services/api/test/integration/remote_user_test.rb b/services/api/test/integration/remote_user_test.rb
index 44737524e..5c09cf1bc 100644
--- a/services/api/test/integration/remote_user_test.rb
+++ b/services/api/test/integration/remote_user_test.rb
@@ -81,7 +81,9 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
end
test 'authenticate with remote token' do
- get '/arvados/v1/users/current', {format: 'json'}, auth(remote: 'zbbbb')
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: auth(remote: 'zbbbb')
assert_response :success
assert_equal 'zbbbb-tpzed-000000000000000', json_response['uuid']
assert_equal false, json_response['is_admin']
@@ -93,7 +95,9 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
@stub_status = 401
# re-authorize before cache expires
- get '/arvados/v1/users/current', {format: 'json'}, auth(remote: 'zbbbb')
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: auth(remote: 'zbbbb')
assert_response :success
# simulate cache expiry
@@ -102,7 +106,9 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
update_all(expires_at: db_current_time - 1.minute)
# re-authorize after cache expires
- get '/arvados/v1/users/current', {format: 'json'}, auth(remote: 'zbbbb')
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: auth(remote: 'zbbbb')
assert_response 401
# simulate cached token indicating wrong user (e.g., local user
@@ -116,7 +122,9 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
@stub_status = 200
@stub_content[:username] = 'blarney'
@stub_content[:email] = 'blarney at example.com'
- get '/arvados/v1/users/current', {format: 'json'}, auth(remote: 'zbbbb')
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: auth(remote: 'zbbbb')
assert_response :success
assert_equal 'barney', json_response['username'], 'local username should not change once assigned'
assert_equal 'blarney at example.com', json_response['email']
@@ -124,20 +132,26 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
test 'authenticate with remote token, remote username conflicts with local' do
@stub_content[:username] = 'active'
- get '/arvados/v1/users/current', {format: 'json'}, auth(remote: 'zbbbb')
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: auth(remote: 'zbbbb')
assert_response :success
assert_equal 'active2', json_response['username']
end
test 'authenticate with remote token, remote username is nil' do
@stub_content.delete :username
- get '/arvados/v1/users/current', {format: 'json'}, auth(remote: 'zbbbb')
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: auth(remote: 'zbbbb')
assert_response :success
assert_equal 'foo', json_response['username']
end
test 'authenticate with remote token from misbhehaving remote cluster' do
- get '/arvados/v1/users/current', {format: 'json'}, auth(remote: 'zbork')
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: auth(remote: 'zbork')
assert_response 401
end
@@ -146,7 +160,9 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
@stub_content = {
error: 'not authorized',
}
- get '/arvados/v1/users/current', {format: 'json'}, auth(remote: 'zbbbb')
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: auth(remote: 'zbbbb')
assert_response 401
end
@@ -169,30 +185,36 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
'///',
].each do |token|
test "authenticate with malformed remote token #{token}" do
- get '/arvados/v1/users/current', {format: 'json'}, {"HTTP_AUTHORIZATION" => "Bearer #{token}"}
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: {"HTTP_AUTHORIZATION" => "Bearer #{token}"}
assert_response 401
end
end
test "ignore extra fields in remote token" do
token = salted_active_token(remote: 'zbbbb') + '/foo/bar/baz/*'
- get '/arvados/v1/users/current', {format: 'json'}, {"HTTP_AUTHORIZATION" => "Bearer #{token}"}
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: {"HTTP_AUTHORIZATION" => "Bearer #{token}"}
assert_response :success
end
test 'remote api server is not an api server' do
@stub_status = 200
@stub_content = '<html>bad</html>'
- get '/arvados/v1/users/current', {format: 'json'}, auth(remote: 'zbbbb')
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: auth(remote: 'zbbbb')
assert_response 401
end
['zbbbb', 'z0000'].each do |token_valid_for|
test "validate #{token_valid_for}-salted token for remote cluster zbbbb" do
salted_token = salt_token(fixture: :active, remote: token_valid_for)
- get '/arvados/v1/users/current', {format: 'json', remote: 'zbbbb'}, {
- "HTTP_AUTHORIZATION" => "Bearer #{salted_token}"
- }
+ get '/arvados/v1/users/current',
+ params: {format: 'json', remote: 'zbbbb'},
+ headers: {"HTTP_AUTHORIZATION" => "Bearer #{salted_token}"}
if token_valid_for == 'zbbbb'
assert_response 200
assert_equal(users(:active).uuid, json_response['uuid'])
@@ -204,13 +226,13 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
test "list readable groups with salted token" do
salted_token = salt_token(fixture: :active, remote: 'zbbbb')
- get '/arvados/v1/groups', {
- format: 'json',
- remote: 'zbbbb',
- limit: 10000,
- }, {
- "HTTP_AUTHORIZATION" => "Bearer #{salted_token}"
- }
+ get '/arvados/v1/groups',
+ params: {
+ format: 'json',
+ remote: 'zbbbb',
+ limit: 10000,
+ },
+ headers: {"HTTP_AUTHORIZATION" => "Bearer #{salted_token}"}
assert_response 200
group_uuids = json_response['items'].collect { |i| i['uuid'] }
assert_includes(group_uuids, 'zzzzz-j7d0g-fffffffffffffff')
@@ -222,7 +244,9 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
test 'auto-activate user from trusted cluster' do
Rails.configuration.auto_activate_users_from = ['zbbbb']
- get '/arvados/v1/users/current', {format: 'json'}, auth(remote: 'zbbbb')
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: auth(remote: 'zbbbb')
assert_response :success
assert_equal 'zbbbb-tpzed-000000000000000', json_response['uuid']
assert_equal false, json_response['is_admin']
@@ -232,17 +256,21 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
end
test 'pre-activate remote user' do
- post '/arvados/v1/users', {
- "user" => {
- "uuid" => "zbbbb-tpzed-000000000000000",
- "email" => 'foo at example.com',
- "username" => 'barney',
- "is_active" => true
- }
- }, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_token(:admin)}"}
+ post '/arvados/v1/users',
+ params: {
+ "user" => {
+ "uuid" => "zbbbb-tpzed-000000000000000",
+ "email" => 'foo at example.com',
+ "username" => 'barney',
+ "is_active" => true
+ }
+ },
+ headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_token(:admin)}"}
assert_response :success
- get '/arvados/v1/users/current', {format: 'json'}, auth(remote: 'zbbbb')
+ get '/arvados/v1/users/current',
+ params: {format: 'json'},
+ headers: auth(remote: 'zbbbb')
assert_response :success
assert_equal 'zbbbb-tpzed-000000000000000', json_response['uuid']
assert_equal nil, json_response['is_admin']
@@ -254,9 +282,9 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
test "validate unsalted v2 token for remote cluster zbbbb" do
auth = api_client_authorizations(:active)
token = "v2/#{auth.uuid}/#{auth.api_token}"
- get '/arvados/v1/users/current', {format: 'json', remote: 'zbbbb'}, {
- "HTTP_AUTHORIZATION" => "Bearer #{token}"
- }
+ get '/arvados/v1/users/current',
+ params: {format: 'json', remote: 'zbbbb'},
+ headers: {"HTTP_AUTHORIZATION" => "Bearer #{token}"}
assert_response :success
assert_equal(users(:active).uuid, json_response['uuid'])
end
@@ -267,15 +295,17 @@ class RemoteUsersTest < ActionDispatch::IntegrationTest
["invalid local", "v2/#{api_client_authorizations(:active).uuid}/fakefakefake"],
["invalid remote", "v2/zbork-gj3su-000000000000000/abc"],
].each do |label, runtime_token|
- post '/arvados/v1/container_requests', {
- "container_request" => {
- "command" => ["echo"],
- "container_image" => "xyz",
- "output_path" => "/",
- "cwd" => "/",
- "runtime_token" => runtime_token
- }
- }, {"HTTP_AUTHORIZATION" => "Bearer #{api_client_authorizations(:active).api_token}"}
+ post '/arvados/v1/container_requests',
+ params: {
+ "container_request" => {
+ "command" => ["echo"],
+ "container_image" => "xyz",
+ "output_path" => "/",
+ "cwd" => "/",
+ "runtime_token" => runtime_token
+ }
+ },
+ headers: {"HTTP_AUTHORIZATION" => "Bearer #{api_client_authorizations(:active).api_token}"}
if label.include? "invalid"
assert_response 422
else
diff --git a/services/api/test/integration/select_test.rb b/services/api/test/integration/select_test.rb
index fb3f4f617..7fbab3b3b 100644
--- a/services/api/test/integration/select_test.rb
+++ b/services/api/test/integration/select_test.rb
@@ -6,7 +6,9 @@ require 'test_helper'
class SelectTest < ActionDispatch::IntegrationTest
test "should select just two columns" do
- get "/arvados/v1/links", {:format => :json, :select => ['uuid', 'link_class']}, auth(:active)
+ get "/arvados/v1/links",
+ params: {:format => :json, :select => ['uuid', 'link_class']},
+ headers: auth(:active)
assert_response :success
assert_equal json_response['items'].count, json_response['items'].select { |i|
i.count == 3 and i['uuid'] != nil and i['link_class'] != nil
@@ -14,11 +16,15 @@ class SelectTest < ActionDispatch::IntegrationTest
end
test "fewer distinct than total count" do
- get "/arvados/v1/links", {:format => :json, :select => ['link_class'], :distinct => false}, auth(:active)
+ get "/arvados/v1/links",
+ params: {:format => :json, :select => ['link_class'], :distinct => false},
+ headers: auth(:active)
assert_response :success
links = json_response['items']
- get "/arvados/v1/links", {:format => :json, :select => ['link_class'], :distinct => true}, auth(:active)
+ get "/arvados/v1/links",
+ params: {:format => :json, :select => ['link_class'], :distinct => true},
+ headers: auth(:active)
assert_response :success
distinct = json_response['items']
@@ -28,7 +34,9 @@ class SelectTest < ActionDispatch::IntegrationTest
end
test "select with order" do
- get "/arvados/v1/links", {:format => :json, :select => ['uuid'], :order => ["uuid asc"]}, auth(:active)
+ get "/arvados/v1/links",
+ params: {:format => :json, :select => ['uuid'], :order => ["uuid asc"]},
+ headers: auth(:active)
assert_response :success
assert json_response['items'].length > 0
@@ -41,7 +49,9 @@ class SelectTest < ActionDispatch::IntegrationTest
end
test "select with default order" do
- get "/arvados/v1/links", {format: :json, select: ['uuid']}, auth(:admin)
+ get "/arvados/v1/links",
+ params: {format: :json, select: ['uuid']},
+ headers: auth(:admin)
assert_response :success
uuids = json_response['items'].collect { |i| i['uuid'] }
assert_equal uuids, uuids.sort
@@ -58,7 +68,12 @@ class SelectTest < ActionDispatch::IntegrationTest
end
test "select two columns with order" do
- get "/arvados/v1/links", {:format => :json, :select => ['link_class', 'uuid'], :order => ['link_class asc', "uuid desc"]}, auth(:active)
+ get "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :select => ['link_class', 'uuid'], :order => ['link_class asc', "uuid desc"]
+ },
+ headers: auth(:active)
assert_response :success
assert json_response['items'].length > 0
@@ -80,7 +95,12 @@ class SelectTest < ActionDispatch::IntegrationTest
end
test "select two columns with old-style order syntax" do
- get "/arvados/v1/links", {:format => :json, :select => ['link_class', 'uuid'], :order => 'link_class asc, uuid desc'}, auth(:active)
+ get "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :select => ['link_class', 'uuid'], :order => 'link_class asc, uuid desc'
+ },
+ headers: auth(:active)
assert_response :success
assert json_response['items'].length > 0
diff --git a/services/api/test/integration/serialized_encoding_test.rb b/services/api/test/integration/serialized_encoding_test.rb
index d7599bc00..16d43e6f3 100644
--- a/services/api/test/integration/serialized_encoding_test.rb
+++ b/services/api/test/integration/serialized_encoding_test.rb
@@ -48,7 +48,8 @@ class SerializedEncodingTest < ActionDispatch::IntegrationTest
}.each_pair do |resource, postdata|
test "create json-encoded #{resource.to_s}" do
post("/arvados/v1/#{resource.to_s.pluralize}",
- {resource => postdata.to_json}, auth(:admin_trustedclient))
+ params: {resource => postdata.to_json},
+ headers: auth(:admin_trustedclient))
assert_response :success
end
end
diff --git a/services/api/test/integration/user_sessions_test.rb b/services/api/test/integration/user_sessions_test.rb
index f5085999e..f2dbaa506 100644
--- a/services/api/test/integration/user_sessions_test.rb
+++ b/services/api/test/integration/user_sessions_test.rb
@@ -28,8 +28,8 @@ class UserSessionsApiTest < ActionDispatch::IntegrationTest
mock['info']['username'] = username unless username.nil?
mock['info']['identity_url'] = identity_url unless identity_url.nil?
post('/auth/josh_id/callback',
- {return_to: client_url(remote: remote)},
- {'omniauth.auth' => mock})
+ params: {return_to: client_url(remote: remote)},
+ headers: {'omniauth.auth' => mock})
errors = {
:redirect => 'Did not redirect to client with token',
diff --git a/services/api/test/integration/users_test.rb b/services/api/test/integration/users_test.rb
index 28e43b845..e57268f90 100644
--- a/services/api/test/integration/users_test.rb
+++ b/services/api/test/integration/users_test.rb
@@ -11,16 +11,18 @@ class UsersTest < ActionDispatch::IntegrationTest
test "setup user multiple times" do
repo_name = 'usertestrepo'
- post "/arvados/v1/users/setup", {
- repo_name: repo_name,
- openid_prefix: 'https://www.google.com/accounts/o8/id',
- user: {
- uuid: 'zzzzz-tpzed-abcdefghijklmno',
- first_name: "in_create_test_first_name",
- last_name: "test_last_name",
- email: "foo at example.com"
- }
- }, auth(:admin)
+ post "/arvados/v1/users/setup",
+ params: {
+ repo_name: repo_name,
+ openid_prefix: 'https://www.google.com/accounts/o8/id',
+ user: {
+ uuid: 'zzzzz-tpzed-abcdefghijklmno',
+ first_name: "in_create_test_first_name",
+ last_name: "test_last_name",
+ email: "foo at example.com"
+ }
+ },
+ headers: auth(:admin)
assert_response :success
@@ -50,26 +52,30 @@ class UsersTest < ActionDispatch::IntegrationTest
verify_system_group_permission_link_for created['uuid']
# invoke setup again with the same data
- post "/arvados/v1/users/setup", {
- repo_name: repo_name,
- vm_uuid: virtual_machines(:testvm).uuid,
- openid_prefix: 'https://www.google.com/accounts/o8/id',
- user: {
- uuid: 'zzzzz-tpzed-abcdefghijklmno',
- first_name: "in_create_test_first_name",
- last_name: "test_last_name",
- email: "foo at example.com"
- }
- }, auth(:admin)
+ post "/arvados/v1/users/setup",
+ params: {
+ repo_name: repo_name,
+ vm_uuid: virtual_machines(:testvm).uuid,
+ openid_prefix: 'https://www.google.com/accounts/o8/id',
+ user: {
+ uuid: 'zzzzz-tpzed-abcdefghijklmno',
+ first_name: "in_create_test_first_name",
+ last_name: "test_last_name",
+ email: "foo at example.com"
+ }
+ },
+ headers: auth(:admin)
assert_response 422 # cannot create another user with same UUID
# invoke setup on the same user
- post "/arvados/v1/users/setup", {
- repo_name: repo_name,
- vm_uuid: virtual_machines(:testvm).uuid,
- openid_prefix: 'https://www.google.com/accounts/o8/id',
- uuid: 'zzzzz-tpzed-abcdefghijklmno',
- }, auth(:admin)
+ post "/arvados/v1/users/setup",
+ params: {
+ repo_name: repo_name,
+ vm_uuid: virtual_machines(:testvm).uuid,
+ openid_prefix: 'https://www.google.com/accounts/o8/id',
+ uuid: 'zzzzz-tpzed-abcdefghijklmno',
+ },
+ headers: auth(:admin)
response_items = json_response['items']
@@ -94,12 +100,14 @@ class UsersTest < ActionDispatch::IntegrationTest
end
test "setup user in multiple steps and verify response" do
- post "/arvados/v1/users/setup", {
- openid_prefix: 'http://www.example.com/account',
- user: {
- email: "foo at example.com"
- }
- }, auth(:admin)
+ post "/arvados/v1/users/setup",
+ params: {
+ openid_prefix: 'http://www.example.com/account',
+ user: {
+ email: "foo at example.com"
+ }
+ },
+ headers: auth(:admin)
assert_response :success
response_items = json_response['items']
@@ -120,11 +128,13 @@ class UsersTest < ActionDispatch::IntegrationTest
nil, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
# invoke setup with a repository
- post "/arvados/v1/users/setup", {
- openid_prefix: 'http://www.example.com/account',
- repo_name: 'newusertestrepo',
- uuid: created['uuid']
- }, auth(:admin)
+ post "/arvados/v1/users/setup",
+ params: {
+ openid_prefix: 'http://www.example.com/account',
+ repo_name: 'newusertestrepo',
+ uuid: created['uuid']
+ },
+ headers: auth(:admin)
assert_response :success
@@ -144,14 +154,16 @@ class UsersTest < ActionDispatch::IntegrationTest
nil, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
# invoke setup with a vm_uuid
- post "/arvados/v1/users/setup", {
- vm_uuid: virtual_machines(:testvm).uuid,
- openid_prefix: 'http://www.example.com/account',
- user: {
- email: 'junk_email'
+ post "/arvados/v1/users/setup",
+ params: {
+ vm_uuid: virtual_machines(:testvm).uuid,
+ openid_prefix: 'http://www.example.com/account',
+ user: {
+ email: 'junk_email'
+ },
+ uuid: created['uuid']
},
- uuid: created['uuid']
- }, auth(:admin)
+ headers: auth(:admin)
assert_response :success
@@ -169,12 +181,14 @@ class UsersTest < ActionDispatch::IntegrationTest
end
test "setup and unsetup user" do
- post "/arvados/v1/users/setup", {
- repo_name: 'newusertestrepo',
- vm_uuid: virtual_machines(:testvm).uuid,
- user: {email: 'foo at example.com'},
- openid_prefix: 'https://www.google.com/accounts/o8/id'
- }, auth(:admin)
+ post "/arvados/v1/users/setup",
+ params: {
+ repo_name: 'newusertestrepo',
+ vm_uuid: virtual_machines(:testvm).uuid,
+ user: {email: 'foo at example.com'},
+ openid_prefix: 'https://www.google.com/accounts/o8/id'
+ },
+ headers: auth(:admin)
assert_response :success
response_items = json_response['items']
@@ -218,36 +232,46 @@ class UsersTest < ActionDispatch::IntegrationTest
end
test 'merge active into project_viewer account' do
- post('/arvados/v1/groups', {
- group: {
- group_class: 'project',
- name: "active user's stuff",
- },
- }, auth(:project_viewer))
+ post('/arvados/v1/groups',
+ params: {
+ group: {
+ group_class: 'project',
+ name: "active user's stuff",
+ },
+ },
+ headers: auth(:project_viewer))
assert_response(:success)
project_uuid = json_response['uuid']
- post('/arvados/v1/users/merge', {
- new_user_token: api_client_authorizations(:project_viewer_trustedclient).api_token,
- new_owner_uuid: project_uuid,
- redirect_to_new_user: true,
- }, auth(:active_trustedclient))
+ post('/arvados/v1/users/merge',
+ params: {
+ new_user_token: api_client_authorizations(:project_viewer_trustedclient).api_token,
+ new_owner_uuid: project_uuid,
+ redirect_to_new_user: true,
+ },
+ headers: auth(:active_trustedclient))
assert_response(:success)
- get('/arvados/v1/users/current', {}, auth(:active))
+ get('/arvados/v1/users/current', params: {}, headers: auth(:active))
assert_response(:success)
assert_equal(users(:project_viewer).uuid, json_response['uuid'])
- get('/arvados/v1/authorized_keys/' + authorized_keys(:active).uuid, {}, auth(:active))
+ get('/arvados/v1/authorized_keys/' + authorized_keys(:active).uuid,
+ params: {},
+ headers: auth(:active))
assert_response(:success)
assert_equal(users(:project_viewer).uuid, json_response['owner_uuid'])
assert_equal(users(:project_viewer).uuid, json_response['authorized_user_uuid'])
- get('/arvados/v1/repositories/' + repositories(:foo).uuid, {}, auth(:active))
+ get('/arvados/v1/repositories/' + repositories(:foo).uuid,
+ params: {},
+ headers: auth(:active))
assert_response(:success)
assert_equal(users(:project_viewer).uuid, json_response['owner_uuid'])
- get('/arvados/v1/groups/' + groups(:aproject).uuid, {}, auth(:active))
+ get('/arvados/v1/groups/' + groups(:aproject).uuid,
+ params: {},
+ headers: auth(:active))
assert_response(:success)
assert_equal(project_uuid, json_response['owner_uuid'])
end
diff --git a/services/api/test/integration/valid_links_test.rb b/services/api/test/integration/valid_links_test.rb
index ed705fc04..1a98a6574 100644
--- a/services/api/test/integration/valid_links_test.rb
+++ b/services/api/test/integration/valid_links_test.rb
@@ -10,33 +10,39 @@ class ValidLinksTest < ActionDispatch::IntegrationTest
test "tail must exist on update" do
admin_auth = {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin).api_token}"}
- post "/arvados/v1/links", {
- :format => :json,
- :link => {
- link_class: 'test',
- name: 'stuff',
- head_uuid: users(:active).uuid,
- tail_uuid: virtual_machines(:testvm).uuid
- }
- }, admin_auth
+ post "/arvados/v1/links",
+ params: {
+ :format => :json,
+ :link => {
+ link_class: 'test',
+ name: 'stuff',
+ head_uuid: users(:active).uuid,
+ tail_uuid: virtual_machines(:testvm).uuid
+ }
+ },
+ headers: admin_auth
assert_response :success
u = json_response['uuid']
- put "/arvados/v1/links/#{u}", {
- :format => :json,
- :link => {
- tail_uuid: virtual_machines(:testvm2).uuid
- }
- }, admin_auth
+ put "/arvados/v1/links/#{u}",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: virtual_machines(:testvm2).uuid
+ }
+ },
+ headers: admin_auth
assert_response :success
assert_equal virtual_machines(:testvm2).uuid, (ActiveSupport::JSON.decode @response.body)['tail_uuid']
- put "/arvados/v1/links/#{u}", {
- :format => :json,
- :link => {
- tail_uuid: 'zzzzz-tpzed-xyzxyzxerrrorxx'
- }
- }, admin_auth
+ put "/arvados/v1/links/#{u}",
+ params: {
+ :format => :json,
+ :link => {
+ tail_uuid: 'zzzzz-tpzed-xyzxyzxerrrorxx'
+ }
+ },
+ headers: admin_auth
assert_response 422
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list