feat: Unify user and super admin credentials (#3830)

Fixes: #3061, #3489
This commit is contained in:
Sojan Jose
2022-01-25 16:58:49 -08:00
committed by GitHub
parent 23965fbaa3
commit 34e8ad9dc5
34 changed files with 303 additions and 233 deletions

View File

@@ -14,7 +14,7 @@ RSpec.describe 'Super Admin access tokens API', type: :request do
context 'when it is an authenticated super admin' do
it 'shows the list of access tokens' do
sign_in super_admin
sign_in(super_admin, scope: :super_admin)
get '/super_admin/access_tokens'
expect(response).to have_http_status(:success)
expect(response.body).to include(platform_app.access_token.token)

View File

@@ -13,7 +13,7 @@ RSpec.describe 'Super Admin Account Users API', type: :request do
context 'when it is an authenticated super admin' do
it 'shows the account user create page' do
sign_in super_admin
sign_in(super_admin, scope: :super_admin)
get '/super_admin/account_users/new'
expect(response).to have_http_status(:success)
end

View File

@@ -15,7 +15,7 @@ RSpec.describe 'Super Admin accounts API', type: :request do
let!(:account) { create(:account) }
it 'shows the list of accounts' do
sign_in super_admin
sign_in(super_admin, scope: :super_admin)
get '/super_admin/accounts'
expect(response).to have_http_status(:success)
expect(response.body).to include('New account')

View File

@@ -15,7 +15,7 @@ RSpec.describe 'Super Admin agent-bots API', type: :request do
let!(:agent_bot) { create(:agent_bot) }
it 'shows the list of users' do
sign_in super_admin
sign_in(super_admin, scope: :super_admin)
get '/super_admin/agent_bots'
expect(response).to have_http_status(:success)
expect(response.body).to include(agent_bot.name)

View File

@@ -15,7 +15,7 @@ RSpec.describe 'Super Admin Application Config API', type: :request do
let!(:config) { create(:installation_config, { name: 'FB_APP_ID', value: 'TESTVALUE' }) }
it 'shows the app_config page' do
sign_in super_admin
sign_in(super_admin, scope: :super_admin)
get '/super_admin/app_config'
expect(response).to have_http_status(:success)
expect(response.body).to include(config.name)
@@ -33,7 +33,7 @@ RSpec.describe 'Super Admin Application Config API', type: :request do
context 'when it is an aunthenticated super admin' do
it 'shows the app_config page' do
sign_in super_admin
sign_in(super_admin, scope: :super_admin)
post '/super_admin/app_config', params: { app_config: { TESTKEY: 'TESTVALUE' } }
expect(response.status).to eq(302)

View File

@@ -19,20 +19,20 @@ RSpec.describe 'Super Admin Installation Config API', type: :request do
end
it 'shows the installation_configs create page' do
sign_in super_admin
sign_in(super_admin, scope: :super_admin)
get '/super_admin/installation_configs/new'
expect(response).to have_http_status(:success)
end
it 'shows the installation_configs edit page' do
sign_in super_admin
sign_in(super_admin, scope: :super_admin)
editable_config = InstallationConfig.editable.first
get "/super_admin/installation_configs/#{editable_config.id}/edit"
expect(response).to have_http_status(:success)
end
it 'shows the installation_configs list page' do
sign_in super_admin
sign_in(super_admin, scope: :super_admin)
get '/super_admin/installation_configs'
expect(response).to have_http_status(:success)
expect(response.body).to include(config.name)

View File

@@ -15,7 +15,7 @@ RSpec.describe 'Super Admin platform app API', type: :request do
let!(:platform_app) { create(:platform_app) }
it 'shows the list of users' do
sign_in super_admin
sign_in(super_admin, scope: :super_admin)
get '/super_admin/platform_apps'
expect(response).to have_http_status(:success)
expect(response.body).to include(platform_app.name)

View File

@@ -1,24 +0,0 @@
require 'rails_helper'
RSpec.describe 'Super Admin super admins API', type: :request do
let(:super_admin) { create(:super_admin) }
describe 'GET /super_admin/users' do
context 'when it is an unauthenticated super admin' do
it 'returns unauthorized' do
get '/super_admin/super_admins'
expect(response).to have_http_status(:redirect)
end
end
context 'when it is an authenticated super admin' do
it 'shows the list of super admins' do
sign_in super_admin
get '/super_admin/super_admins'
expect(response).to have_http_status(:success)
expect(response.body).to include('New super admin')
expect(response.body).to include(super_admin.email)
end
end
end
end

View File

@@ -15,7 +15,7 @@ RSpec.describe 'Super Admin Users API', type: :request do
let!(:user) { create(:user) }
it 'shows the list of users' do
sign_in super_admin
sign_in(super_admin, scope: :super_admin)
get '/super_admin/users'
expect(response).to have_http_status(:success)
expect(response.body).to include('New user')

View File

@@ -1,46 +0,0 @@
require 'rails_helper'
RSpec.describe 'Super Admin', type: :request do
let(:super_admin) { create(:super_admin) }
describe 'request to /super_admin' do
context 'when the super admin is unauthenticated' do
it 'redirects to signin page' do
get '/super_admin/'
expect(response).to have_http_status(:redirect)
expect(response.body).to include('sign_in')
end
it 'signs super admin in and out' do
sign_in super_admin
get '/super_admin'
expect(response).to have_http_status(:success)
expect(response.body).to include('Dashboard')
sign_out super_admin
get '/super_admin'
expect(response).to have_http_status(:redirect)
end
end
end
describe 'request to /super_admin/sidekiq' do
context 'when the super admin is unauthenticated' do
it 'redirects to signin page' do
get '/monitoring/sidekiq'
expect(response).to have_http_status(:not_found)
expect(response.body).to include('sign_in')
end
it 'signs super admin in and out' do
sign_in super_admin
get '/monitoring/sidekiq'
expect(response).to have_http_status(:success)
sign_out super_admin
get '/monitoring/sidekiq'
expect(response).to have_http_status(:not_found)
end
end
end
end