Commit 6184e401 authored by Vladlena Shumilo's avatar Vladlena Shumilo

Disable sync for offline cloud licenses

Remove the automatic seat link sync execution
for licenses with offline cloud attr enabled

Changelog: changed
EE: true
parent 97d7a956
...@@ -28,6 +28,7 @@ module Gitlab ...@@ -28,6 +28,7 @@ module Gitlab
def should_sync_seats? def should_sync_seats?
return false unless license&.cloud_license? return false unless license&.cloud_license?
return false if license.offline_cloud_license?
!license.trial? && license.expires_at.present? # Skip sync if license has no expiration !license.trial? && license.expires_at.present? # Skip sync if license has no expiration
end end
......
...@@ -584,6 +584,10 @@ class License < ApplicationRecord ...@@ -584,6 +584,10 @@ class License < ApplicationRecord
!!license&.cloud_licensing? !!license&.cloud_licensing?
end end
def offline_cloud_license?
!!license&.offline_cloud_licensing?
end
def customer_service_enabled? def customer_service_enabled?
!!license&.operational_metrics? !!license&.operational_metrics?
end end
......
...@@ -19,6 +19,14 @@ FactoryBot.define do ...@@ -19,6 +19,14 @@ FactoryBot.define do
cloud_licensing_enabled { true } cloud_licensing_enabled { true }
end end
trait :offline_enabled do
offline_cloud_licensing_enabled { true }
end
trait :offline_disabled do
offline_cloud_licensing_enabled { false }
end
transient do transient do
plan { License::STARTER_PLAN } plan { License::STARTER_PLAN }
end end
......
...@@ -166,14 +166,26 @@ RSpec.describe Gitlab::SeatLinkData do ...@@ -166,14 +166,26 @@ RSpec.describe Gitlab::SeatLinkData do
it { is_expected.to be_falsey } it { is_expected.to be_falsey }
end end
context 'when not a cloud license' do
let(:license) { build(:license) }
it { is_expected.to be_falsey }
end
context 'when cloud license for offline use' do
let(:license) { build(:license, cloud: true, offline_cloud_licensing_enabled: true) }
it { is_expected.to be_falsey }
end
context 'when expires_at is not set' do context 'when expires_at is not set' do
let(:license) { build(:license, expires_at: nil) } let(:license) { build(:license, cloud: true, expires_at: nil) }
it { is_expected.to be_falsey } it { is_expected.to be_falsey }
end end
context 'when license is trial' do context 'when license is trial' do
let(:license) { build(:license, trial: true) } let(:license) { build(:license, cloud: true, trial: true) }
it { is_expected.to be_falsey } it { is_expected.to be_falsey }
end end
......
...@@ -1486,6 +1486,36 @@ RSpec.describe License do ...@@ -1486,6 +1486,36 @@ RSpec.describe License do
end end
end end
describe '#offline_cloud_license?' do
subject { license.offline_cloud_license? }
context 'when no license provided' do
before do
license.data = nil
end
it { is_expected.to be false }
end
context 'when the license has offline cloud licensing disabled' do
let(:gl_license) { build(:gitlab_license, :cloud, :offline_disabled) }
it { is_expected.to be false }
end
context 'when the license has offline cloud licensing enabled' do
let(:gl_license) { build(:gitlab_license, :cloud, :offline_enabled) }
it { is_expected.to be true }
end
context 'when the license offline cloud licensing is not set' do
let(:gl_license) { build(:gitlab_license, :cloud) }
it { is_expected.to be false }
end
end
describe '#customer_service_enabled?' do describe '#customer_service_enabled?' do
subject { license.customer_service_enabled? } subject { license.customer_service_enabled? }
......
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