Commit c518549f authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Remove license check warning message on boot

We already show this message on the web so this is not needed
parent 33ad59e2
# frozen_string_literal: true # frozen_string_literal: true
Gitlab.ee do Gitlab.ee do
begin public_key_file = File.read(Rails.root.join(".license_encryption_key.pub"))
public_key_file = File.read(Rails.root.join(".license_encryption_key.pub")) public_key = OpenSSL::PKey::RSA.new(public_key_file)
public_key = OpenSSL::PKey::RSA.new(public_key_file) Gitlab::License.encryption_key = public_key
Gitlab::License.encryption_key = public_key rescue
rescue warn "WARNING: No valid license encryption key provided."
warn "WARNING: No valid license encryption key provided."
end
# Needed to run migration
if ActiveRecord::Base.connected? && ActiveRecord::Base.connection.table_exists?('licenses')
message = LicenseHelper.license_message(signed_in: true, is_admin: true, in_html: false)
if ::License.block_changes? && message.present?
warn "WARNING: #{message}"
end
end
end end
...@@ -18,7 +18,7 @@ module LicenseHelper ...@@ -18,7 +18,7 @@ module LicenseHelper
License.current&.maximum_user_count || 0 License.current&.maximum_user_count || 0
end end
def license_message(signed_in: signed_in?, is_admin: current_user&.admin?, in_html: true) def license_message(signed_in: signed_in?, is_admin: current_user&.admin?)
return unless current_license return unless current_license
return unless signed_in return unless signed_in
return unless (is_admin && current_license.notify_admins?) || current_license.notify_users? return unless (is_admin && current_license.notify_admins?) || current_license.notify_users?
...@@ -35,20 +35,18 @@ module LicenseHelper ...@@ -35,20 +35,18 @@ module LicenseHelper
message << block_changes_message message << block_changes_message
message << message << if is_admin
'Upload a new license in the admin area'
if is_admin else
'Upload a new license in the admin area' 'Ask an admin to upload a new license'
else end
'Ask an admin to upload a new license'
end
message << 'to' message << 'to'
message << (current_license.block_changes? ? 'restore' : 'ensure uninterrupted') message << (current_license.block_changes? ? 'restore' : 'ensure uninterrupted')
message << 'service.' message << 'service.'
end end
message << renewal_instructions_message(in_html: in_html) unless is_trial message << renewal_instructions_message unless is_trial
message.join(' ').html_safe message.join(' ').html_safe
end end
...@@ -144,15 +142,12 @@ module LicenseHelper ...@@ -144,15 +142,12 @@ module LicenseHelper
User.active.count User.active.count
end end
def renewal_instructions_message(in_html: true) def renewal_instructions_message
renewal_faq_url = 'https://about.gitlab.com/pricing/licensing-faq/#self-managed-gitlab' renewal_faq_url = 'https://about.gitlab.com/pricing/licensing-faq/#self-managed-gitlab'
renewal_faq_link_start = in_html ? "<a href='#{renewal_faq_url}' target='_blank'>".html_safe : '' renewal_faq_link_start = "<a href='#{renewal_faq_url}' target='_blank'>".html_safe
link_end = in_html ? '</a>'.html_safe : '' link_end = '</a>'.html_safe
message = _('For renewal instructions %{link_start}view our Licensing FAQ.%{link_end}') % { link_start: renewal_faq_link_start, link_end: link_end }
message += ' ' + renewal_faq_url unless in_html
message _('For renewal instructions %{link_start}view our Licensing FAQ.%{link_end}') % { link_start: renewal_faq_link_start, link_end: link_end }
end end
end end
...@@ -10,7 +10,10 @@ describe LicenseHelper do ...@@ -10,7 +10,10 @@ describe LicenseHelper do
describe '#license_message' do describe '#license_message' do
context 'license installed' do context 'license installed' do
subject { license_message(signed_in: true, is_admin: false) }
let(:license) { double('License') } let(:license) { double('License') }
let(:faq_link_regex) { /For renewal instructions <a href.*>view our Licensing FAQ\.<\/a>/ }
before do before do
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
...@@ -19,32 +22,16 @@ describe LicenseHelper do ...@@ -19,32 +22,16 @@ describe LicenseHelper do
allow(license).to receive(:remaining_days).and_return(4) allow(license).to receive(:remaining_days).and_return(4)
end end
context 'in HTML' do it 'does NOT have a license faq link if license is a trial' do
let(:faq_link_regex) { /For renewal instructions <a href.*>view our Licensing FAQ\.<\/a>/ } allow(license).to receive(:trial?).and_return(true)
subject { license_message(signed_in: true, is_admin: false) }
it 'does NOT have a license faq link if license is a trial' do
allow(license).to receive(:trial?).and_return(true)
expect(subject).not_to match(faq_link_regex)
end
it 'has license faq link if license is not a trial' do expect(subject).not_to match(faq_link_regex)
allow(license).to receive(:trial?).and_return(false)
expect(subject).to match(faq_link_regex)
end
end end
context 'not in HTML' do it 'has license faq link if license is not a trial' do
subject { license_message(signed_in: true, is_admin: false, in_html: false) } allow(license).to receive(:trial?).and_return(false)
it 'has license faq link if license is not a trial' do expect(subject).to match(faq_link_regex)
allow(license).to receive(:trial?).and_return(false)
expect(subject).to match(/For renewal instructions view our Licensing FAQ. https:.*/)
end
end end
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