diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 09:09:43 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 09:09:43 +0000 |
commit | f5050253469fc0961c02deec0e698ad62bdd9de5 (patch) | |
tree | 30bbd8f8b556fd5b730f0123921138ee1d6bdaa2 /spec/requests/api/internal/pages_spec.rb | |
parent | f6cdec670b9b757fc2225a2c6627ab79765e5b8a (diff) | |
download | gitlab-ce-f5050253469fc0961c02deec0e698ad62bdd9de5.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/internal/pages_spec.rb')
-rw-r--r-- | spec/requests/api/internal/pages_spec.rb | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/spec/requests/api/internal/pages_spec.rb b/spec/requests/api/internal/pages_spec.rb index 0c3c2fa22d6..fecf15c29c2 100644 --- a/spec/requests/api/internal/pages_spec.rb +++ b/spec/requests/api/internal/pages_spec.rb @@ -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 |