Commit 623d2a90 authored by Igor Drozdov's avatar Igor Drozdov

Expect exclusive no-store Cache-Control header

Now with 6.1 if no-store is set on Cache-Control
header all other cache directives are dropped
parent c17349a9
......@@ -61,7 +61,7 @@ RSpec.describe Admin::AuditLogReportsController do
expect(response).to have_gitlab_http_status(:ok)
expect(response.headers["Content-Length"]).to be_nil
expect(response.headers["Cache-Control"]).to eq('no-cache, no-store')
expect(response.headers["Cache-Control"]).to eq('no-store')
expect(response.headers['Content-Type']).to eq('text/csv; charset=utf-8; header=present')
expect(response.headers['X-Accel-Buffering']).to eq('no')
expect(response.headers['Last-Modified']).to eq('0')
......
......@@ -663,7 +663,7 @@ RSpec.describe User do
SELECT "users".* FROM "users"
WHERE ("users"."state" IN ('active'))
AND
("users"."user_type" IS NULL OR "users"."user_type" IN (NULL, 6, 4))
("users"."user_type" IS NULL OR "users"."user_type" IN (6, 4))
AND
("users"."user_type" IS NULL OR "users"."user_type" NOT IN (2, 6, 1, 3, 7, 8))
AND
......
......@@ -704,7 +704,7 @@ RSpec.describe ApplicationController do
get :index
expect(response.headers['Cache-Control']).to eq 'max-age=0, private, must-revalidate, no-store'
expect(response.headers['Cache-Control']).to eq 'no-store'
expect(response.headers['Pragma']).to eq 'no-cache'
end
......@@ -740,7 +740,7 @@ RSpec.describe ApplicationController do
it 'sets no-cache headers', :aggregate_failures do
subject
expect(response.headers['Cache-Control']).to eq 'no-cache, no-store'
expect(response.headers['Cache-Control']).to eq 'no-store'
expect(response.headers['Pragma']).to eq 'no-cache'
expect(response.headers['Expires']).to eq 'Fri, 01 Jan 1990 00:00:00 GMT'
end
......
......@@ -258,7 +258,7 @@ RSpec.describe SearchController do
expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['Cache-Control']).to include('max-age=60, private')
expect(response.headers['Cache-Control']).to eq('no-store')
end
end
......
......@@ -68,7 +68,7 @@ RSpec.describe 'Pipeline Badge' do
visit pipeline_project_badges_path(project, ref: ref, format: :svg)
expect(page.status_code).to eq(200)
expect(page.response_headers['Cache-Control']).to include 'no-cache'
expect(page.response_headers['Cache-Control']).to eq('no-store')
end
end
......
......@@ -558,8 +558,7 @@ RSpec.describe API::Files do
get api(url, current_user), params: params
expect(response.headers["Cache-Control"]).to include("no-store")
expect(response.headers["Cache-Control"]).to include("no-cache")
expect(response.headers["Cache-Control"]).to eq("max-age=0, private, must-revalidate, no-store, no-cache")
expect(response.headers["Pragma"]).to eq("no-cache")
expect(response.headers["Expires"]).to eq("Fri, 01 Jan 1990 00:00:00 GMT")
end
......
......@@ -178,10 +178,12 @@ RSpec.describe API::Repositories do
expect(headers['Content-Disposition']).to eq 'inline'
end
it_behaves_like 'uncached response' do
before do
get api(route, current_user)
end
it 'defines an uncached header response' do
get api(route, current_user)
expect(response.headers["Cache-Control"]).to eq("max-age=0, private, must-revalidate, no-store, no-cache")
expect(response.headers["Pragma"]).to eq("no-cache")
expect(response.headers["Expires"]).to eq("Fri, 01 Jan 1990 00:00:00 GMT")
end
context 'when sha does not exist' do
......
......@@ -298,7 +298,7 @@ RSpec.shared_examples 'wiki controller actions' do
expect(response.headers['Content-Disposition']).to match(/^inline/)
expect(response.headers[Gitlab::Workhorse::DETECT_HEADER]).to eq('true')
expect(response.cache_control[:public]).to be(false)
expect(response.cache_control[:extras]).to include('no-store')
expect(response.headers['Cache-Control']).to eq('no-store')
end
end
end
......
# frozen_string_literal: true
#
# Pairs with lib/gitlab/no_cache_headers.rb
#
RSpec.shared_examples 'uncached response' do
it 'defines an uncached header response' do
expect(response.headers["Cache-Control"]).to include("no-store", "no-cache")
expect(response.headers["Pragma"]).to eq("no-cache")
expect(response.headers["Expires"]).to eq("Fri, 01 Jan 1990 00:00:00 GMT")
end
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