2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
RSpec.describe 'admin manage applications' do
|
2017-08-17 22:00:37 +05:30
|
|
|
before do
|
2021-02-22 17:27:13 +05:30
|
|
|
admin = create(:admin)
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2020-09-03 11:15:55 +05:30
|
|
|
it 'creates new oauth application' do
|
2017-08-17 22:00:37 +05:30
|
|
|
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'
|
2017-09-10 17:25:29 +05:30
|
|
|
check :doorkeeper_application_trusted
|
2020-09-03 11:15:55 +05:30
|
|
|
check :doorkeeper_application_scopes_read_user
|
2017-08-17 22:00:37 +05:30
|
|
|
click_on 'Submit'
|
|
|
|
expect(page).to have_content('Application: test')
|
2018-12-05 23:21:45 +05:30
|
|
|
expect(page).to have_content('Application ID')
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content('Secret')
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(page).to have_content('Trusted Y')
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('Confidential Y')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
click_on 'Edit'
|
|
|
|
expect(page).to have_content('Edit application')
|
|
|
|
|
|
|
|
fill_in :doorkeeper_application_name, with: 'test_changed'
|
2017-09-10 17:25:29 +05:30
|
|
|
uncheck :doorkeeper_application_trusted
|
2020-03-13 15:44:24 +05:30
|
|
|
uncheck :doorkeeper_application_confidential
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
click_on 'Submit'
|
|
|
|
expect(page).to have_content('test_changed')
|
2018-12-05 23:21:45 +05:30
|
|
|
expect(page).to have_content('Application ID')
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content('Secret')
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(page).to have_content('Trusted N')
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('Confidential N')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
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-03 11:15:55 +05:30
|
|
|
|
|
|
|
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
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|