-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* registration and rake tests * rubocop changes Co-authored-by: Jesus Federico <jesus@123it.ca>
- Loading branch information
1 parent
cd0c1c8
commit 5ce3f0a
Showing
8 changed files
with
255 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,7 @@ process.yml | |
localhost.crt | ||
localhost.key | ||
|
||
/public/assets | ||
/public/assets | ||
|
||
# ignore rspec coverage | ||
coverage/* |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# 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' | ||
|
||
RSpec.describe(RegistrationController, type: :controller) do | ||
before do | ||
ENV['DEVELOPER_MODE_ENABLED'] = 'true' | ||
tenant = RailsLti2Provider::Tenant.create!(uid: '') | ||
reg = { | ||
issuer: 'issuer', | ||
client_id: 'client_id', | ||
key_set_url: 'key_set_url', | ||
auth_token_url: 'auth_token_url', | ||
auth_login_url: 'auth_login_url', | ||
} | ||
@app = RailsLti2Provider::Tool.create!( | ||
uuid: 'issuer', | ||
shared_secret: 'client_id', | ||
tool_settings: reg.to_json, | ||
lti_version: '1.3.0', | ||
tenant: tenant | ||
) | ||
end | ||
|
||
describe 'GET registration/new' do | ||
it 'gives a successful response' do | ||
get :new | ||
expect(response).to(be_successful) | ||
end | ||
end | ||
|
||
describe 'POST registration/submit' do | ||
it 'adds another tool' do | ||
post :submit, params: { | ||
iss: 'test.com', | ||
client_id: 'test_secret', | ||
key_set_url: 'key.test.com', | ||
auth_token_url: 'auth-token.test.com', | ||
auth_login_url: 'auth-login.test.com', | ||
} | ||
expect(response).to(redirect_to(:registration_list)) | ||
end | ||
end | ||
|
||
describe 'GET registration/list' do | ||
it 'gives a successful response' do | ||
get :list | ||
expect(response).to(be_successful) | ||
end | ||
|
||
it 'gives a proper list of all items' do | ||
get :list | ||
current_tools = RailsLti2Provider::Tool.where(lti_version: '1.3.0').pluck(:tool_settings) | ||
current_tools.map! do |reg| | ||
JSON.parse(reg) | ||
end | ||
expect(assigns(:registrations)).to(eq(current_tools)) | ||
end | ||
end | ||
|
||
describe 'GET registration/edit' do | ||
it 'gives a successful response' do | ||
get :edit, params: { client_id: @app.shared_secret, reg_id: @app.uuid } | ||
expect(response).to(be_successful) | ||
end | ||
it 'edits an existing tool' do | ||
post :submit, params: { | ||
iss: 'test.com', | ||
client_id: 'test_secret', | ||
key_set_url: 'edit-key.test.com', | ||
auth_token_url: 'edit-auth-token.test.com', | ||
auth_login_url: 'edit-auth-login.test.com', | ||
} | ||
expect(response).to(redirect_to(:registration_list)) | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# 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 'rake' | ||
|
||
RSpec.describe('rake tasks involving apps') do | ||
before do | ||
Rake.application.rake_require('tasks/db_apps') | ||
Rake::Task.define_task(:environment) | ||
|
||
@app = Doorkeeper::Application.create!(name: 'test-app', uid: 'key', secret: 'secret', \ | ||
redirect_uri: 'https://test.example.com', scopes: 'api') | ||
end | ||
describe 'calling db:app' do | ||
it 'displays the existing app' do | ||
appinfo ||= @app.attributes.select { |key, _value| %w[name uid secret redirect_uri].include?(key) } | ||
expect do | ||
Rake.application.invoke_task('db:apps:showall') | ||
end.to(output(appinfo.to_json + "\n").to_stdout) | ||
end | ||
it 'and adding an app' do | ||
Rake.application.invoke_task('db:apps:add[test-add-app,https://test.example.com,key-add,secret-add]') | ||
end | ||
it 'and updating an app' do | ||
Rake.application.invoke_task('db:apps:update[test-app,https://test.example.com,key-updated,secret-updated]') | ||
end | ||
it 'and deleting an app' do | ||
Rake.application.invoke_task('db:apps:delete[test-app]') | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# 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 'rake' | ||
|
||
RSpec.describe('rake tasks involving keys') do | ||
before do | ||
Rake.application.rake_require('tasks/db_keys') | ||
Rake::Task.define_task(:environment) | ||
|
||
@tenant = RailsLti2Provider::Tenant.create!(uid: 'tenant') | ||
@other_tenant = RailsLti2Provider::Tenant.create!(uid: 'other-tenant') | ||
@single_tenant_key = RailsLti2Provider::Tool.create!(uuid: 'single-key', shared_secret: 'secret', lti_version: 'LTI-1p0', | ||
tool_settings: 'none', tenant: RailsLti2Provider::Tenant.create!(uid: '')) | ||
@multi_tenant_key = RailsLti2Provider::Tool.create!(uuid: 'multi-key', shared_secret: 'secret', lti_version: 'LTI-1p0', | ||
tool_settings: 'none', tenant: @tenant) | ||
end | ||
describe 'calling db:keys' do | ||
it 'displays the existing keys' do | ||
expected_keys_text = "'single-key'='secret'\n'multi-key'='secret' for tenant 'tenant'\n" | ||
expect do | ||
Rake.application.invoke_task('db:keys:showall') | ||
end.to(output(expected_keys_text).to_stdout) | ||
end | ||
it 'and adding an key in single tenant' do | ||
Rake.application.invoke_task('db:keys:add[single-test-key, secret]') | ||
end | ||
it 'and adding an key in multi tenant' do | ||
Rake.application.invoke_task('db:keys:add[single-test-key, secret, tenant]') | ||
end | ||
it 'and updating an key in single tenant' do | ||
Rake.application.invoke_task('db:keys:update[single-key,secret-updated]') | ||
end | ||
it 'and updating an key in multi tenant' do | ||
Rake.application.invoke_task('db:keys:update[multi-key,secret-updated, other-tenant]') | ||
end | ||
it 'and deleting an key' do | ||
Rake.application.invoke_task('db:keys:delete[single-key]') | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# 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 'rake' | ||
|
||
RSpec.describe('rake tasks involving tenants') do | ||
before do | ||
Rake.application.rake_require('tasks/db_tenants') | ||
Rake::Task.define_task(:environment) | ||
@tenant = RailsLti2Provider::Tenant.create!(uid: 'tenant') | ||
end | ||
|
||
describe 'calling db:tenants' do | ||
it 'and displays the tenant' do | ||
tenant_text = /Tenant with uid 'tenant'/ | ||
expect do | ||
Rake.application.invoke_task('db:tenants:showall') | ||
end.to(output(tenant_text).to_stdout) | ||
end | ||
it 'and adds a tenant' do | ||
Rake.application.invoke_task('db:tenants:add[test-tenant]') | ||
end | ||
it 'and deletes a tenant' do | ||
Rake.application.invoke_task('db:tenants:delete[tenant]') | ||
end | ||
it 'and deletes all tenants' do | ||
Rake.application.invoke_task('db:tenants:deleteall') | ||
end | ||
end | ||
end |