Commit 6d9001c7 authored by Yorick Peterse's avatar Yorick Peterse

Backport gitlab.yml.example from EE

To make this happen, we need to conditionally add the group_saml
strategy when running tests, but only on EE. This requires some changes
to Gitlab.ee? so that it can be used before/without loading the Rails
environment. We also have to change how we require a few files, so this
can run outside of Rails.
parent 2a05305b
...@@ -344,9 +344,9 @@ production: &base ...@@ -344,9 +344,9 @@ production: &base
schedule_migrate_external_diffs_worker: schedule_migrate_external_diffs_worker:
cron: "15 * * * *" cron: "15 * * * *"
## # GitLab EE only jobs. These jobs are automatically enabled for an EE
# GitLab EE only jobs: # installation, and ignored for a CE installation.
ee_cron_jobs:
# Snapshot active users statistics # Snapshot active users statistics
historical_data_worker: historical_data_worker:
cron: "0 12 * * *" cron: "0 12 * * *"
...@@ -1088,7 +1088,6 @@ test: ...@@ -1088,7 +1088,6 @@ test:
external_providers: [] external_providers: []
providers: providers:
- { name: 'group_saml' }
- { name: 'cas3', - { name: 'cas3',
label: 'cas3', label: 'cas3',
args: { url: 'https://sso.example.com', args: { url: 'https://sso.example.com',
......
...@@ -128,6 +128,15 @@ if github_settings ...@@ -128,6 +128,15 @@ if github_settings
end end
end end
# SAML should be enabled for the tests automatically, but only for EE.
saml_provider_enabled = Settings.omniauth.providers.any? do |provider|
provider['name'] == 'group_saml'
end
if Gitlab.ee? && Rails.env.test? && !saml_provider_enabled
Settings.omniauth.providers << Settingslogic.new({ 'name' => 'group_saml' })
end
Settings['shared'] ||= Settingslogic.new({}) Settings['shared'] ||= Settingslogic.new({})
Settings.shared['path'] = Settings.absolute(Settings.shared['path'] || "shared") Settings.shared['path'] = Settings.absolute(Settings.shared['path'] || "shared")
...@@ -341,6 +350,11 @@ Settings.gravatar['host'] = Settings.host_without_www(Settings.gravatar[ ...@@ -341,6 +350,11 @@ Settings.gravatar['host'] = Settings.host_without_www(Settings.gravatar[
# Cron Jobs # Cron Jobs
# #
Settings['cron_jobs'] ||= Settingslogic.new({}) Settings['cron_jobs'] ||= Settingslogic.new({})
if Gitlab.ee? && Settings['ee_cron_jobs']
Settings.cron_jobs.merge!(Settings.ee_cron_jobs)
end
Settings.cron_jobs['stuck_ci_jobs_worker'] ||= Settingslogic.new({}) Settings.cron_jobs['stuck_ci_jobs_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['stuck_ci_jobs_worker']['cron'] ||= '0 * * * *' Settings.cron_jobs['stuck_ci_jobs_worker']['cron'] ||= '0 * * * *'
Settings.cron_jobs['stuck_ci_jobs_worker']['job_class'] = 'StuckCiJobsWorker' Settings.cron_jobs['stuck_ci_jobs_worker']['job_class'] = 'StuckCiJobsWorker'
......
require 'settingslogic' require 'settingslogic'
# We can not use `Rails.root` here, as this file might be loaded without the
# full Rails environment being loaded. We can not use `require_relative` either,
# as Rails uses `load` for `require_dependency` (used when loading the Rails
# environment). This could then lead to this file being loaded twice.
require_dependency File.expand_path('../lib/gitlab', __dir__)
class Settings < Settingslogic class Settings < Settingslogic
source ENV.fetch('GITLAB_CONFIG') { Pathname.new(File.expand_path('..', __dir__)).join('config/gitlab.yml') } source ENV.fetch('GITLAB_CONFIG') { Pathname.new(File.expand_path('..', __dir__)).join('config/gitlab.yml') }
namespace ENV.fetch('GITLAB_ENV') { Rails.env } namespace ENV.fetch('GITLAB_ENV') { Rails.env }
......
# frozen_string_literal: true # frozen_string_literal: true
require_dependency 'gitlab/popen' require_dependency File.expand_path('gitlab/popen', __dir__)
module Gitlab module Gitlab
def self.root def self.root
...@@ -60,11 +60,15 @@ module Gitlab ...@@ -60,11 +60,15 @@ module Gitlab
end end
def self.ee? def self.ee?
if ENV['IS_GITLAB_EE'].present? @is_ee ||=
Gitlab::Utils.to_boolean(ENV['IS_GITLAB_EE']) if ENV['IS_GITLAB_EE'].present?
else Gitlab::Utils.to_boolean(ENV['IS_GITLAB_EE'])
Object.const_defined?(:License) else
end # We may use this method when the Rails environment is not loaded. This
# means that checking the presence of the License class could result in
# this method returning `false`, even for an EE installation.
root.join('ee/app/models/license.rb').exist?
end
end end
def self.http_proxy_env? def self.http_proxy_env?
......
...@@ -3,6 +3,7 @@ require 'bundler/setup' ...@@ -3,6 +3,7 @@ require 'bundler/setup'
ENV['GITLAB_ENV'] = 'test' ENV['GITLAB_ENV'] = 'test'
ENV['IN_MEMORY_APPLICATION_SETTINGS'] = 'true' ENV['IN_MEMORY_APPLICATION_SETTINGS'] = 'true'
require 'active_support/dependencies'
require_relative '../config/settings' require_relative '../config/settings'
require_relative 'support/rspec' require_relative 'support/rspec'
require 'active_support/all' require 'active_support/all'
......
...@@ -97,14 +97,42 @@ describe Gitlab do ...@@ -97,14 +97,42 @@ describe Gitlab do
end end
describe '.ee?' do describe '.ee?' do
before do
described_class.instance_variable_set(:@is_ee, nil)
end
after do
described_class.instance_variable_set(:@is_ee, nil)
end
it 'returns true when using Enterprise Edition' do it 'returns true when using Enterprise Edition' do
stub_const('License', Class.new) root = Pathname.new('dummy')
license_path = double(:path, exist?: true)
allow(described_class)
.to receive(:root)
.and_return(root)
allow(root)
.to receive(:join)
.with('ee/app/models/license.rb')
.and_return(license_path)
expect(described_class.ee?).to eq(true) expect(described_class.ee?).to eq(true)
end end
it 'returns false when using Community Edition' do it 'returns false when using Community Edition' do
hide_const('License') root = double(:path)
license_path = double(:path, exists?: false)
allow(described_class)
.to receive(:root)
.and_return(Pathname.new('dummy'))
allow(root)
.to receive(:join)
.with('ee/app/models/license.rb')
.and_return(license_path)
expect(described_class.ee?).to eq(false) expect(described_class.ee?).to eq(false)
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