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