Commit c37e7abd authored by Imre Farkas's avatar Imre Farkas

Merge branch 'dblessing_disable_enforced_sso_plan_expires' into 'master'

When a namespace GitLab Subscription expires, disable SSO enforcement

Closes #34287

See merge request gitlab-org/gitlab!21135
parents 81dd2f03 f34d845e
---
title: When a namespace GitLab Subscription expires, disable SSO enforcement
merge_request: 21135
author:
type: fixed
...@@ -30,7 +30,7 @@ class SamlProvider < ApplicationRecord ...@@ -30,7 +30,7 @@ class SamlProvider < ApplicationRecord
end end
def enforced_sso? def enforced_sso?
enabled? && super && ::Feature.enabled?(:enforced_sso, group) enabled? && super && group.feature_available?(:group_saml) && ::Feature.enabled?(:enforced_sso, group)
end end
def enforced_group_managed_accounts? def enforced_group_managed_accounts?
......
...@@ -34,6 +34,7 @@ describe RoutableActions do ...@@ -34,6 +34,7 @@ describe RoutableActions do
let(:user) { identity.user } let(:user) { identity.user }
before do before do
stub_licensed_features(group_saml: true)
sign_in(user) sign_in(user)
end end
......
...@@ -80,6 +80,7 @@ describe GroupsController do ...@@ -80,6 +80,7 @@ describe GroupsController do
let(:guest_user) { identity.user } let(:guest_user) { identity.user }
before do before do
stub_licensed_features(group_saml: true)
group.add_guest(guest_user) group.add_guest(guest_user)
sign_in(guest_user) sign_in(guest_user)
end end
......
...@@ -25,7 +25,7 @@ describe Groups::Security::CredentialsController do ...@@ -25,7 +25,7 @@ describe Groups::Security::CredentialsController do
context 'when `credentials_inventory` feature is enabled' do context 'when `credentials_inventory` feature is enabled' do
before do before do
stub_licensed_features(credentials_inventory: true) stub_licensed_features(credentials_inventory: true, group_saml: true)
end end
context 'for a group that enforces group managed accounts' do context 'for a group that enforces group managed accounts' do
......
...@@ -20,7 +20,7 @@ describe 'Groups::Security::Credentials' do ...@@ -20,7 +20,7 @@ describe 'Groups::Security::Credentials' do
context 'licensed' do context 'licensed' do
before do before do
stub_licensed_features(credentials_inventory: true) stub_licensed_features(credentials_inventory: true, group_saml: true)
end end
context 'links' do context 'links' do
......
...@@ -6,6 +6,10 @@ describe Gitlab::Auth::GroupSaml::SsoEnforcer do ...@@ -6,6 +6,10 @@ describe Gitlab::Auth::GroupSaml::SsoEnforcer do
let(:saml_provider) { build_stubbed(:saml_provider, enforced_sso: true) } let(:saml_provider) { build_stubbed(:saml_provider, enforced_sso: true) }
let(:session) { {} } let(:session) { {} }
before do
stub_licensed_features(group_saml: true)
end
around do |example| around do |example|
Gitlab::Session.with_session(session) do Gitlab::Session.with_session(session) do
example.run example.run
......
...@@ -8,6 +8,10 @@ describe Identity do ...@@ -8,6 +8,10 @@ describe Identity do
end end
context 'with saml_provider' do context 'with saml_provider' do
before do
stub_licensed_features(group_saml: true)
end
it 'allows user to have records with different groups' do it 'allows user to have records with different groups' do
_identity_one = create(:identity, provider: 'group_saml', saml_provider: create(:saml_provider)) _identity_one = create(:identity, provider: 'group_saml', saml_provider: create(:saml_provider))
identity_two = create(:identity, provider: 'group_saml', saml_provider: create(:saml_provider)) identity_two = create(:identity, provider: 'group_saml', saml_provider: create(:saml_provider))
......
...@@ -3,6 +3,14 @@ ...@@ -3,6 +3,14 @@
require 'spec_helper' require 'spec_helper'
describe SamlProvider do describe SamlProvider do
let(:group) { create(:group) }
subject(:saml_provider) { create(:saml_provider, group: group) }
before do
stub_licensed_features(group_saml: true)
end
describe "Associations" do describe "Associations" do
it { is_expected.to belong_to :group } it { is_expected.to belong_to :group }
it { is_expected.to have_many :identities } it { is_expected.to have_many :identities }
...@@ -55,8 +63,6 @@ describe SamlProvider do ...@@ -55,8 +63,6 @@ describe SamlProvider do
end end
describe 'Default values' do describe 'Default values' do
subject(:saml_provider) { described_class.new }
it 'defaults enabled to true' do it 'defaults enabled to true' do
expect(subject).to be_enabled expect(subject).to be_enabled
end end
...@@ -66,8 +72,6 @@ describe SamlProvider do ...@@ -66,8 +72,6 @@ describe SamlProvider do
let(:group) { create(:group, path: 'foo-group') } let(:group) { create(:group, path: 'foo-group') }
let(:settings) { subject.settings } let(:settings) { subject.settings }
subject(:saml_provider) { create(:saml_provider, group: group) }
before do before do
stub_default_url_options(protocol: "https") stub_default_url_options(protocol: "https")
end end
...@@ -117,6 +121,13 @@ describe SamlProvider do ...@@ -117,6 +121,13 @@ describe SamlProvider do
expect(subject).not_to be_enforced_sso expect(subject).not_to be_enforced_sso
end end
end end
it 'does not enforce SSO when the feature is unavailable' do
stub_licensed_features(group_saml: false)
subject.enforced_sso = true
expect(subject).not_to be_enforced_sso
end
end end
context 'when provider is disabled' do context 'when provider is disabled' do
......
...@@ -141,6 +141,10 @@ describe GroupPolicy do ...@@ -141,6 +141,10 @@ describe GroupPolicy do
let_it_be(:saml_provider) { create(:saml_provider, group: group, enforced_sso: true) } let_it_be(:saml_provider) { create(:saml_provider, group: group, enforced_sso: true) }
before do
stub_licensed_features(group_saml: true)
end
context 'when the session has been set globally' do context 'when the session has been set globally' do
around do |example| around do |example|
Gitlab::Session.with_session({}) do Gitlab::Session.with_session({}) do
......
...@@ -16,6 +16,7 @@ describe ProjectPolicy do ...@@ -16,6 +16,7 @@ describe ProjectPolicy do
subject { described_class.new(current_user, project) } subject { described_class.new(current_user, project) }
before do before do
stub_licensed_features(group_saml: true)
project.add_maintainer(maintainer) project.add_maintainer(maintainer)
project.add_developer(developer) project.add_developer(developer)
project.add_reporter(reporter) project.add_reporter(reporter)
......
...@@ -12,6 +12,10 @@ RSpec.shared_examples 'base SamlProvider service' do ...@@ -12,6 +12,10 @@ RSpec.shared_examples 'base SamlProvider service' do
let(:fingerprint) { '11:22:33:44:55:66:77:88:99:11:22:33:44:55:66:77:88:99' } let(:fingerprint) { '11:22:33:44:55:66:77:88:99:11:22:33:44:55:66:77:88:99' }
before do
stub_licensed_features(group_saml: true)
end
it 'updates SAML provider with given params' do it 'updates SAML provider with given params' do
expect do expect do
service.execute service.execute
......
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