Skip to content
Snippets Groups Projects
Unverified Commit f6e1388e authored by Samuel Couillard's avatar Samuel Couillard Committed by GitHub
Browse files

Add Provider (#4907)


* Add Provider

* Rename Providers to Tenants

---------

Co-authored-by: default avatarAhmad Farhat <ahmad.af.farhat@gmail.com>
parent 553676e2
No related branches found
No related tags found
No related merge requests found
......@@ -19,12 +19,12 @@
module Api
module V1
module Admin
class AdminsController < ApiController
class TenantsController < ApiController
before_action do
# TODO: - ahmad: Add role check
end
def provider
def create
provider = params[:provider]
create_roles(provider:)
create_site_settings(provider:)
......
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
#
# Copyright (c) 2022 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.
#
# Greenlight 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 Greenlight; if not, see <http://www.gnu.org/licenses/>.
# frozen_string_literal: true
class Tenant < ApplicationRecord
validates :name, presence: true, uniqueness: true
validates :client_secret, presence: true
end
......@@ -107,8 +107,7 @@ Rails.application.routes.draw do
post '/', to: 'role_permissions#update'
end
end
post '/provider', to: 'admins#provider'
resources :tenants, only: :create
end
namespace :migrations do
......
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
#
# Copyright (c) 2022 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.
#
# Greenlight 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 Greenlight; if not, see <http://www.gnu.org/licenses/>.
# frozen_string_literal: true
class CreateTenants < ActiveRecord::Migration[7.0]
def change
create_table :tenants do |t|
t.string :name, null: false, index: { unique: true }
t.string :client_secret, null: false
t.timestamps
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_02_27_213252) do
ActiveRecord::Schema[7.0].define(version: 2023_03_01_203522) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
......@@ -173,6 +173,14 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_27_213252) do
t.index ["setting_id"], name: "index_site_settings_on_setting_id"
end
create_table "tenants", force: :cascade do |t|
t.string "name", null: false
t.string "client_secret", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["name"], name: "index_tenants_on_name", unique: true
end
create_table "users", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "name", null: false
t.string "email", null: false
......
......@@ -18,7 +18,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Admin::AdminsController, type: :controller do
RSpec.describe Api::V1::Admin::TenantsController, type: :controller do
let(:user) { create(:user) }
let(:provider) { 'bigbluebutton' }
......@@ -28,9 +28,9 @@ RSpec.describe Api::V1::Admin::AdminsController, type: :controller do
create_settings_permissions_meetingoptions
end
describe 'provider' do
describe 'creates' do
it 'creates the default roles for the provider' do
post :provider, params: { provider: }
post :create, params: { provider: }
expect(Role.exists?(name: 'Administrator', provider:)).to be true
expect(Role.exists?(name: 'User', provider:)).to be true
......@@ -38,7 +38,7 @@ RSpec.describe Api::V1::Admin::AdminsController, type: :controller do
end
it 'creates the default SiteSettings for the provider' do
post :provider, params: { provider: }
post :create, params: { provider: }
settings = Setting.all
settings.each do |setting|
......@@ -47,7 +47,7 @@ RSpec.describe Api::V1::Admin::AdminsController, type: :controller do
end
it 'creates the default RoomsConfiguration for the provider' do
post :provider, params: { provider: }
post :create, params: { provider: }
options = MeetingOption.all
options.each do |option|
......@@ -56,7 +56,7 @@ RSpec.describe Api::V1::Admin::AdminsController, type: :controller do
end
it 'creates the default RolePermissions for the provider' do
post :provider, params: { provider: }
post :create, params: { provider: }
roles = Role.where(provider:)
permissions = Permission.all
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment