forked from External/greenlight
GRN2-138: Fixed issue with admin rake task (#521)
* Fixed issue with admin rake task * rspec
This commit is contained in:
parent
4a4fcec6fb
commit
c3ddb17514
|
@ -78,8 +78,6 @@ module ApplicationHelper
|
|||
def allow_greenlight_accounts?
|
||||
return Rails.configuration.allow_user_signup unless Rails.configuration.loadbalanced_configuration
|
||||
return false unless @user_domain && !@user_domain.empty? && Rails.configuration.allow_user_signup
|
||||
# No need to retrieve the provider info if the provider is whitelisted
|
||||
return true if launcher_allow_user_signup_whitelisted?(@user_domain)
|
||||
# Proceed with retrieving the provider info
|
||||
begin
|
||||
provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
|
||||
|
|
|
@ -200,9 +200,8 @@ class User < ApplicationRecord
|
|||
|
||||
def greenlight_account?
|
||||
return true unless provider # For testing cases when provider is set to null
|
||||
return provider == "greenlight" unless Rails.configuration.loadbalanced_configuration
|
||||
# No need to retrive the provider info if the provider is whitelisted
|
||||
return true if launcher_allow_user_signup_whitelisted?(provider)
|
||||
return true if provider == "greenlight"
|
||||
return false unless Rails.configuration.loadbalanced_configuration
|
||||
# Proceed with fetching the provider info
|
||||
provider_info = retrieve_provider_info(provider, 'api2', 'getUserGreenlightCredentials')
|
||||
provider_info['provider'] == 'greenlight'
|
||||
|
|
|
@ -66,7 +66,6 @@ module Greenlight
|
|||
config.loadbalancer_endpoint = ENV["LOADBALANCER_ENDPOINT"]
|
||||
config.loadbalancer_secret = ENV["LOADBALANCER_SECRET"]
|
||||
config.launcher_secret = ENV["LAUNCHER_SECRET"]
|
||||
config.launcher_allow_user_signup = ENV["LAUNCHER_ALLOW_GREENLIGHT_ACCOUNTS"]
|
||||
|
||||
# Fix endpoint format if required.
|
||||
config.loadbalancer_endpoint += "/" unless config.bigbluebutton_endpoint.ends_with?("/")
|
||||
|
|
|
@ -73,10 +73,4 @@ module BbbApi
|
|||
def remove_slash(s)
|
||||
s.nil? ? nil : s.chomp("/")
|
||||
end
|
||||
|
||||
def launcher_allow_user_signup_whitelisted?(provider)
|
||||
return false unless Rails.configuration.launcher_allow_user_signup
|
||||
whitelist = Rails.configuration.launcher_allow_user_signup.split(',')
|
||||
whitelist.include?(provider)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -65,20 +65,9 @@ describe ApplicationHelper do
|
|||
expect(helper.allow_greenlight_accounts?).to eql(false)
|
||||
end
|
||||
|
||||
it "allows if user_domain is white listed" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
allow(helper).to receive(:launcher_allow_user_signup_whitelisted?).and_return(true)
|
||||
|
||||
@user_domain = "provider1"
|
||||
|
||||
expect(helper.allow_greenlight_accounts?).to eql(true)
|
||||
end
|
||||
|
||||
it "allows if user provider is set to greenlight" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
allow(helper).to receive(:launcher_allow_user_signup_whitelisted?).and_return(false)
|
||||
allow(helper).to receive(:retrieve_provider_info).and_return("provider" => "greenlight")
|
||||
|
||||
@user_domain = "provider1"
|
||||
|
@ -89,7 +78,6 @@ describe ApplicationHelper do
|
|||
it "doesnt allow if user provider is not set to greenlight" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
allow(helper).to receive(:launcher_allow_user_signup_whitelisted?).and_return(false)
|
||||
allow(helper).to receive(:retrieve_provider_info).and_return("provider" => "google")
|
||||
|
||||
@user_domain = "provider1"
|
||||
|
|
Loading…
Reference in New Issue