Commit e44821cd authored by Toon Claes's avatar Toon Claes

More readonly to read_only renames

parent 6f3055fa
...@@ -174,8 +174,8 @@ module Gitlab ...@@ -174,8 +174,8 @@ module Gitlab
ENV['GITLAB_PATH_OUTSIDE_HOOK'] = ENV['PATH'] ENV['GITLAB_PATH_OUTSIDE_HOOK'] = ENV['PATH']
ENV['GIT_TERMINAL_PROMPT'] = '0' ENV['GIT_TERMINAL_PROMPT'] = '0'
# Gitlab Readonly middleware support # Gitlab Read-only middleware support
config.middleware.insert_after ActionDispatch::Flash, 'Gitlab::Middleware::Readonly' config.middleware.insert_after ActionDispatch::Flash, 'Gitlab::Middleware::ReadOnly'
config.generators do |g| config.generators do |g|
g.factory_girl false g.factory_girl false
......
...@@ -19,8 +19,8 @@ module Gitlab ...@@ -19,8 +19,8 @@ module Gitlab
command_not_allowed: "The command you're trying to execute is not allowed.", command_not_allowed: "The command you're trying to execute is not allowed.",
upload_pack_disabled_over_http: 'Pulling over HTTP is not allowed.', upload_pack_disabled_over_http: 'Pulling over HTTP is not allowed.',
receive_pack_disabled_over_http: 'Pushing over HTTP is not allowed.', receive_pack_disabled_over_http: 'Pushing over HTTP is not allowed.',
readonly: 'The repository is temporarily read-only. Please try again later.', read_only: 'The repository is temporarily read-only. Please try again later.',
cannot_push_to_readonly: "You can't push code to a read-only GitLab instance." cannot_push_to_read_only: "You can't push code to a read-only GitLab instance."
}.freeze }.freeze
DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive }.freeze DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive }.freeze
...@@ -173,11 +173,11 @@ module Gitlab ...@@ -173,11 +173,11 @@ module Gitlab
# TODO: please clean this up # TODO: please clean this up
def check_push_access!(changes) def check_push_access!(changes)
if project.repository_read_only? if project.repository_read_only?
raise UnauthorizedError, ERROR_MESSAGES[:readonly] raise UnauthorizedError, ERROR_MESSAGES[:read_only]
end end
if Gitlab::Database.read_only? if Gitlab::Database.read_only?
raise UnauthorizedError, ERROR_MESSAGES[:cannot_push_to_readonly] raise UnauthorizedError, ERROR_MESSAGES[:cannot_push_to_read_only]
end end
if deploy_key if deploy_key
......
module Gitlab module Gitlab
module Middleware module Middleware
class Readonly class ReadOnly
DISALLOWED_METHODS = %w(POST PATCH PUT DELETE).freeze DISALLOWED_METHODS = %w(POST PATCH PUT DELETE).freeze
APPLICATION_JSON = 'application/json'.freeze APPLICATION_JSON = 'application/json'.freeze
API_VERSIONS = (3..4) API_VERSIONS = (3..4)
...@@ -14,7 +14,7 @@ module Gitlab ...@@ -14,7 +14,7 @@ module Gitlab
@env = env @env = env
if disallowed_request? && Gitlab::Database.read_only? if disallowed_request? && Gitlab::Database.read_only?
Rails.logger.debug('GitLab Readonly: preventing possible non readonly operation') Rails.logger.debug('GitLab ReadOnly: preventing possible non read-only operation')
error_message = 'You cannot do writing operations on a read-only GitLab instance' error_message = 'You cannot do writing operations on a read-only GitLab instance'
if json_request? if json_request?
......
...@@ -83,7 +83,7 @@ describe EE::User do ...@@ -83,7 +83,7 @@ describe EE::User do
expect(subject.reload.remember_created_at).to be_nil expect(subject.reload.remember_created_at).to be_nil
end end
it 'does not clear remember_created_at when in a GitLab readonly instance' do it 'does not clear remember_created_at when in a GitLab read-only instance' do
allow(Gitlab::Database).to receive(:read_only?) { true } allow(Gitlab::Database).to receive(:read_only?) { true }
expect { subject.forget_me! }.not_to change(subject, :remember_created_at) expect { subject.forget_me! }.not_to change(subject, :remember_created_at)
...@@ -99,7 +99,7 @@ describe EE::User do ...@@ -99,7 +99,7 @@ describe EE::User do
expect(subject.reload.remember_created_at).not_to be_nil expect(subject.reload.remember_created_at).not_to be_nil
end end
it 'does not update remember_created_at when in a Geo readonly instance' do it 'does not update remember_created_at when in a Geo read-only instance' do
allow(Gitlab::Database).to receive(:read_only?) { true } allow(Gitlab::Database).to receive(:read_only?) { true }
expect { subject.remember_me! }.not_to change(subject, :remember_created_at) expect { subject.remember_me! }.not_to change(subject, :remember_created_at)
......
...@@ -174,7 +174,7 @@ FactoryGirl.define do ...@@ -174,7 +174,7 @@ FactoryGirl.define do
end end
end end
trait :readonly do trait :read_only do
repository_read_only true repository_read_only true
end end
......
...@@ -36,7 +36,7 @@ describe Banzai::Renderer do ...@@ -36,7 +36,7 @@ describe Banzai::Renderer do
is_expected.to eq('field_html') is_expected.to eq('field_html')
end end
it "skips database caching on a GitLab readonly instance" do it "skips database caching on a GitLab read-only instance" do
allow(Gitlab::Database).to receive(:read_only?).and_return(true) allow(Gitlab::Database).to receive(:read_only?).and_return(true)
expect(object).to receive(:refresh_markdown_cache!) expect(object).to receive(:refresh_markdown_cache!)
......
...@@ -943,7 +943,7 @@ describe Gitlab::GitAccess do ...@@ -943,7 +943,7 @@ describe Gitlab::GitAccess do
end end
context 'when the repository is read only' do context 'when the repository is read only' do
let(:project) { create(:project, :repository, :readonly) } let(:project) { create(:project, :repository, :read_only) }
it 'denies push access' do it 'denies push access' do
project.add_master(user) project.add_master(user)
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Middleware::Readonly do describe Gitlab::Middleware::ReadOnly do
include Rack::Test::Methods include Rack::Test::Methods
RSpec::Matchers.define :be_a_redirect do RSpec::Matchers.define :be_a_redirect do
...@@ -38,7 +38,7 @@ describe Gitlab::Middleware::Readonly do ...@@ -38,7 +38,7 @@ describe Gitlab::Middleware::Readonly do
let(:request) { Rack::MockRequest.new(rack_stack) } let(:request) { Rack::MockRequest.new(rack_stack) }
context 'normal requests to a readonly Gitlab instance' do context 'normal requests to a read-only Gitlab instance' do
let(:fake_app) { lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['OK']] } } let(:fake_app) { lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['OK']] } }
before do before do
......
...@@ -2928,7 +2928,7 @@ describe Project do ...@@ -2928,7 +2928,7 @@ describe Project do
expect(project.migrate_to_hashed_storage!).to be_truthy expect(project.migrate_to_hashed_storage!).to be_truthy
end end
it 'flags as readonly' do it 'flags as read-only' do
expect { project.migrate_to_hashed_storage! }.to change { project.repository_read_only }.to(true) expect { project.migrate_to_hashed_storage! }.to change { project.repository_read_only }.to(true)
end end
...@@ -3055,7 +3055,7 @@ describe Project do ...@@ -3055,7 +3055,7 @@ describe Project do
expect(project.migrate_to_hashed_storage!).to be_nil expect(project.migrate_to_hashed_storage!).to be_nil
end end
it 'does not flag as readonly' do it 'does not flag as read-only' do
expect { project.migrate_to_hashed_storage! }.not_to change { project.repository_read_only } expect { project.migrate_to_hashed_storage! }.not_to change { project.repository_read_only }
end end
end end
......
...@@ -20,7 +20,7 @@ describe Projects::HashedStorageMigrationService do ...@@ -20,7 +20,7 @@ describe Projects::HashedStorageMigrationService do
expect(gitlab_shell.exists?(project.repository_storage_path, "#{hashed_storage.disk_path}.wiki.git")).to be_truthy expect(gitlab_shell.exists?(project.repository_storage_path, "#{hashed_storage.disk_path}.wiki.git")).to be_truthy
end end
it 'updates project to be hashed and not readonly' do it 'updates project to be hashed and not read-only' do
service.execute service.execute
expect(project.hashed_storage?).to be_truthy expect(project.hashed_storage?).to be_truthy
......
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