debian-mirror-gitlab/spec/features/projects/settings/access_tokens_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
2.1 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'Project > Settings > Access Tokens', :js do
2020-05-24 23:13:21 +05:30
let_it_be(:user) { create(:user) }
let_it_be(:bot_user) { create(:user, :project_bot) }
2021-04-29 21:17:54 +05:30
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
2022-03-02 08:16:31 +05:30
let_it_be(:resource_settings_access_tokens_path) { project_settings_access_tokens_path(project) }
2020-05-24 23:13:21 +05:30
before_all do
project.add_maintainer(user)
end
before do
2021-12-11 22:18:48 +05:30
stub_feature_flags(bootstrap_confirmation_modals: false)
2020-05-24 23:13:21 +05:30
sign_in(user)
end
2022-03-02 08:16:31 +05:30
def create_resource_access_token
2020-05-24 23:13:21 +05:30
project.add_maintainer(bot_user)
create(:personal_access_token, user: bot_user)
end
2021-04-29 21:17:54 +05:30
context 'when user is not a project maintainer' do
before do
project.add_developer(user)
end
2022-03-02 08:16:31 +05:30
it_behaves_like 'resource access tokens missing access rights'
2021-04-29 21:17:54 +05:30
end
2020-05-24 23:13:21 +05:30
describe 'token creation' do
2022-03-02 08:16:31 +05:30
it_behaves_like 'resource access tokens creation', 'project'
2021-04-29 21:17:54 +05:30
context 'when token creation is not allowed' do
2022-03-02 08:16:31 +05:30
it_behaves_like 'resource access tokens creation disallowed', 'Project access token creation is disabled in this group. You can still use and manage existing tokens.'
2021-04-29 21:17:54 +05:30
context 'with a project in a personal namespace' do
let(:personal_project) { create(:project) }
before do
personal_project.add_maintainer(user)
end
2022-03-02 08:16:31 +05:30
it 'shows access token creation form and text' do
2021-04-29 21:17:54 +05:30
visit project_settings_access_tokens_path(personal_project)
2022-03-02 08:16:31 +05:30
expect(page).to have_selector('#new_resource_access_token')
2021-06-08 01:23:25 +05:30
expect(page).to have_text('Generate project access tokens scoped to this project for your applications that need access to the GitLab API.')
2021-04-29 21:17:54 +05:30
end
end
end
2020-05-24 23:13:21 +05:30
end
describe 'active tokens' do
2022-03-02 08:16:31 +05:30
let!(:resource_access_token) { create_resource_access_token }
2020-05-24 23:13:21 +05:30
2022-03-02 08:16:31 +05:30
it_behaves_like 'active resource access tokens'
2020-05-24 23:13:21 +05:30
end
describe 'inactive tokens' do
2022-03-02 08:16:31 +05:30
let!(:resource_access_token) { create_resource_access_token }
2020-05-24 23:13:21 +05:30
2022-03-02 08:16:31 +05:30
it_behaves_like 'inactive resource access tokens', 'This project has no active access tokens.'
2020-05-24 23:13:21 +05:30
end
end