summaryrefslogtreecommitdiff
path: root/spec/requests/api/internal/pages_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-22 11:31:16 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-22 11:31:16 +0000
commit905c1110b08f93a19661cf42a276c7ea90d0a0ff (patch)
tree756d138db422392c00471ab06acdff92c5a9b69c /spec/requests/api/internal/pages_spec.rb
parent50d93f8d1686950fc58dda4823c4835fd0d8c14b (diff)
downloadgitlab-ce-905c1110b08f93a19661cf42a276c7ea90d0a0ff.tar.gz
Add latest changes from gitlab-org/gitlab@12-4-stable-ee
Diffstat (limited to 'spec/requests/api/internal/pages_spec.rb')
-rw-r--r--spec/requests/api/internal/pages_spec.rb108
1 files changed, 99 insertions, 9 deletions
diff --git a/spec/requests/api/internal/pages_spec.rb b/spec/requests/api/internal/pages_spec.rb
index e1b563b92f4..03bf748b471 100644
--- a/spec/requests/api/internal/pages_spec.rb
+++ b/spec/requests/api/internal/pages_spec.rb
@@ -43,6 +43,10 @@ describe API::Internal::Pages do
super(host, headers)
end
+ def deploy_pages(project)
+ project.mark_pages_as_deployed
+ end
+
context 'not existing host' do
it 'responds with 404 Not Found' do
query_host('pages.gitlab.io')
@@ -56,18 +60,104 @@ describe API::Internal::Pages do
let(:project) { create(:project, namespace: namespace, name: 'gitlab-ce') }
let!(:pages_domain) { create(:pages_domain, domain: 'pages.gitlab.io', project: project) }
- it 'responds with the correct domain configuration' do
- query_host('pages.gitlab.io')
+ context 'when there are no pages deployed for the related project' do
+ it 'responds with 204 No Content' do
+ query_host('pages.gitlab.io')
- expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('internal/pages/virtual_domain')
+ expect(response).to have_gitlab_http_status(204)
+ end
+ end
- expect(json_response['certificate']).to eq(pages_domain.certificate)
- expect(json_response['key']).to eq(pages_domain.key)
+ context 'when there are pages deployed for the related project' do
+ it 'responds with the correct domain configuration' do
+ deploy_pages(project)
+
+ query_host('pages.gitlab.io')
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to match_response_schema('internal/pages/virtual_domain')
+
+ expect(json_response['certificate']).to eq(pages_domain.certificate)
+ expect(json_response['key']).to eq(pages_domain.key)
+
+ expect(json_response['lookup_paths']).to eq(
+ [
+ {
+ 'project_id' => project.id,
+ 'access_control' => false,
+ 'https_only' => false,
+ 'prefix' => '/',
+ 'source' => {
+ 'type' => 'file',
+ 'path' => 'gitlab-org/gitlab-ce/public/'
+ }
+ }
+ ]
+ )
+ end
+ end
+ end
+
+ context 'namespaced domain' do
+ let(:group) { create(:group, name: 'mygroup') }
+
+ before do
+ allow(Settings.pages).to receive(:host).and_return('gitlab-pages.io')
+ allow(Gitlab.config.pages).to receive(:url).and_return("http://gitlab-pages.io")
+ end
+
+ context 'regular project' do
+ it 'responds with the correct domain configuration' do
+ project = create(:project, group: group, name: 'myproject')
+ deploy_pages(project)
+
+ query_host('mygroup.gitlab-pages.io')
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to match_response_schema('internal/pages/virtual_domain')
+
+ expect(json_response['lookup_paths']).to eq(
+ [
+ {
+ 'project_id' => project.id,
+ 'access_control' => false,
+ 'https_only' => false,
+ 'prefix' => '/myproject/',
+ 'source' => {
+ 'type' => 'file',
+ 'path' => 'mygroup/myproject/public/'
+ }
+ }
+ ]
+ )
+ end
+ end
- lookup_path = json_response['lookup_paths'][0]
- expect(lookup_path['prefix']).to eq('/')
- expect(lookup_path['source']['path']).to eq('gitlab-org/gitlab-ce/public/')
+ context 'group root project' do
+ it 'responds with the correct domain configuration' do
+ project = create(:project, group: group, name: 'mygroup.gitlab-pages.io')
+ deploy_pages(project)
+
+ query_host('mygroup.gitlab-pages.io')
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to match_response_schema('internal/pages/virtual_domain')
+
+ expect(json_response['lookup_paths']).to eq(
+ [
+ {
+ 'project_id' => project.id,
+ 'access_control' => false,
+ 'https_only' => false,
+ 'prefix' => '/',
+ 'source' => {
+ 'type' => 'file',
+ 'path' => 'mygroup/mygroup.gitlab-pages.io/public/'
+ }
+ }
+ ]
+ )
+ end
end
end
end