Does not redirect user to the custom home page URL on a Geo secondary

If a user is not signed-in and tries to access root_path on a Geo
secondary node, redirects them to the sign-in page. Don't redirect
to the custom home page URL if one is present. Otherwise, it
will break the Geo OAuth workflow always redirecting the user to
the Geo primary node, which prevents access to the secondary node.
parent cc85cb8f
......@@ -15,5 +15,17 @@ module EE
super
end
override :redirect_to_home_page_url?
def redirect_to_home_page_url?
# If a user is not signed-in and tries to access root_path on a Geo
# secondary node, redirects them to the sign-in page. Don't redirect
# to the custom home page URL if one is present. Otherwise, it
# will break the Geo OAuth workflow always redirecting the user to
# the Geo primary node, which prevents access to the secondary node.
return false if ::Gitlab::Geo.secondary?
super
end
end
end
---
title: Geo - Does not redirect user to the custom home page URL on a Geo secondary
merge_request: 13447
author:
type: fixed
......@@ -3,35 +3,98 @@
require 'spec_helper'
describe RootController do
describe 'GET index' do
let(:user) { create(:user) }
include ::EE::GeoHelpers
before do
stub_licensed_features(operations_dashboard: true)
sign_in(user)
allow(subject).to receive(:current_user).and_return(user)
end
describe 'GET #index' do
context 'when user is not logged in' do
context 'on a Geo primary node' do
set(:primary_node) { create(:geo_node, :primary) }
context 'who has customized their dashboard setting for operations' do
before do
user.dashboard = 'operations'
end
before do
stub_current_geo_node(primary_node)
end
it 'redirects to the sign-in page' do
get :index
expect(response).to redirect_to(new_user_session_path)
end
it 'redirects to operations dashboard' do
get :index
context 'when a custom home page URL is defined' do
before do
stub_application_setting(home_page_url: 'https://custom.gitlab.com/foo')
end
expect(response).to redirect_to operations_path
it 'redirects the user to the custom home page URL' do
get :index
expect(response).to redirect_to('https://custom.gitlab.com/foo')
end
end
end
context 'when unlicensed' do
context 'on a Geo secondary node' do
set(:secondary_node) { create(:geo_node) }
before do
stub_licensed_features(operations_dashboard: false)
stub_current_geo_node(secondary_node)
end
it 'renders the default dashboard' do
it 'redirects to the sign-in page' do
get :index
expect(response).to render_template 'dashboard/projects/index'
expect(response).to redirect_to(new_user_session_path)
end
context 'when a custom home page URL is defined' do
before do
stub_application_setting(home_page_url: 'https://custom.gitlab.com/foo')
end
it 'redirects to the sign-in page' do
get :index
expect(response).to redirect_to(new_user_session_path)
end
end
end
end
context 'with a user' do
let(:user) { create(:user) }
before do
sign_in(user)
allow(subject).to receive(:current_user).and_return(user)
end
context 'who has customized their dashboard setting for operations' do
before do
user.dashboard = 'operations'
end
context 'when licensed' do
before do
stub_licensed_features(operations_dashboard: true)
end
it 'redirects to operations dashboard' do
get :index
expect(response).to redirect_to operations_path
end
end
context 'when unlicensed' do
before do
stub_licensed_features(operations_dashboard: false)
end
it 'renders the default dashboard' do
get :index
expect(response).to render_template 'dashboard/projects/index'
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment