FIX: Do not allow invite_only and enable_sso at the same time

This functionality was never supported but before the new review queue
it didn't have any errors. Now the combination of settings is prevented
and existing sites with sso enabled will be migrated to remove invite
only.
This commit is contained in:
Robin Ward
2019-04-02 10:26:27 -04:00
parent af04318aff
commit 6ebadaed2c
7 changed files with 78 additions and 2 deletions

View File

@ -0,0 +1,31 @@
require 'rails_helper'
RSpec.describe EnableInviteOnlyValidator do
subject { described_class.new }
context "when sso is enabled" do
before do
SiteSetting.sso_url = "https://example.com/sso"
SiteSetting.enable_sso = true
end
it "is valid when false" do
expect(subject.valid_value?('f')).to eq(true)
end
it "is isn't value for true" do
expect(subject.valid_value?('t')).to eq(false)
expect(subject.error_message).to eq(I18n.t(
'site_settings.errors.sso_invite_only'
))
end
end
context "when sso isn't enabled" do
it "is valid when true or false" do
expect(subject.valid_value?('f')).to eq(true)
expect(subject.valid_value?('t')).to eq(true)
end
end
end

View File

@ -26,6 +26,24 @@ RSpec.describe EnableSsoValidator do
end
end
describe "when invite_only is set" do
before do
SiteSetting.invite_only = true
SiteSetting.sso_url = 'https://example.com/sso'
end
it 'allows a false value' do
expect(subject.valid_value?('f')).to eq(true)
end
it "doesn't allow true" do
expect(subject.valid_value?('t')).to eq(false)
expect(subject.error_message).to eq(I18n.t(
'site_settings.errors.sso_invite_only'
))
end
end
describe "when 'sso url' is present" do
before do
SiteSetting.sso_url = "https://www.example.com/sso"