2019-10-15 05:06:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-02 07:41:30 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
require 'rainbow/ext/string'
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe 'seed production settings' do
|
2017-06-02 09:25:54 -04:00
|
|
|
let(:settings_file) { Rails.root.join('db/fixtures/production/010_settings.rb') }
|
|
|
|
let(:settings) { Gitlab::CurrentSettings.current_application_settings }
|
2017-06-02 07:41:30 -04:00
|
|
|
|
2018-04-16 04:46:37 -04:00
|
|
|
before do
|
|
|
|
# It's important to set this variable so that we don't save a memoized
|
|
|
|
# (supposed to be) in-memory record in `Gitlab::CurrentSettings.in_memory_application_settings`
|
|
|
|
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
|
|
|
|
end
|
|
|
|
|
2017-06-02 07:41:30 -04:00
|
|
|
context 'GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN is set in the environment' do
|
|
|
|
before do
|
|
|
|
stub_env('GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN', '013456789')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'writes the token to the database' do
|
|
|
|
load(settings_file)
|
|
|
|
|
|
|
|
expect(settings.runners_registration_token).to eq('013456789')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'GITLAB_PROMETHEUS_METRICS_ENABLED is set in the environment' do
|
|
|
|
context 'GITLAB_PROMETHEUS_METRICS_ENABLED is true' do
|
|
|
|
before do
|
|
|
|
stub_env('GITLAB_PROMETHEUS_METRICS_ENABLED', 'true')
|
|
|
|
end
|
|
|
|
|
2020-12-09 13:09:48 -05:00
|
|
|
it 'prometheus_metrics_enabled is set to true' do
|
2017-06-02 07:41:30 -04:00
|
|
|
load(settings_file)
|
|
|
|
|
|
|
|
expect(settings.prometheus_metrics_enabled).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'GITLAB_PROMETHEUS_METRICS_ENABLED is false' do
|
|
|
|
before do
|
|
|
|
stub_env('GITLAB_PROMETHEUS_METRICS_ENABLED', 'false')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'prometheus_metrics_enabled is set to false' do
|
|
|
|
load(settings_file)
|
|
|
|
|
|
|
|
expect(settings.prometheus_metrics_enabled).to eq(false)
|
|
|
|
end
|
|
|
|
end
|
2017-06-06 07:16:55 -04:00
|
|
|
|
2018-05-07 04:46:23 -04:00
|
|
|
context 'GITLAB_PROMETHEUS_METRICS_ENABLED is default' do
|
2017-06-06 07:16:55 -04:00
|
|
|
before do
|
|
|
|
stub_env('GITLAB_PROMETHEUS_METRICS_ENABLED', '')
|
|
|
|
end
|
|
|
|
|
2018-05-07 04:46:23 -04:00
|
|
|
it 'prometheus_metrics_enabled is set to true' do
|
2017-06-06 07:16:55 -04:00
|
|
|
load(settings_file)
|
|
|
|
|
2018-05-07 04:46:23 -04:00
|
|
|
expect(settings.prometheus_metrics_enabled).to eq(true)
|
2017-06-06 07:16:55 -04:00
|
|
|
end
|
|
|
|
end
|
2017-06-02 07:41:30 -04:00
|
|
|
end
|
2020-10-22 08:08:41 -04:00
|
|
|
|
|
|
|
context 'CI JWT signing key' do
|
|
|
|
it 'writes valid RSA key to the database' do
|
|
|
|
expect { load(settings_file) }.to change { settings.reload.ci_jwt_signing_key }.from(nil)
|
|
|
|
expect { OpenSSL::PKey::RSA.new(settings.ci_jwt_signing_key) }.not_to raise_error
|
|
|
|
end
|
|
|
|
end
|
2017-06-02 07:41:30 -04:00
|
|
|
end
|