Commit ff8a76b2 authored by Stan Hu's avatar Stan Hu

Merge branch '11594-geo-redirect-after-authentication-prevents-access-to-secondary' into 'master'

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

Closes #11594

See merge request gitlab-org/gitlab-ee!13447
parents 3566e3d0 0acaa17b
...@@ -15,5 +15,17 @@ module EE ...@@ -15,5 +15,17 @@ module EE
super super
end 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
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 @@ ...@@ -3,35 +3,98 @@
require 'spec_helper' require 'spec_helper'
describe RootController do describe RootController do
describe 'GET index' do include ::EE::GeoHelpers
let(:user) { create(:user) }
before do describe 'GET #index' do
stub_licensed_features(operations_dashboard: true) context 'when user is not logged in' do
sign_in(user) context 'on a Geo primary node' do
allow(subject).to receive(:current_user).and_return(user) set(:primary_node) { create(:geo_node, :primary) }
end
context 'who has customized their dashboard setting for operations' do before do
before do stub_current_geo_node(primary_node)
user.dashboard = 'operations' end
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 context 'when a custom home page URL is defined' do
get :index 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 end
context 'when unlicensed' do context 'on a Geo secondary node' do
set(:secondary_node) { create(:geo_node) }
before do before do
stub_licensed_features(operations_dashboard: false) stub_current_geo_node(secondary_node)
end end
it 'renders the default dashboard' do it 'redirects to the sign-in page' do
get :index 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 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