forked from External/greenlight
GRN2-180: First stages of refactoring code for v2.4 (#748)
* Email rescues and authenticator concern * Application controller and helper clean up * Moved controller code out of helpers * More helper and email clean up * Cleaned up remaining helpers and create omniauth_options * Controller code clean up * restructured views structure * Restructured role code * Restructured profile and code clean up * Master merge * Added bbb server concern to deal with bbb calls * Bug fixes and changes after changes * rspec * More rubocop fixes
This commit is contained in:
88
spec/concerns/bbb_server_spec.rb
Normal file
88
spec/concerns/bbb_server_spec.rb
Normal file
@ -0,0 +1,88 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
|
||||
#
|
||||
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free Software
|
||||
# Foundation; either version 3.0 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License along
|
||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require "rails_helper"
|
||||
require 'bigbluebutton_api'
|
||||
|
||||
describe BbbServer do
|
||||
include BbbServer
|
||||
|
||||
let(:bbb_server) { BigBlueButton::BigBlueButtonApi.new("http://bbb.example.com/bigbluebutton/api", "secret", "0.8") }
|
||||
|
||||
before do
|
||||
@user = create(:user)
|
||||
@room = @user.main_room
|
||||
end
|
||||
|
||||
context "#running?" do
|
||||
it "should return false when not running" do
|
||||
expect(room_running?(@room.bbb_id)).to be false
|
||||
end
|
||||
|
||||
it "should return true when running" do
|
||||
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(true)
|
||||
expect(room_running?(@room.bbb_id)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context "#start_session" do
|
||||
it "should update latest session info" do
|
||||
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:create_meeting).and_return(
|
||||
messageKey: ""
|
||||
)
|
||||
|
||||
expect do
|
||||
start_session(@room)
|
||||
end.to change { @room.sessions }.by(1)
|
||||
|
||||
expect(@room.last_session).not_to be nil
|
||||
end
|
||||
end
|
||||
|
||||
context "#join_path" do
|
||||
it "should return correct join URL for user" do
|
||||
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_meeting_info).and_return(
|
||||
attendeePW: @room.attendee_pw
|
||||
)
|
||||
|
||||
endpoint = Rails.configuration.bigbluebutton_endpoint
|
||||
secret = Rails.configuration.bigbluebutton_secret
|
||||
fullname = "fullName=Example"
|
||||
join_via_html5 = "&join_via_html5=true"
|
||||
meeting_id = "&meetingID=#{@room.bbb_id}"
|
||||
password = "&password=#{@room.attendee_pw}"
|
||||
|
||||
query = fullname + join_via_html5 + meeting_id + password
|
||||
checksum_string = "join#{query + secret}"
|
||||
|
||||
checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack1("H*")
|
||||
expect(join_path(@room, "Example")).to eql("#{endpoint}join?#{query}&checksum=#{checksum}")
|
||||
end
|
||||
end
|
||||
|
||||
context "#recordings" do
|
||||
it "deletes the recording" do
|
||||
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:delete_recordings).and_return(
|
||||
returncode: true, deleted: true
|
||||
)
|
||||
|
||||
expect(delete_recording(Faker::IDNumber.valid))
|
||||
.to contain_exactly([:returncode, true], [:deleted, true])
|
||||
end
|
||||
end
|
||||
end
|
@ -19,13 +19,15 @@
|
||||
require "rails_helper"
|
||||
require 'bigbluebutton_api'
|
||||
|
||||
shared_examples_for "recorder" do
|
||||
let(:controller) { described_class } # the class that includes the concern
|
||||
describe Recorder do
|
||||
include Recorder
|
||||
include BbbServer
|
||||
|
||||
let(:bbb_server) { BigBlueButton::BigBlueButtonApi.new("http://bbb.example.com/bigbluebutton/api", "secret", "0.8") }
|
||||
|
||||
before do
|
||||
@user = create(:user)
|
||||
@room = @user.main_room
|
||||
|
||||
allow_any_instance_of(Room).to receive(:owner).and_return(@user)
|
||||
end
|
||||
|
||||
@ -44,7 +46,7 @@ shared_examples_for "recorder" do
|
||||
]
|
||||
)
|
||||
|
||||
expect(recordings(@room.bbb_id, @room.owner.provider)).to contain_exactly(
|
||||
expect(recordings(@room.bbb_id)).to contain_exactly(
|
||||
name: "Example",
|
||||
playbacks:
|
||||
[
|
||||
@ -118,7 +120,7 @@ shared_examples_for "recorder" do
|
||||
]
|
||||
)
|
||||
|
||||
expect(all_recordings(@user.rooms.pluck(:bbb_id), @user.provider, search: "Exam", column: "name",
|
||||
expect(all_recordings(@user.rooms.pluck(:bbb_id), search: "Exam", column: "name",
|
||||
direction: "desc")).to eq(
|
||||
[
|
||||
{
|
||||
@ -219,7 +221,7 @@ shared_examples_for "recorder" do
|
||||
end
|
||||
|
||||
it "should filter recordings on name" do
|
||||
expect(recordings(@room.bbb_id, @room.owner.provider, search: "Exam")).to contain_exactly(
|
||||
expect(recordings(@room.bbb_id, search: "Exam")).to contain_exactly(
|
||||
{
|
||||
meetingID: @room.bbb_id,
|
||||
name: "aExamaaa",
|
||||
@ -250,7 +252,7 @@ shared_examples_for "recorder" do
|
||||
end
|
||||
|
||||
it "should filter recordings on participants" do
|
||||
expect(recordings(@room.bbb_id, @room.owner.provider, search: "5")).to contain_exactly(
|
||||
expect(recordings(@room.bbb_id, search: "5")).to contain_exactly(
|
||||
meetingID: @room.bbb_id,
|
||||
name: "aExamaaa",
|
||||
participants: "5",
|
||||
@ -267,7 +269,7 @@ shared_examples_for "recorder" do
|
||||
end
|
||||
|
||||
it "should filter recordings on format" do
|
||||
expect(recordings(@room.bbb_id, @room.owner.provider, search: "presentation")).to contain_exactly(
|
||||
expect(recordings(@room.bbb_id, search: "presentation")).to contain_exactly(
|
||||
{
|
||||
meetingID: @room.bbb_id,
|
||||
name: "test",
|
||||
@ -298,7 +300,7 @@ shared_examples_for "recorder" do
|
||||
end
|
||||
|
||||
it "should filter recordings on visibility" do
|
||||
expect(recordings(@room.bbb_id, @room.owner.provider, search: "public")).to contain_exactly(
|
||||
expect(recordings(@room.bbb_id, search: "public")).to contain_exactly(
|
||||
{
|
||||
meetingID: @room.bbb_id,
|
||||
name: "test",
|
||||
@ -329,7 +331,7 @@ shared_examples_for "recorder" do
|
||||
end
|
||||
|
||||
it "should filter recordings on metadata name by default" do
|
||||
expect(recordings(@room.bbb_id, @room.owner.provider, search: "metadata")).to contain_exactly(
|
||||
expect(recordings(@room.bbb_id, search: "metadata")).to contain_exactly(
|
||||
meetingID: @room.bbb_id,
|
||||
name: "Exam",
|
||||
participants: "1",
|
||||
@ -385,7 +387,7 @@ shared_examples_for "recorder" do
|
||||
end
|
||||
|
||||
it "should sort recordings on name" do
|
||||
expect(recordings(@room.bbb_id, @room.owner.provider, column: "name", direction: "asc")).to eq(
|
||||
expect(recordings(@room.bbb_id, column: "name", direction: "asc")).to eq(
|
||||
[
|
||||
{
|
||||
meetingID: @room.bbb_id,
|
||||
@ -421,7 +423,7 @@ shared_examples_for "recorder" do
|
||||
end
|
||||
|
||||
it "should sort recordings on participants" do
|
||||
expect(recordings(@room.bbb_id, @room.owner.provider, column: "users", direction: "desc")).to eq(
|
||||
expect(recordings(@room.bbb_id, column: "users", direction: "desc")).to eq(
|
||||
[
|
||||
{
|
||||
meetingID: @room.bbb_id,
|
||||
@ -457,7 +459,7 @@ shared_examples_for "recorder" do
|
||||
end
|
||||
|
||||
it "should sort recordings on visibility" do
|
||||
expect(recordings(@room.bbb_id, @room.owner.provider, column: "visibility", direction: "desc")).to eq(
|
||||
expect(recordings(@room.bbb_id, column: "visibility", direction: "desc")).to eq(
|
||||
[
|
||||
{
|
||||
meetingID: @room.bbb_id,
|
||||
@ -493,7 +495,7 @@ shared_examples_for "recorder" do
|
||||
end
|
||||
|
||||
it "should sort recordings on length" do
|
||||
expect(recordings(@room.bbb_id, @room.owner.provider, column: "length", direction: "asc")).to eq(
|
||||
expect(recordings(@room.bbb_id, column: "length", direction: "asc")).to eq(
|
||||
[
|
||||
{
|
||||
meetingID: @room.bbb_id,
|
||||
@ -529,7 +531,7 @@ shared_examples_for "recorder" do
|
||||
end
|
||||
|
||||
it "should sort recordings on format" do
|
||||
expect(recordings(@room.bbb_id, @room.owner.provider, column: "formats", direction: "desc")).to eq(
|
||||
expect(recordings(@room.bbb_id, column: "formats", direction: "desc")).to eq(
|
||||
[
|
||||
{
|
||||
meetingID: @room.bbb_id,
|
||||
|
@ -37,7 +37,7 @@ describe AccountActivationsController, type: :controller do
|
||||
|
||||
get :show, params: { email: user.email }
|
||||
|
||||
expect(response).to render_template(:verify)
|
||||
expect(response).to render_template(:show)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -91,7 +91,7 @@ describe AdminsController, type: :controller do
|
||||
context "POST #invite" do
|
||||
before do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
|
||||
allow_any_instance_of(ApplicationController).to receive(:allow_greenlight_users?).and_return(true)
|
||||
allow_any_instance_of(ApplicationController).to receive(:allow_greenlight_accounts?).and_return(true)
|
||||
allow_any_instance_of(User).to receive(:greenlight_account?).and_return(true)
|
||||
end
|
||||
|
||||
@ -177,7 +177,7 @@ describe AdminsController, type: :controller do
|
||||
@request.session[:user_id] = @admin.id
|
||||
fake_image_url = "example.com"
|
||||
|
||||
post :branding, params: { url: fake_image_url }
|
||||
post :update_settings, params: { setting: "Branding Image", value: fake_image_url }
|
||||
|
||||
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Branding Image")
|
||||
|
||||
@ -194,7 +194,7 @@ describe AdminsController, type: :controller do
|
||||
@request.session[:user_id] = @admin.id
|
||||
primary_color = Faker::Color.hex_color
|
||||
|
||||
post :coloring, params: { color: primary_color }
|
||||
post :coloring, params: { value: primary_color }
|
||||
|
||||
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Primary Color")
|
||||
|
||||
@ -209,7 +209,7 @@ describe AdminsController, type: :controller do
|
||||
@request.session[:user_id] = @admin.id
|
||||
primary_color = Faker::Color.hex_color
|
||||
|
||||
post :coloring_lighten, params: { color: primary_color }
|
||||
post :update_settings, params: { setting: "Primary Color Lighten", value: primary_color }
|
||||
|
||||
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Primary Color Lighten")
|
||||
|
||||
@ -224,7 +224,7 @@ describe AdminsController, type: :controller do
|
||||
@request.session[:user_id] = @admin.id
|
||||
primary_color = Faker::Color.hex_color
|
||||
|
||||
post :coloring_darken, params: { color: primary_color }
|
||||
post :update_settings, params: { setting: "Primary Color Darken", value: primary_color }
|
||||
|
||||
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Primary Color Darken")
|
||||
|
||||
@ -243,7 +243,7 @@ describe AdminsController, type: :controller do
|
||||
|
||||
@request.session[:user_id] = @admin.id
|
||||
|
||||
post :registration_method, params: { method: "invite" }
|
||||
post :registration_method, params: { value: "invite" }
|
||||
|
||||
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Registration Method")
|
||||
|
||||
@ -259,7 +259,7 @@ describe AdminsController, type: :controller do
|
||||
|
||||
@request.session[:user_id] = @admin.id
|
||||
|
||||
post :registration_method, params: { method: "invite" }
|
||||
post :registration_method, params: { value: "invite" }
|
||||
|
||||
expect(flash[:alert]).to be_present
|
||||
expect(response).to redirect_to(admin_site_settings_path)
|
||||
@ -273,7 +273,7 @@ describe AdminsController, type: :controller do
|
||||
|
||||
@request.session[:user_id] = @admin.id
|
||||
|
||||
post :room_authentication, params: { value: "true" }
|
||||
post :update_settings, params: { setting: "Room Authentication", value: "true" }
|
||||
|
||||
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Room Authentication")
|
||||
|
||||
@ -289,7 +289,7 @@ describe AdminsController, type: :controller do
|
||||
|
||||
@request.session[:user_id] = @admin.id
|
||||
|
||||
post :room_limit, params: { limit: 5 }
|
||||
post :update_settings, params: { setting: "Room Limit", value: 5 }
|
||||
|
||||
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Room Limit")
|
||||
|
||||
@ -305,7 +305,7 @@ describe AdminsController, type: :controller do
|
||||
|
||||
@request.session[:user_id] = @admin.id
|
||||
|
||||
post :default_recording_visibility, params: { visibility: "public" }
|
||||
post :update_settings, params: { setting: "Default Recording Visibility", value: "public" }
|
||||
|
||||
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Default Recording Visibility")
|
||||
|
||||
@ -353,7 +353,7 @@ describe AdminsController, type: :controller do
|
||||
post :new_role, params: { role: { name: "admin" } }
|
||||
|
||||
expect(response).to redirect_to admin_roles_path
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.duplicate_name"))
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.invalid_create"))
|
||||
end
|
||||
|
||||
it "should fail with empty role name" do
|
||||
@ -362,7 +362,7 @@ describe AdminsController, type: :controller do
|
||||
post :new_role, params: { role: { name: " " } }
|
||||
|
||||
expect(response).to redirect_to admin_roles_path
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.empty_name"))
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.invalid_create"))
|
||||
end
|
||||
|
||||
it "should create new role and increase user role priority" do
|
||||
@ -412,7 +412,7 @@ describe AdminsController, type: :controller do
|
||||
|
||||
patch :change_role_order, params: { role: [new_role3.id, new_role2.id] }
|
||||
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.invalid_update"))
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.invalid_order"))
|
||||
expect(response).to redirect_to admin_roles_path
|
||||
end
|
||||
|
||||
@ -432,7 +432,7 @@ describe AdminsController, type: :controller do
|
||||
|
||||
patch :change_role_order, params: { role: [new_role3.id, new_role2.id] }
|
||||
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.invalid_update"))
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.invalid_order"))
|
||||
expect(response).to redirect_to admin_roles_path
|
||||
end
|
||||
|
||||
@ -489,7 +489,7 @@ describe AdminsController, type: :controller do
|
||||
|
||||
patch :update_role, params: { role_id: new_role.id, role: { name: "admin" } }
|
||||
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.duplicate_name"))
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.invalid_update"))
|
||||
expect(response).to redirect_to admin_roles_path(selected_role: new_role.id)
|
||||
end
|
||||
|
||||
|
@ -63,6 +63,64 @@ describe ApplicationController do
|
||||
end
|
||||
end
|
||||
|
||||
context "getters" do
|
||||
it "returns whether user signup is allowed" do
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
|
||||
expect(controller.allow_user_signup?).to eql(true)
|
||||
end
|
||||
|
||||
it "returns whether the default bbb endpoint is being used" do
|
||||
allow(Rails.configuration).to receive(:bigbluebutton_endpoint)
|
||||
.and_return("http://test-install.blindsidenetworks.com/bigbluebutton/api/")
|
||||
allow(Rails.configuration).to receive(:bigbluebutton_endpoint_default)
|
||||
.and_return("http://test-install.blindsidenetworks.com/bigbluebutton/api/")
|
||||
|
||||
expect(controller.bigbluebutton_endpoint_default?).to eql(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "allow_greenlight_accounts" do
|
||||
it "allows if user sign up is turned on" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(false)
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
|
||||
expect(controller.allow_greenlight_accounts?).to eql(true)
|
||||
end
|
||||
|
||||
it "doesn't allow if user sign up is turned off" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(false)
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(false)
|
||||
|
||||
expect(controller.allow_greenlight_accounts?).to eql(false)
|
||||
end
|
||||
|
||||
it "doesn't allow if user_domain is blank" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
|
||||
expect(controller.allow_greenlight_accounts?).to eql(false)
|
||||
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(controller).to receive(:retrieve_provider_info).and_return("provider" => "greenlight")
|
||||
controller.instance_variable_set(:@user_domain, "provider1")
|
||||
|
||||
expect(controller.allow_greenlight_accounts?).to eql(true)
|
||||
end
|
||||
|
||||
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(controller).to receive(:retrieve_provider_info).and_return("provider" => "google")
|
||||
controller.instance_variable_set(:@user_domain, "provider1")
|
||||
|
||||
expect(controller.allow_greenlight_accounts?).to eql(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "errors" do
|
||||
it "renders a BigBlueButton error if a BigBlueButtonException occurrs" do
|
||||
routes.draw { get "error" => "anonymous#error" }
|
||||
@ -74,7 +132,7 @@ describe ApplicationController do
|
||||
it "renders a 404 error if user is not found" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
|
||||
allow(Rails.env).to receive(:test?).and_return(false)
|
||||
allow_any_instance_of(SessionsHelper).to receive(:parse_user_domain).and_return("fake_provider")
|
||||
allow_any_instance_of(ApplicationController).to receive(:parse_user_domain).and_return("fake_provider")
|
||||
allow_any_instance_of(BbbApi).to receive(:retrieve_provider_info).and_raise("No user with that id exists")
|
||||
|
||||
routes.draw { get "user_not_found" => "anonymous#user_not_found" }
|
||||
@ -86,7 +144,7 @@ describe ApplicationController do
|
||||
it "renders a 404 error if user is not given" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
|
||||
allow(Rails.env).to receive(:test?).and_return(false)
|
||||
allow_any_instance_of(SessionsHelper).to receive(:parse_user_domain).and_return("")
|
||||
allow_any_instance_of(ApplicationController).to receive(:parse_user_domain).and_return("")
|
||||
allow_any_instance_of(BbbApi).to receive(:retrieve_provider_info).and_raise("Provider not included.")
|
||||
|
||||
routes.draw { get "user_not_found" => "anonymous#user_not_found" }
|
||||
@ -98,7 +156,7 @@ describe ApplicationController do
|
||||
it "renders a 500 error if any other error related to bbb api" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
|
||||
allow(Rails.env).to receive(:test?).and_return(false)
|
||||
allow_any_instance_of(SessionsHelper).to receive(:parse_user_domain).and_return("")
|
||||
allow_any_instance_of(ApplicationController).to receive(:parse_user_domain).and_return("")
|
||||
allow_any_instance_of(BbbApi).to receive(:retrieve_provider_info).and_raise("Other error")
|
||||
|
||||
routes.draw { get "user_not_found" => "anonymous#user_not_found" }
|
||||
|
@ -73,7 +73,9 @@ describe PasswordResetsController, type: :controller do
|
||||
end
|
||||
|
||||
describe "PATCH #update" do
|
||||
before { allow(Rails.configuration).to receive(:enable_email_verification).and_return(true) }
|
||||
before do
|
||||
allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
|
||||
end
|
||||
|
||||
context "valid user" do
|
||||
it "reloads page with notice if password is empty" do
|
||||
@ -120,7 +122,7 @@ describe PasswordResetsController, type: :controller do
|
||||
|
||||
allow(controller).to receive(:valid_user).and_return(nil)
|
||||
allow(controller).to receive(:check_expiration).and_return(nil)
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
controller.instance_variable_set(:@user, user)
|
||||
|
||||
params = {
|
||||
id: token,
|
||||
|
@ -27,10 +27,10 @@ describe RecordingsController, type: :controller do
|
||||
|
||||
context "POST #update_recording" do
|
||||
it "updates the recordings details" do
|
||||
allow_any_instance_of(Room).to receive(:update_recording).and_return(updated: true)
|
||||
allow_any_instance_of(BbbServer).to receive(:update_recording).and_return(updated: true)
|
||||
@request.session[:user_id] = @user.uid
|
||||
|
||||
post :update_recording, params: { meetingID: @room.bbb_id, record_id: Faker::IDNumber.valid, state: "public" }
|
||||
post :update, params: { meetingID: @room.bbb_id, record_id: Faker::IDNumber.valid, state: "public" }
|
||||
|
||||
expect(response).to have_http_status(302)
|
||||
end
|
||||
@ -38,7 +38,7 @@ describe RecordingsController, type: :controller do
|
||||
it "redirects to root if not the room owner" do
|
||||
@request.session[:user_id] = @secondary_user.uid
|
||||
|
||||
post :update_recording, params: { meetingID: @room.bbb_id, record_id: Faker::IDNumber.valid, state: "public" }
|
||||
post :update, params: { meetingID: @room.bbb_id, record_id: Faker::IDNumber.valid, state: "public" }
|
||||
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
@ -46,10 +46,10 @@ describe RecordingsController, type: :controller do
|
||||
|
||||
context "DELETE #delete_recording" do
|
||||
it "deletes the recording" do
|
||||
allow_any_instance_of(Room).to receive(:delete_recording).and_return(true)
|
||||
allow_any_instance_of(BbbServer).to receive(:delete_recording).and_return(true)
|
||||
@request.session[:user_id] = @user.uid
|
||||
|
||||
post :delete_recording, params: { meetingID: @room.bbb_id, record_id: Faker::IDNumber.valid, state: "public" }
|
||||
post :delete, params: { meetingID: @room.bbb_id, record_id: Faker::IDNumber.valid, state: "public" }
|
||||
|
||||
expect(response).to have_http_status(302)
|
||||
end
|
||||
@ -57,7 +57,7 @@ describe RecordingsController, type: :controller do
|
||||
it "redirects to root if not the room owner" do
|
||||
@request.session[:user_id] = @secondary_user.uid
|
||||
|
||||
post :delete_recording, params: { meetingID: @room.bbb_id, record_id: Faker::IDNumber.valid, state: "public" }
|
||||
post :delete, params: { meetingID: @room.bbb_id, record_id: Faker::IDNumber.valid, state: "public" }
|
||||
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
|
@ -28,8 +28,11 @@ def random_valid_room_params
|
||||
end
|
||||
|
||||
describe RoomsController, type: :controller do
|
||||
it_behaves_like "recorder"
|
||||
include Recorder
|
||||
include BbbServer
|
||||
|
||||
let(:bbb_server) { BigBlueButton::BigBlueButtonApi.new("http://bbb.example.com/bigbluebutton/api", "secret", "0.8") }
|
||||
|
||||
describe "GET #show" do
|
||||
before do
|
||||
@user = create(:user)
|
||||
@ -41,8 +44,7 @@ describe RoomsController, type: :controller do
|
||||
|
||||
get :show, params: { room_uid: @owner.main_room }
|
||||
|
||||
expect(assigns(:recordings)).to eql(recordings(@owner.main_room.bbb_id, @owner.provider))
|
||||
expect(assigns(:is_running)).to eql(@owner.main_room.running?)
|
||||
expect(assigns(:recordings)).to eql(recordings(@owner.main_room.bbb_id))
|
||||
end
|
||||
|
||||
it "should be able to search recordings if user is owner" do
|
||||
@ -199,11 +201,6 @@ describe RoomsController, type: :controller do
|
||||
@user = create(:user)
|
||||
@owner = create(:user)
|
||||
@room = @owner.main_room
|
||||
|
||||
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_meeting_info).and_return(
|
||||
moderatorPW: "modpass",
|
||||
attendeePW: "attpass",
|
||||
)
|
||||
end
|
||||
|
||||
it "should use account name if user is logged in and meeting running" do
|
||||
@ -212,7 +209,7 @@ describe RoomsController, type: :controller do
|
||||
@request.session[:user_id] = @user.id
|
||||
post :join, params: { room_uid: @room, join_name: @user.name }
|
||||
|
||||
expect(response).to redirect_to(@owner.main_room.join_path(@user.name, {}, @user.uid))
|
||||
expect(response).to redirect_to(join_path(@owner.main_room, @user.name, {}, @user.uid))
|
||||
end
|
||||
|
||||
it "should use join name if user is not logged in and meeting running" do
|
||||
@ -220,7 +217,7 @@ describe RoomsController, type: :controller do
|
||||
|
||||
post :join, params: { room_uid: @room, join_name: "Join Name" }
|
||||
|
||||
expect(response).to redirect_to(@owner.main_room.join_path("Join Name", {}))
|
||||
expect(response).to redirect_to(join_path(@owner.main_room, "Join Name", {}))
|
||||
end
|
||||
|
||||
it "should render wait if meeting isn't running" do
|
||||
@ -243,7 +240,7 @@ describe RoomsController, type: :controller do
|
||||
@request.session[:user_id] = @user.id
|
||||
post :join, params: { room_uid: room, join_name: @user.name }
|
||||
|
||||
expect(response).to redirect_to(room.join_path(@user.name, { user_is_moderator: false }, @user.uid))
|
||||
expect(response).to redirect_to(join_path(room, @user.name, { user_is_moderator: false }, @user.uid))
|
||||
end
|
||||
|
||||
it "should join the room as moderator if room has the all_join_moderator setting" do
|
||||
@ -257,7 +254,7 @@ describe RoomsController, type: :controller do
|
||||
@request.session[:user_id] = @user.id
|
||||
post :join, params: { room_uid: room, join_name: @user.name }
|
||||
|
||||
expect(response).to redirect_to(room.join_path(@user.name, { user_is_moderator: true }, @user.uid))
|
||||
expect(response).to redirect_to(join_path(room, @user.name, { user_is_moderator: true }, @user.uid))
|
||||
end
|
||||
|
||||
it "should render wait if the correct access code is supplied" do
|
||||
@ -292,7 +289,7 @@ describe RoomsController, type: :controller do
|
||||
@request.session[:user_id] = @owner.id
|
||||
post :join, params: { room_uid: @room, join_name: @owner.name }
|
||||
|
||||
expect(response).to redirect_to(@owner.main_room.join_path(@owner.name, { user_is_moderator: true }, @owner.uid))
|
||||
expect(response).to redirect_to(join_path(@owner.main_room, @owner.name, { user_is_moderator: true }, @owner.uid))
|
||||
end
|
||||
|
||||
it "redirects to root if owner of room is not verified" do
|
||||
@ -362,7 +359,7 @@ describe RoomsController, type: :controller do
|
||||
@request.session[:user_id] = @user.id
|
||||
post :start, params: { room_uid: @user.main_room }
|
||||
|
||||
expect(response).to redirect_to(@user.main_room.join_path(@user.name, { user_is_moderator: true }, @user.uid))
|
||||
expect(response).to redirect_to(join_path(@user.main_room, @user.name, { user_is_moderator: true }, @user.uid))
|
||||
end
|
||||
|
||||
it "should bring to room if not owner" do
|
||||
|
@ -373,7 +373,7 @@ describe UsersController, type: :controller do
|
||||
|
||||
user.reload
|
||||
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.invalid_removal"))
|
||||
expect(flash[:alert]).to eq(I18n.t("administrator.roles.invalid_assignment"))
|
||||
expect(response).to render_template(:edit)
|
||||
end
|
||||
|
||||
@ -439,7 +439,6 @@ describe UsersController, type: :controller do
|
||||
it "allows admins to delete users" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
|
||||
allow_any_instance_of(User).to receive(:greenlight_account?).and_return(true)
|
||||
allow_any_instance_of(Room).to receive(:delete_all_recordings).and_return('')
|
||||
allow_any_instance_of(ApplicationController).to receive(:set_user_domain).and_return("provider1")
|
||||
controller.instance_variable_set(:@user_domain, "provider1")
|
||||
|
||||
|
@ -1,44 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
|
||||
#
|
||||
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free Software
|
||||
# Foundation; either version 3.0 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License along
|
||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
describe AdminsHelper do
|
||||
describe "edit_disabled" do
|
||||
it "should disable inputs for roles with a higher priority" do
|
||||
user = create(:user)
|
||||
admin_role = Role.find_by(name: "admin", provider: "greenlight")
|
||||
helper.instance_variable_set(:@selected_role, admin_role)
|
||||
|
||||
allow_any_instance_of(SessionsHelper).to receive(:current_user).and_return(user)
|
||||
|
||||
expect(helper.edit_disabled).to eq(true)
|
||||
end
|
||||
|
||||
it "should enable inputs for roles with a lower priority" do
|
||||
user = create(:user)
|
||||
user.roles << Role.find_by(name: "admin", provider: "greenlight")
|
||||
user_role = Role.find_by(name: "user", provider: "greenlight")
|
||||
helper.instance_variable_set(:@selected_role, user_role)
|
||||
|
||||
allow_any_instance_of(SessionsHelper).to receive(:current_user).and_return(user)
|
||||
|
||||
expect(helper.edit_disabled).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
@ -20,21 +20,6 @@ require "rails_helper"
|
||||
|
||||
describe ApplicationHelper do
|
||||
describe "#getter functions" do
|
||||
it "returns whether user signup is allowed" do
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
|
||||
expect(helper.allow_user_signup?).to eql(true)
|
||||
end
|
||||
|
||||
it "returns whether the default bbb endpoint is being used" do
|
||||
allow(Rails.configuration).to receive(:bigbluebutton_endpoint)
|
||||
.and_return("http://test-install.blindsidenetworks.com/bigbluebutton/api/")
|
||||
allow(Rails.configuration).to receive(:bigbluebutton_endpoint_default)
|
||||
.and_return("http://test-install.blindsidenetworks.com/bigbluebutton/api/")
|
||||
|
||||
expect(helper.bigbluebutton_endpoint_default?).to eql(true)
|
||||
end
|
||||
|
||||
it "returns the correct omniauth login url" do
|
||||
allow(Rails.configuration).to receive(:relative_url_root).and_return("/b")
|
||||
provider = Faker::Company.name
|
||||
@ -43,51 +28,8 @@ describe ApplicationHelper do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#allow_greenlight_accounts" do
|
||||
it "allows if user sign up is turned on" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(false)
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
|
||||
expect(helper.allow_greenlight_accounts?).to eql(true)
|
||||
end
|
||||
|
||||
it "doesn't allow if user sign up is turned off" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(false)
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(false)
|
||||
|
||||
expect(helper.allow_greenlight_accounts?).to eql(false)
|
||||
end
|
||||
|
||||
it "doesn't allow if user_domain is blank" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
|
||||
expect(helper.allow_greenlight_accounts?).to eql(false)
|
||||
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(:retrieve_provider_info).and_return("provider" => "greenlight")
|
||||
|
||||
@user_domain = "provider1"
|
||||
|
||||
expect(helper.allow_greenlight_accounts?).to eql(true)
|
||||
end
|
||||
|
||||
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(:retrieve_provider_info).and_return("provider" => "google")
|
||||
|
||||
@user_domain = "provider1"
|
||||
|
||||
expect(helper.allow_greenlight_accounts?).to eql(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe "role_clour" do
|
||||
it "should use default if the user doens't have a role" do
|
||||
describe "role_colur" do
|
||||
it "should use default if the user doesn't have a role" do
|
||||
expect(helper.role_colour(Role.create(name: "test"))).to eq(Rails.configuration.primary_color_default)
|
||||
end
|
||||
|
||||
|
@ -1,44 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
|
||||
#
|
||||
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free Software
|
||||
# Foundation; either version 3.0 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License along
|
||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
describe UsersHelper do
|
||||
describe "disabled roles" do
|
||||
it "should return roles with a less than or equal to priority for non admins" do
|
||||
user = create(:user)
|
||||
allow_any_instance_of(SessionsHelper).to receive(:current_user).and_return(user)
|
||||
|
||||
disabled_roles = helper.disabled_roles(user)
|
||||
|
||||
expect(disabled_roles.count).to eq(1)
|
||||
end
|
||||
|
||||
it "should return roles with a lesser priority for admins" do
|
||||
admin = create(:user)
|
||||
admin.add_role :admin
|
||||
user = create(:user)
|
||||
|
||||
allow_any_instance_of(SessionsHelper).to receive(:current_user).and_return(admin)
|
||||
|
||||
disabled_roles = helper.disabled_roles(user)
|
||||
|
||||
expect(disabled_roles.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
@ -62,52 +62,6 @@ describe Room, type: :model do
|
||||
end
|
||||
end
|
||||
|
||||
context "#running?" do
|
||||
it "should return false when not running" do
|
||||
expect(@room.running?).to be false
|
||||
end
|
||||
|
||||
it "should return true when running" do
|
||||
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(true)
|
||||
expect(@room.running?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context "#start_session" do
|
||||
it "should update latest session info" do
|
||||
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:create_meeting).and_return(
|
||||
messageKey: ""
|
||||
)
|
||||
|
||||
expect do
|
||||
@room.start_session
|
||||
end.to change { @room.sessions }.by(1)
|
||||
|
||||
expect(@room.last_session).not_to be nil
|
||||
end
|
||||
end
|
||||
|
||||
context "#join_path" do
|
||||
it "should return correct join URL for user" do
|
||||
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_meeting_info).and_return(
|
||||
attendeePW: "testpass"
|
||||
)
|
||||
|
||||
endpoint = Rails.configuration.bigbluebutton_endpoint
|
||||
secret = Rails.configuration.bigbluebutton_secret
|
||||
fullname = "fullName=Example"
|
||||
join_via_html5 = "&join_via_html5=true"
|
||||
meeting_id = "&meetingID=#{@room.bbb_id}"
|
||||
password = "&password=testpass"
|
||||
|
||||
query = fullname + join_via_html5 + meeting_id + password
|
||||
checksum_string = "join#{query + secret}"
|
||||
|
||||
checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack1("H*")
|
||||
expect(@room.join_path("Example")).to eql("#{endpoint}join?#{query}&checksum=#{checksum}")
|
||||
end
|
||||
end
|
||||
|
||||
context "#notify_waiting" do
|
||||
it "should broadcast to waiting channel with started action" do
|
||||
expect do
|
||||
@ -115,32 +69,4 @@ describe Room, type: :model do
|
||||
end.to have_broadcasted_to("#{@room.uid}_waiting_channel").with(a_hash_including(action: "started"))
|
||||
end
|
||||
end
|
||||
|
||||
context "#participants" do
|
||||
it "should link participants to accounts" do
|
||||
user1 = create(:user)
|
||||
user2 = create(:user)
|
||||
|
||||
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_meeting_info).and_return(
|
||||
attendees: [
|
||||
{ userID: user1.uid, fullName: user1.name },
|
||||
{ userID: "non-matching-uid", fullName: "Guest User" },
|
||||
{ userID: user2.uid, fullName: user2.name },
|
||||
],
|
||||
)
|
||||
|
||||
expect(@room.participants).to contain_exactly(user1, nil, user2)
|
||||
end
|
||||
end
|
||||
|
||||
context "#recordings" do
|
||||
it "deletes the recording" do
|
||||
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:delete_recordings).and_return(
|
||||
returncode: true, deleted: true
|
||||
)
|
||||
|
||||
expect(@room.delete_recording(Faker::IDNumber.valid))
|
||||
.to contain_exactly([:returncode, true], [:deleted, true])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user