|
904 | 904 | context 'when namespace_in_path is enabled in gitlab_pages' do
|
905 | 905 | before do
|
906 | 906 | stub_gitlab_rb(
|
907 |
| - gitlab_pages: { namespace_in_path: true } |
| 907 | + gitlab_pages: { |
| 908 | + namespace_in_path: true, |
| 909 | + auth_redirect_uri: 'https://projects.pages.localhost/auth', |
| 910 | + } |
908 | 911 | )
|
909 | 912 | end
|
910 | 913 |
|
|
918 | 921 | expect(content).to include('rewrite ^/([^/]+)/(.*)$ /$2 break;')
|
919 | 922 | expect(content).to include('proxy_set_header Host $1.$http_host;')
|
920 | 923 | expect(content).to include('proxy_set_header X-Gitlab-Namespace-In-Path $namespace;')
|
921 |
| - expect(content).to include('proxy_redirect ~^https://(projects\.pages\.localhost)/(.*)$ https://$1/$2;') |
| 924 | + expect(content).to include('proxy_redirect ~^(https://projects\.pages\.localhost/auth)(.*)$ $1$2;') |
922 | 925 | expect(content).to include('proxy_redirect ~^https://([^/]*)\.(pages\.localhost)/(.*)$ https://$2/$1/$3;')
|
923 | 926 | expect(content).to include('proxy_redirect ~^//([^/]*)\.(pages\.localhost)/(.*)$ /$1/$3;')
|
924 | 927 | expect(content).to include('proxy_redirect ~^/(.*)$ /$namespace/$1;')
|
|
935 | 938 | context 'when namespace_in_path is enabled and pages_external_url has custom port in gitlab_pages' do
|
936 | 939 | before do
|
937 | 940 | stub_gitlab_rb(
|
938 |
| - gitlab_pages: { namespace_in_path: true }, |
939 |
| - pages_external_url: 'https://pages.localhost:25800' |
| 941 | + pages_external_url: 'https://pages.localhost:25800', |
| 942 | + gitlab_pages: { |
| 943 | + namespace_in_path: true, |
| 944 | + auth_redirect_uri: 'https://projects.pages.localhost/auth', |
| 945 | + } |
940 | 946 | )
|
941 | 947 | end
|
942 | 948 |
|
|
951 | 957 | expect(content).to include('rewrite ^/([^/]+)/(.*)$ /$2 break;')
|
952 | 958 | expect(content).to include('proxy_set_header Host $1.$http_host;')
|
953 | 959 | expect(content).to include('proxy_set_header X-Gitlab-Namespace-In-Path $namespace;')
|
954 |
| - expect(content).to include('proxy_redirect ~^https://(projects\.pages\.localhost:25800)/(.*)$ https://$1/$2;') |
| 960 | + expect(content).to include('proxy_redirect ~^(https://projects\.pages\.localhost/auth)(.*)$ $1$2;') |
955 | 961 | expect(content).to include('proxy_redirect ~^https://([^/]*)\.(pages\.localhost:25800)/(.*)$ https://$2/$1/$3;')
|
956 | 962 | expect(content).to include('proxy_redirect ~^//([^/]*)\.(pages\.localhost:25800)/(.*)$ /$1/$3;')
|
957 | 963 | expect(content).to include('proxy_redirect ~^/(.*)$ /$namespace/$1;')
|
|
995 | 1001 | }
|
996 | 1002 | end
|
997 | 1003 | end
|
| 1004 | + |
| 1005 | + context 'when namespace_in_path is enabled in gitlab_pages and auth_redirect_uri has custom url' do |
| 1006 | + before do |
| 1007 | + stub_gitlab_rb( |
| 1008 | + gitlab_pages: { |
| 1009 | + namespace_in_path: true, |
| 1010 | + auth_redirect_uri: 'https://customauth.pages.localhost/auth', |
| 1011 | + } |
| 1012 | + ) |
| 1013 | + end |
| 1014 | + |
| 1015 | + it 'applies nginx namespace_in_path settings for gitlab-pages' do |
| 1016 | + expect(chef_run).to render_file(http_conf['pages']).with_content { |content| |
| 1017 | + expect(content).to include('server {').twice |
| 1018 | + expect(content).to include('server_name ~^pages\.localhost$;') |
| 1019 | + expect(content).to include('location ~ ^/(?<namespace>[^/]+)$ {') |
| 1020 | + expect(content).to include('return 301 $scheme://$http_host$request_uri/;') |
| 1021 | + expect(content).to include('location ~ ^/(?<namespace>[^/]+)/(?<project>.*)$ {') |
| 1022 | + expect(content).to include('rewrite ^/([^/]+)/(.*)$ /$2 break;') |
| 1023 | + expect(content).to include('proxy_set_header Host $1.$http_host;') |
| 1024 | + expect(content).to include('proxy_set_header X-Gitlab-Namespace-In-Path $namespace;') |
| 1025 | + expect(content).to include('proxy_redirect ~^(https://customauth\.pages\.localhost/auth)(.*)$ $1$2;') |
| 1026 | + expect(content).to include('proxy_redirect ~^https://([^/]*)\.(pages\.localhost)/(.*)$ https://$2/$1/$3;') |
| 1027 | + expect(content).to include('proxy_redirect ~^//([^/]*)\.(pages\.localhost)/(.*)$ /$1/$3;') |
| 1028 | + expect(content).to include('proxy_redirect ~^/(.*)$ /$namespace/$1;') |
| 1029 | + expect(content).to include('proxy_hide_header X-Gitlab-Namespace-In-Path;') |
| 1030 | + # Below checks are to verify proper render entries are made |
| 1031 | + expect(content).to include('proxy_http_version 1.1;').twice |
| 1032 | + expect(content).to include('proxy_pass').twice |
| 1033 | + expect(content).to include('disable_symlinks on;').twice |
| 1034 | + expect(content).to include('server_tokens off;').twice |
| 1035 | + } |
| 1036 | + end |
| 1037 | + end |
998 | 1038 | end
|
999 | 1039 |
|
1000 | 1040 | include_examples "consul service discovery", "nginx", "nginx"
|
|
0 commit comments