diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-25 21:10:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-25 21:10:10 +0300 |
commit | a653b30df71fcbe5be7dd30f34622500e527b5ea (patch) | |
tree | 80ee090386c158b008a2e7c571653148c5b3d528 /spec/lib | |
parent | 180e88bbfbdd93939ec2c37e457207f29fd6ccfd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/backup/database_spec.rb | 14 | ||||
-rw-r--r-- | spec/lib/backup/gitaly_backup_spec.rb | 5 | ||||
-rw-r--r-- | spec/lib/json_web_token/hmac_token_spec.rb | 2 |
3 files changed, 9 insertions, 12 deletions
diff --git a/spec/lib/backup/database_spec.rb b/spec/lib/backup/database_spec.rb index dd8a4a14531..e0ca090d96a 100644 --- a/spec/lib/backup/database_spec.rb +++ b/spec/lib/backup/database_spec.rb @@ -272,14 +272,13 @@ RSpec.describe Backup::Database, feature_category: :backup_restore do end context 'with PostgreSQL settings defined in the environment' do - let(:cmd) { %W[#{Gem.ruby} -e] + ["$stderr.puts ENV.to_h.select { |k, _| k.start_with?('PG') }"] } let(:config) { YAML.load_file(File.join(Rails.root, 'config', 'database.yml'))['test'] } before do - stub_const 'ENV', ENV.to_h.merge({ + stub_env(ENV.to_h.merge({ 'GITLAB_BACKUP_PGHOST' => 'test.example.com', 'PGPASSWORD' => 'donotchange' - }) + })) end it 'overrides default config values' do @@ -289,12 +288,13 @@ RSpec.describe Backup::Database, feature_category: :backup_restore do expect(Rake::Task['gitlab:db:drop_tables:main']).to receive(:invoke) end + expect(ENV).to receive(:[]=).with('PGHOST', 'test.example.com') + expect(ENV).not_to receive(:[]=).with('PGPASSWORD', anything) + subject.restore(backup_dir) - expect(output).to include(%("PGHOST"=>"test.example.com")) - expect(output).to include(%("PGPASSWORD"=>"donotchange")) - expect(output).to include(%("PGPORT"=>"#{config['port']}")) if config['port'] - expect(output).to include(%("PGUSER"=>"#{config['username']}")) if config['username'] + expect(ENV['PGPORT']).to eq(config['port']) if config['port'] + expect(ENV['PGUSER']).to eq(config['username']) if config['username'] end end diff --git a/spec/lib/backup/gitaly_backup_spec.rb b/spec/lib/backup/gitaly_backup_spec.rb index 172fc28dd3e..40e835e9dc8 100644 --- a/spec/lib/backup/gitaly_backup_spec.rb +++ b/spec/lib/backup/gitaly_backup_spec.rb @@ -132,11 +132,8 @@ RSpec.describe Backup::GitalyBackup, feature_category: :backup_restore do ) end - before do - stub_const('ENV', ssl_env) - end - it 'passes through SSL envs' do + expect(subject).to receive(:current_env).and_return(ssl_env) expect(Open3).to receive(:popen2).with(expected_env, anything, 'create', '-path', anything, '-layout', 'pointer', '-id', backup_id).and_call_original subject.start(:create, destination, backup_id: backup_id) diff --git a/spec/lib/json_web_token/hmac_token_spec.rb b/spec/lib/json_web_token/hmac_token_spec.rb index 7c486b2fe1b..877184a4a3d 100644 --- a/spec/lib/json_web_token/hmac_token_spec.rb +++ b/spec/lib/json_web_token/hmac_token_spec.rb @@ -25,7 +25,7 @@ RSpec.describe JSONWebToken::HMACToken do end describe '.decode' do - let(:leeway) { described_class::IAT_LEEWAY } + let(:leeway) { described_class::LEEWAY } let(:decoded_token) { described_class.decode(encoded_token, secret, leeway: leeway) } context 'with an invalid token' do |