File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed
files/gitlab-cookbooks/gitlab-pages/libraries
spec/chef/cookbooks/gitlab-pages/recipes Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,12 @@ def parse_auth_redirect_uri
8989
9090 pages_uri = URI ( Gitlab [ 'pages_external_url' ] . to_s )
9191 parsed_port = [ 80 , 443 ] . include? ( pages_uri . port ) ? "" : ":#{ pages_uri . port } "
92- Gitlab [ 'gitlab_pages' ] [ 'auth_redirect_uri' ] = pages_uri . scheme + '://projects.' + pages_uri . host + parsed_port + '/auth'
92+
93+ Gitlab [ 'gitlab_pages' ] [ 'auth_redirect_uri' ] = if Gitlab [ 'gitlab_pages' ] [ 'namespace_in_path' ]
94+ "#{ pages_uri . scheme } ://#{ pages_uri . host } #{ parsed_port } /projects/auth"
95+ else
96+ "#{ pages_uri . scheme } ://projects.#{ pages_uri . host } #{ parsed_port } /auth"
97+ end
9398 end
9499
95100 def authorize_with_gitlab
Original file line number Diff line number Diff line change 169169 chef_run
170170 end
171171 end
172+
173+ context 'when namespace in path is enabled' do
174+ before do
175+ stub_gitlab_rb (
176+ pages_external_url : 'https://pages.example.com' ,
177+ gitlab_pages : {
178+ access_control : true ,
179+ namespace_in_path : true ,
180+ }
181+ )
182+ end
183+
184+ it 'renders pages config file with default auth-redirect-uri' do
185+ expect ( chef_run ) . to render_file ( "/var/opt/gitlab/gitlab-pages/gitlab-pages-config" ) . with_content { |content |
186+ expect ( content ) . to match ( %r{auth-redirect-uri=https://pages.example.com/projects/auth} )
187+ expect ( content ) . to match ( %r{namespace-in-path=true} )
188+ }
189+ end
190+ end
191+
192+ context 'with custom port and namespace in path is enabled' do
193+ before do
194+ stub_gitlab_rb (
195+ pages_external_url : 'https://pages.example.com:8443' ,
196+ gitlab_pages : {
197+ access_control : true ,
198+ namespace_in_path : true ,
199+ }
200+ )
201+ end
202+
203+ it 'renders pages config file with default auth-redirect-uri' do
204+ expect ( chef_run ) . to render_file ( "/var/opt/gitlab/gitlab-pages/gitlab-pages-config" ) . with_content { |content |
205+ expect ( content ) . to match ( %r{auth-redirect-uri=https://pages.example.com:8443/projects/auth} )
206+ expect ( content ) . to match ( %r{namespace-in-path=true} )
207+ }
208+ end
209+ end
172210 end
173211
174212 context 'with custom port' do
You can’t perform that action at this time.
0 commit comments