Commit 9786eda8 authored by Douwe Maan's avatar Douwe Maan

Split up ldap_extras feature into ldap_group_sync and multiple_ldap_servers

parent 07630469
...@@ -17,6 +17,6 @@ class Groups::LdapsController < Groups::ApplicationController ...@@ -17,6 +17,6 @@ class Groups::LdapsController < Groups::ApplicationController
private private
def check_enabled_extras! def check_enabled_extras!
render_404 unless Gitlab::LDAP::Config.enabled_extras? render_404 unless Gitlab::LDAP::Config.enabled? && ::License.feature_available?(:ldap_group_sync)
end end
end end
...@@ -18,7 +18,8 @@ class License < ActiveRecord::Base ...@@ -18,7 +18,8 @@ class License < ActiveRecord::Base
issue_board_milestone issue_board_milestone
issue_weights issue_weights
jenkins_integration jenkins_integration
ldap_extras ldap_group_sync
multiple_ldap_servers
merge_request_approvers merge_request_approvers
merge_request_rebase merge_request_rebase
merge_request_squash merge_request_squash
...@@ -108,7 +109,8 @@ class License < ActiveRecord::Base ...@@ -108,7 +109,8 @@ class License < ActiveRecord::Base
elastic_search elastic_search
extended_audit_events extended_audit_events
geo geo
ldap_extras ldap_group_sync
multiple_ldap_servers
object_storage object_storage
repository_size_limit repository_size_limit
].freeze ].freeze
......
...@@ -3,7 +3,7 @@ class LdapAllGroupsSyncWorker ...@@ -3,7 +3,7 @@ class LdapAllGroupsSyncWorker
include CronjobQueue include CronjobQueue
def perform def perform
return unless Gitlab::LDAP::Config.enabled_extras? return unless Gitlab::LDAP::Config.enabled? && ::License.feature_available?(:ldap_group_sync)
logger.info 'Started LDAP group sync' logger.info 'Started LDAP group sync'
EE::Gitlab::LDAP::Sync::Groups.execute EE::Gitlab::LDAP::Sync::Groups.execute
......
...@@ -3,7 +3,7 @@ class LdapGroupSyncWorker ...@@ -3,7 +3,7 @@ class LdapGroupSyncWorker
include DedicatedSidekiqQueue include DedicatedSidekiqQueue
def perform(group_ids, provider = nil) def perform(group_ids, provider = nil)
return unless Gitlab::LDAP::Config.enabled_extras? return unless Gitlab::LDAP::Config.enabled? && ::License.feature_available?(:ldap_group_sync)
groups = Group.where(id: Array(group_ids)) groups = Group.where(id: Array(group_ids))
......
...@@ -3,7 +3,7 @@ class LdapSyncWorker ...@@ -3,7 +3,7 @@ class LdapSyncWorker
include CronjobQueue include CronjobQueue
def perform def perform
return unless Gitlab::LDAP::Config.enabled_extras? return unless Gitlab::LDAP::Config.enabled? && ::License.feature_available?(:ldap_group_sync)
Rails.logger.info "Performing daily LDAP sync task." Rails.logger.info "Performing daily LDAP sync task."
User.ldap.find_each(batch_size: 100).each do |ldap_user| User.ldap.find_each(batch_size: 100).each do |ldap_user|
......
- if Gitlab::LDAP::Config.enabled_extras? && can?(current_user, :admin_ldap_group_links, @group) - if Gitlab::LDAP::Config.enabled? && ::License.feature_available?(:ldap_group_sync) && can?(current_user, :admin_ldap_group_links, @group)
= nav_link(path: 'ldap_group_links#index') do = nav_link(path: 'ldap_group_links#index') do
= link_to group_ldap_group_links_path(@group), title: 'LDAP Group' do = link_to group_ldap_group_links_path(@group), title: 'LDAP Group' do
%span %span
......
module EE
module Gitlab
module LDAP
module Config
extend ActiveSupport::Concern
class_methods do
def enabled_extras?
enabled? && ::License.feature_available?(:ldap_extras)
end
end
end
end
end
end
...@@ -213,7 +213,7 @@ module API ...@@ -213,7 +213,7 @@ module API
desc 'Sync a group with LDAP.' desc 'Sync a group with LDAP.'
post ":id/ldap_sync" do post ":id/ldap_sync" do
not_found! unless Gitlab::LDAP::Config.enabled_extras? not_found! unless Gitlab::LDAP::Config.enabled? && ::License.feature_available?(:ldap_group_sync)
group = find_group!(params[:id]) group = find_group!(params[:id])
authorize! :admin_group, group authorize! :admin_group, group
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
module Gitlab module Gitlab
module LDAP module LDAP
class Config class Config
include ::EE::Gitlab::LDAP::Config
NET_LDAP_ENCRYPTION_METHOD = { NET_LDAP_ENCRYPTION_METHOD = {
simple_tls: :simple_tls, simple_tls: :simple_tls,
start_tls: :start_tls, start_tls: :start_tls,
...@@ -27,7 +25,7 @@ module Gitlab ...@@ -27,7 +25,7 @@ module Gitlab
def self.available_servers def self.available_servers
return [] unless enabled? return [] unless enabled?
enabled_extras? ? servers : Array.wrap(servers.first) ::License.feature_available?(:multiple_ldap_servers) ? servers : Array.wrap(servers.first)
end end
def self.providers def self.providers
......
...@@ -700,9 +700,13 @@ describe API::Groups do ...@@ -700,9 +700,13 @@ describe API::Groups do
end end
describe 'POST /groups/:id/ldap_sync' do describe 'POST /groups/:id/ldap_sync' do
context 'when LDAP config enabled_extras is true' do
before do before do
allow(Gitlab::LDAP::Config).to receive(:enabled_extras?).and_return(true) allow(Gitlab::LDAP::Config).to receive(:enabled?).and_return(true)
end
context 'when the ldap_group_sync feature is available' do
before do
stub_licensed_features(ldap_group_sync: true)
end end
context 'when authenticated as the group owner' do context 'when authenticated as the group owner' do
...@@ -772,9 +776,9 @@ describe API::Groups do ...@@ -772,9 +776,9 @@ describe API::Groups do
end end
end end
context 'when LDAP config enabled_extras is false' do context 'when the ldap_group_sync feature is not available' do
before do before do
allow(Gitlab::LDAP::Config).to receive(:enabled_extras?).and_return(false) stub_licensed_features(ldap_group_sync: false)
end end
it 'returns 404 (same as CE would)' do it 'returns 404 (same as CE would)' do
......
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