forked from bigbluebutton/greenlight
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3e8778
commit 0c05b7b
Showing
5 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
db/data/20240806205559_add_domain_specific_email_signup_to_site_settings.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddDomainSpecificEmailSignupToSiteSettings < ActiveRecord::Migration[7.1] | ||
def up | ||
setting = Setting.find_or_create_by(name: 'SpecificEmailDomainSignUp') | ||
|
||
SiteSetting.create!(setting:, value: '', provider: 'greenlight') unless SiteSetting.exists?(setting:, provider: 'greenlight') | ||
|
||
Tenant.all.each do |tenant| | ||
SiteSetting.create!(setting:, value: '', provider: tenant.name) unless SiteSetting.exists?(setting:, provider: tenant.name) | ||
end | ||
end | ||
|
||
def down | ||
Tenant.all.each do |tenant| | ||
SiteSetting.find_by(setting: Setting.find_by(name: 'Maintenance'), provider: tenant.name)&.destroy | ||
end | ||
|
||
SiteSetting.find_by(setting: Setting.find_by(name: 'Maintenance'), provider: 'greenlight')&.destroy | ||
|
||
Setting.find_by(name: 'SpecificEmailDomainSignUp')&.destroy | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
DataMigrate::Data.define(version: 20240423162700) | ||
DataMigrate::Data.define(version: 20240806205559) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -301,6 +301,66 @@ | |
expect(response.parsed_body['errors']).not_to be_nil | ||
end | ||
end | ||
|
||
context 'Specific Email Domain Signup' do | ||
context 'restricted domain not set' do | ||
before do | ||
site_settings = instance_double(SettingGetter) | ||
allow(SettingGetter).to receive(:new).with(setting_name: 'SpecificEmailDomainSignUp', provider: 'greenlight').and_return(site_settings) | ||
allow(site_settings).to receive(:call).and_return('') | ||
end | ||
|
||
it 'creates the user' do | ||
expect { post :create, params: user_params }.to change(User, :count).from(0).to(1) | ||
end | ||
end | ||
|
||
context 'restricted domain set to 1 domain' do | ||
before do | ||
site_settings = instance_double(SettingGetter) | ||
allow(SettingGetter).to receive(:new).with(setting_name: 'SpecificEmailDomainSignUp', provider: 'greenlight').and_return(site_settings) | ||
allow(site_settings).to receive(:call).and_return('@domain.com') | ||
end | ||
|
||
it 'creates the user if the domain is allowed' do | ||
user_params[:user][:email] = '[email protected]' | ||
expect { post :create, params: user_params }.to change(User, :count).from(0).to(1) | ||
end | ||
|
||
it 'does not create if the domain is not allowed' do | ||
user_params[:user][:email] = '[email protected]' | ||
expect { post :create, params: user_params }.not_to change(User, :count) | ||
end | ||
end | ||
|
||
context 'restricted domain set to multiple domain' do | ||
before do | ||
site_settings = instance_double(SettingGetter) | ||
allow(SettingGetter).to receive(:new).with(setting_name: 'SpecificEmailDomainSignUp', provider: 'greenlight').and_return(site_settings) | ||
allow(site_settings).to receive(:call).and_return('@example.com,@test.com,@domain.com') | ||
end | ||
|
||
it 'creates the user if the domain is allowed 1' do | ||
user_params[:user][:email] = '[email protected]' | ||
expect { post :create, params: user_params }.to change(User, :count).from(0).to(1) | ||
end | ||
|
||
it 'creates the user if the domain is allowed 2' do | ||
user_params[:user][:email] = '[email protected]' | ||
expect { post :create, params: user_params }.to change(User, :count).from(0).to(1) | ||
end | ||
|
||
it 'creates the user if the domain is allowed 3' do | ||
user_params[:user][:email] = '[email protected]' | ||
expect { post :create, params: user_params }.to change(User, :count).from(0).to(1) | ||
end | ||
|
||
it 'does not create if the domain is not allowed' do | ||
user_params[:user][:email] = '[email protected]' | ||
expect { post :create, params: user_params }.not_to change(User, :count) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe '#show' do | ||
|