2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-16 06:45:52 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
RSpec.describe 'admin manage applications' do
|
2016-12-16 06:45:52 -05:00
|
|
|
before do
|
2020-11-23 10:09:37 -05:00
|
|
|
admin = create(:admin)
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2016-12-16 06:45:52 -05:00
|
|
|
end
|
|
|
|
|
2020-09-02 11:10:54 -04:00
|
|
|
it 'creates new oauth application' do
|
2016-12-16 06:45:52 -05:00
|
|
|
visit admin_applications_path
|
|
|
|
|
2017-04-04 18:36:19 -04:00
|
|
|
click_on 'New application'
|
2016-12-16 06:45:52 -05:00
|
|
|
expect(page).to have_content('New application')
|
|
|
|
|
|
|
|
fill_in :doorkeeper_application_name, with: 'test'
|
|
|
|
fill_in :doorkeeper_application_redirect_uri, with: 'https://test.com'
|
2017-07-24 16:45:12 -04:00
|
|
|
check :doorkeeper_application_trusted
|
2020-09-02 11:10:54 -04:00
|
|
|
check :doorkeeper_application_scopes_read_user
|
2016-12-16 06:45:52 -05:00
|
|
|
click_on 'Submit'
|
|
|
|
expect(page).to have_content('Application: test')
|
2018-10-03 04:31:03 -04:00
|
|
|
expect(page).to have_content('Application ID')
|
2016-12-16 06:45:52 -05:00
|
|
|
expect(page).to have_content('Secret')
|
2017-07-24 16:45:12 -04:00
|
|
|
expect(page).to have_content('Trusted Y')
|
2020-01-22 13:08:47 -05:00
|
|
|
expect(page).to have_content('Confidential Y')
|
2016-12-16 06:45:52 -05:00
|
|
|
|
|
|
|
click_on 'Edit'
|
|
|
|
expect(page).to have_content('Edit application')
|
|
|
|
|
|
|
|
fill_in :doorkeeper_application_name, with: 'test_changed'
|
2017-07-24 16:45:12 -04:00
|
|
|
uncheck :doorkeeper_application_trusted
|
2020-01-22 13:08:47 -05:00
|
|
|
uncheck :doorkeeper_application_confidential
|
2017-07-24 16:45:12 -04:00
|
|
|
|
2016-12-16 06:45:52 -05:00
|
|
|
click_on 'Submit'
|
|
|
|
expect(page).to have_content('test_changed')
|
2018-10-03 04:31:03 -04:00
|
|
|
expect(page).to have_content('Application ID')
|
2016-12-16 06:45:52 -05:00
|
|
|
expect(page).to have_content('Secret')
|
2017-07-24 16:45:12 -04:00
|
|
|
expect(page).to have_content('Trusted N')
|
2020-01-22 13:08:47 -05:00
|
|
|
expect(page).to have_content('Confidential N')
|
2016-12-16 06:45:52 -05:00
|
|
|
|
|
|
|
visit admin_applications_path
|
|
|
|
page.within '.oauth-applications' do
|
|
|
|
click_on 'Destroy'
|
|
|
|
end
|
|
|
|
expect(page.find('.oauth-applications')).not_to have_content('test_changed')
|
|
|
|
end
|
2020-09-02 11:10:54 -04:00
|
|
|
|
|
|
|
context 'when scopes are blank' do
|
|
|
|
it 'returns an error' do
|
|
|
|
visit admin_applications_path
|
|
|
|
|
|
|
|
click_on 'New application'
|
|
|
|
expect(page).to have_content('New application')
|
|
|
|
|
|
|
|
fill_in :doorkeeper_application_name, with: 'test'
|
|
|
|
fill_in :doorkeeper_application_redirect_uri, with: 'https://test.com'
|
|
|
|
click_on 'Submit'
|
|
|
|
|
|
|
|
expect(page).to have_content("Scopes can't be blank")
|
|
|
|
end
|
|
|
|
end
|
2016-12-16 06:45:52 -05:00
|
|
|
end
|