projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '17948-test-collection-tool' into main. Closes #17948
[arvados.git]
/
apps
/
workbench
/
test
/
controllers
/
application_controller_test.rb
diff --git
a/apps/workbench/test/controllers/application_controller_test.rb
b/apps/workbench/test/controllers/application_controller_test.rb
index 7c8c79825a96500ee0df94a701e0be3d84e6ed79..72c3e0ab0cfe4f30f43d29f856ab5ef43c375e78 100644
(file)
--- a/
apps/workbench/test/controllers/application_controller_test.rb
+++ b/
apps/workbench/test/controllers/application_controller_test.rb
@@
-1,3
+1,7
@@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
require 'test_helper'
class ApplicationControllerTest < ActionController::TestCase
require 'test_helper'
class ApplicationControllerTest < ActionController::TestCase
@@
-321,41
+325,48
@@
class ApplicationControllerTest < ActionController::TestCase
# Each pdh has more than one collection; however, we should get only one for each
assert collections.size == 2, 'Expected two objects in the preloaded collection hash'
assert collections[pdh1], 'Expected collections for the passed in pdh #{pdh1}'
# Each pdh has more than one collection; however, we should get only one for each
assert collections.size == 2, 'Expected two objects in the preloaded collection hash'
assert collections[pdh1], 'Expected collections for the passed in pdh #{pdh1}'
- assert_equal collections[pdh1].size, 1,
'Expected one collection for the passed in pdh #{pdh1}'
+ assert_equal collections[pdh1].size, 1,
"Expected one collection for the passed in pdh #{pdh1}"
assert collections[pdh2], 'Expected collections for the passed in pdh #{pdh2}'
assert collections[pdh2], 'Expected collections for the passed in pdh #{pdh2}'
- assert_equal collections[pdh2].size, 1,
'Expected one collection for the passed in pdh #{pdh2}'
+ assert_equal collections[pdh2].size, 1,
"Expected one collection for the passed in pdh #{pdh2}"
end
test "requesting a nonexistent object returns 404" do
# We're really testing ApplicationController's find_object_by_uuid.
# It's easiest to do that by instantiating a concrete controller.
@controller = NodesController.new
end
test "requesting a nonexistent object returns 404" do
# We're really testing ApplicationController's find_object_by_uuid.
# It's easiest to do that by instantiating a concrete controller.
@controller = NodesController.new
- get(:show,
{id: "zzzzz-zzzzz-zzzzzzzzzzzzzzz"},
session_for(:admin))
+ get(:show,
params: {id: "zzzzz-zzzzz-zzzzzzzzzzzzzzz"}, session:
session_for(:admin))
assert_response 404
end
assert_response 404
end
- test "requesting to the API server includes
client_session_id param
" do
- got_
query
= nil
+ test "requesting to the API server includes
X-Request-Id header
" do
+ got_
header
= nil
stub_api_calls
stub_api_calls
- stub_api_client.stubs(:post).with do |url, query,
opts
={}|
- got_
query = query
+ stub_api_client.stubs(:post).with do |url, query,
header
={}|
+ got_
header = header
true
end.returns fake_api_response('{}', 200, {})
true
end.returns fake_api_response('{}', 200, {})
- Rails.configuration.
anonymous_user_t
oken =
+ Rails.configuration.
Users.AnonymousUserT
oken =
api_fixture("api_client_authorizations", "anonymous", "api_token")
@controller = ProjectsController.new
test_uuid = "zzzzz-j7d0g-zzzzzzzzzzzzzzz"
api_fixture("api_client_authorizations", "anonymous", "api_token")
@controller = ProjectsController.new
test_uuid = "zzzzz-j7d0g-zzzzzzzzzzzzzzz"
- get(:show, {id: test_uuid})
+ get(:show, params: {id: test_uuid})
+
+ assert_not_nil got_header
+ assert_includes got_header, 'X-Request-Id'
+ assert_match /^req-[0-9a-zA-Z]{20}$/, got_header["X-Request-Id"]
+ end
- assert_includes got_query, 'current_request_id'
- assert_match /\d{10}-\d{9}/, got_query['current_request_id']
+ test "current request_id is nil after a request" do
+ @controller = NodesController.new
+ get(:index, params: {}, session: session_for(:active))
+ assert_nil Thread.current[:request_id]
end
end
- test "
current_request_id is nil after a request
" do
+ test "
X-Request-Id header
" do
@controller = NodesController.new
@controller = NodesController.new
- get(:index,
{},
session_for(:active))
- assert_
nil Thread.current[:current_request_id
]
+ get(:index,
params: {}, session:
session_for(:active))
+ assert_
match /^req-[0-9a-zA-Z]{20}$/, response.headers['X-Request-Id'
]
end
[".navbar .login-menu a",
end
[".navbar .login-menu a",
@@
-363,14
+374,14
@@
class ApplicationControllerTest < ActionController::TestCase
].each do |css_selector|
test "login link at #{css_selector.inspect} includes return_to param" do
# Without an anonymous token, we're immediately redirected to login.
].each do |css_selector|
test "login link at #{css_selector.inspect} includes return_to param" do
# Without an anonymous token, we're immediately redirected to login.
- Rails.configuration.
anonymous_user_t
oken =
+ Rails.configuration.
Users.AnonymousUserT
oken =
api_fixture("api_client_authorizations", "anonymous", "api_token")
@controller = ProjectsController.new
test_uuid = "zzzzz-j7d0g-zzzzzzzzzzzzzzz"
api_fixture("api_client_authorizations", "anonymous", "api_token")
@controller = ProjectsController.new
test_uuid = "zzzzz-j7d0g-zzzzzzzzzzzzzzz"
- get(:show, {id: test_uuid})
+ get(:show,
params:
{id: test_uuid})
login_link = css_select(css_selector).first
assert_not_nil(login_link, "failed to select login link")
login_link = css_select(css_selector).first
assert_not_nil(login_link, "failed to select login link")
- login_href = URI.unescape(login_link.attributes["href"])
+ login_href = URI.unescape(login_link.attributes["href"]
.value
)
# The parameter needs to include the full URL to work.
assert_includes(login_href, "://")
assert_match(/[\?&]return_to=[^&]*\/projects\/#{test_uuid}(&|$)/,
# The parameter needs to include the full URL to work.
assert_includes(login_href, "://")
assert_match(/[\?&]return_to=[^&]*\/projects\/#{test_uuid}(&|$)/,
@@
-382,17
+393,17
@@
class ApplicationControllerTest < ActionController::TestCase
# We're really testing ApplicationController's render_exception.
# Our primary concern is that it doesn't raise an error and
# return 500.
# We're really testing ApplicationController's render_exception.
# Our primary concern is that it doesn't raise an error and
# return 500.
- orig_api_server = Rails.configuration.
arvados_v1_base
+ orig_api_server = Rails.configuration.
Services.Controller.ExternalURL
begin
# The URL should look valid in all respects, and avoid talking over a
# network. 100::/64 is the IPv6 discard prefix, so it's perfect.
begin
# The URL should look valid in all respects, and avoid talking over a
# network. 100::/64 is the IPv6 discard prefix, so it's perfect.
- Rails.configuration.
arvados_v1_base
= "https://[100::f]:1/"
+ Rails.configuration.
Services.Controller.ExternalURL
= "https://[100::f]:1/"
@controller = NodesController.new
@controller = NodesController.new
- get(:index,
{},
session_for(:active))
+ get(:index,
params: {}, session:
session_for(:active))
assert_includes(405..422, @response.code.to_i,
"bad response code when API server is unreachable")
ensure
assert_includes(405..422, @response.code.to_i,
"bad response code when API server is unreachable")
ensure
- Rails.configuration.
arvados_v1_base
= orig_api_server
+ Rails.configuration.
Services.Controller.ExternalURL
= orig_api_server
end
end
end
end
@@
-410,14
+421,14
@@
class ApplicationControllerTest < ActionController::TestCase
].each do |controller, fixture, anon_config=true|
test "#{controller} show method with anonymous config #{anon_config ? '' : 'not '}enabled" do
if anon_config
].each do |controller, fixture, anon_config=true|
test "#{controller} show method with anonymous config #{anon_config ? '' : 'not '}enabled" do
if anon_config
- Rails.configuration.
anonymous_user_t
oken = api_fixture('api_client_authorizations')['anonymous']['api_token']
+ Rails.configuration.
Users.AnonymousUserT
oken = api_fixture('api_client_authorizations')['anonymous']['api_token']
else
else
- Rails.configuration.
anonymous_user_token = false
+ Rails.configuration.
Users.AnonymousUserToken = ""
end
@controller = controller
end
@controller = controller
- get(:show, {id: fixture['uuid']})
+ get(:show,
params:
{id: fixture['uuid']})
if anon_config
assert_response 200
if anon_config
assert_response 200
@@
-438,10
+449,10
@@
class ApplicationControllerTest < ActionController::TestCase
false,
].each do |config|
test "invoke show with include_accept_encoding_header config #{config}" do
false,
].each do |config|
test "invoke show with include_accept_encoding_header config #{config}" do
- Rails.configuration.
include_accept_encoding_header_in_api_requests
= config
+ Rails.configuration.
APIResponseCompression
= config
@controller = CollectionsController.new
@controller = CollectionsController.new
- get(:show,
{id: api_fixture('collections')['foo_file']['uuid']},
session_for(:admin))
+ get(:show,
params: {id: api_fixture('collections')['foo_file']['uuid']}, session:
session_for(:admin))
assert_equal([['.', 'foo', 3]], assigns(:object).files)
end
assert_equal([['.', 'foo', 3]], assigns(:object).files)
end
@@
-450,13
+461,13
@@
class ApplicationControllerTest < ActionController::TestCase
test 'Edit name and verify that a duplicate is not created' do
@controller = ProjectsController.new
project = api_fixture("groups")["aproject"]
test 'Edit name and verify that a duplicate is not created' do
@controller = ProjectsController.new
project = api_fixture("groups")["aproject"]
- post :update, {
+ post :update,
params:
{
id: project["uuid"],
project: {
name: 'test name'
},
format: :json
id: project["uuid"],
project: {
name: 'test name'
},
format: :json
- }, session_for(:active)
+ }, session
: session
_for(:active)
assert_includes @response.body, 'test name'
updated = assigns(:object)
assert_equal updated.uuid, project["uuid"]
assert_includes @response.body, 'test name'
updated = assigns(:object)
assert_equal updated.uuid, project["uuid"]
@@
-470,7
+481,7
@@
class ApplicationControllerTest < ActionController::TestCase
test "access #{controller.controller_name} index as admin and verify Home link is#{' not' if !expect_home_link} shown" do
@controller = controller
test "access #{controller.controller_name} index as admin and verify Home link is#{' not' if !expect_home_link} shown" do
@controller = controller
- get :index,
{},
session_for(:admin)
+ get :index,
params: {}, session:
session_for(:admin)
assert_response 200
assert_includes @response.body, expect_str
assert_response 200
assert_includes @response.body, expect_str
@@
-492,7
+503,7
@@
class ApplicationControllerTest < ActionController::TestCase
test "access #{controller.controller_name} index as admin and verify Delete option is#{' not' if !expect_delete_link} shown" do
@controller = controller
test "access #{controller.controller_name} index as admin and verify Delete option is#{' not' if !expect_delete_link} shown" do
@controller = controller
- get :index,
{},
session_for(:admin)
+ get :index,
params: {}, session:
session_for(:admin)
assert_response 200
assert_includes @response.body, expect_str
assert_response 200
assert_includes @response.body, expect_str