Commit 706609ce authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'add-internal-api-pages-enabled' into 'master'

Add status endpoint to Pages Internal API

See merge request gitlab-org/gitlab!28743
parents 87fbd139 607aaa77
---
title: Add status endpoint to Pages Internal API
merge_request: 28743
author:
type: added
......@@ -16,6 +16,13 @@ module API
namespace 'internal' do
namespace 'pages' do
desc 'Indicates that pages API is enabled and auth token is valid' do
detail 'This feature was introduced in GitLab 12.10.'
end
get "status" do
no_content!
end
desc 'Get GitLab Pages domain configuration by hostname' do
detail 'This feature was introduced in GitLab 12.3.'
end
......
......@@ -3,13 +3,36 @@
require 'spec_helper'
describe API::Internal::Pages do
describe "GET /internal/pages" do
let(:pages_secret) { SecureRandom.random_bytes(Gitlab::Pages::SECRET_LENGTH) }
let(:auth_headers) do
jwt_token = JWT.encode({ 'iss' => 'gitlab-pages' }, Gitlab::Pages.secret, 'HS256')
{ Gitlab::Pages::INTERNAL_API_REQUEST_HEADER => jwt_token }
end
let(:pages_secret) { SecureRandom.random_bytes(Gitlab::Pages::SECRET_LENGTH) }
before do
allow(Gitlab::Pages).to receive(:secret).and_return(pages_secret)
end
describe "GET /internal/pages/status" do
def query_enabled(headers = {})
get api("/internal/pages/status"), headers: headers
end
before do
allow(Gitlab::Pages).to receive(:secret).and_return(pages_secret)
it 'responds with 401 Unauthorized' do
query_enabled
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'responds with 204 no content' do
query_enabled(auth_headers)
expect(response).to have_gitlab_http_status(:no_content)
expect(response.body).to be_empty
end
end
describe "GET /internal/pages" do
def query_host(host, headers = {})
get api("/internal/pages"), headers: headers, params: { host: host }
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