diff options
Diffstat (limited to 'spec/policies/global_policy_spec.rb')
-rw-r--r-- | spec/policies/global_policy_spec.rb | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/spec/policies/global_policy_spec.rb b/spec/policies/global_policy_spec.rb index 3d6d95bb122..0d91c288bbc 100644 --- a/spec/policies/global_policy_spec.rb +++ b/spec/policies/global_policy_spec.rb @@ -10,6 +10,7 @@ RSpec.describe GlobalPolicy, feature_category: :shared do let_it_be(:service_account) { create(:user, :service_account) } let_it_be(:migration_bot) { create(:user, :migration_bot) } let_it_be(:security_bot) { create(:user, :security_bot) } + let_it_be(:llm_bot) { create(:user, :llm_bot) } let_it_be_with_reload(:current_user) { create(:user) } let_it_be(:user) { create(:user) } @@ -238,6 +239,12 @@ RSpec.describe GlobalPolicy, feature_category: :shared do it { is_expected.to be_disallowed(:access_api) } end + context 'llm bot' do + let(:current_user) { llm_bot } + + it { is_expected.to be_disallowed(:access_api) } + end + context 'user blocked pending approval' do before do current_user.block_pending_approval @@ -617,6 +624,12 @@ RSpec.describe GlobalPolicy, feature_category: :shared do it { is_expected.to be_disallowed(:log_in) } end + context 'llm bot' do + let(:current_user) { llm_bot } + + it { is_expected.to be_disallowed(:log_in) } + end + context 'user blocked pending approval' do before do current_user.block_pending_approval @@ -626,47 +639,53 @@ RSpec.describe GlobalPolicy, feature_category: :shared do end end - describe 'create_instance_runners' do + describe 'create_instance_runner' do context 'admin' do let(:current_user) { admin_user } context 'when admin mode is enabled', :enable_admin_mode do - it { is_expected.to be_allowed(:create_instance_runners) } + it { is_expected.to be_allowed(:create_instance_runner) } end context 'when admin mode is disabled' do - it { is_expected.to be_disallowed(:create_instance_runners) } + it { is_expected.to be_disallowed(:create_instance_runner) } end end context 'with project_bot' do let(:current_user) { project_bot } - it { is_expected.to be_disallowed(:create_instance_runners) } + it { is_expected.to be_disallowed(:create_instance_runner) } end context 'with migration_bot' do let(:current_user) { migration_bot } - it { is_expected.to be_disallowed(:create_instance_runners) } + it { is_expected.to be_disallowed(:create_instance_runner) } end context 'with security_bot' do let(:current_user) { security_bot } + it { is_expected.to be_disallowed(:create_instance_runner) } + end + + context 'with llm_bot' do + let(:current_user) { llm_bot } + it { is_expected.to be_disallowed(:create_instance_runners) } end context 'with regular user' do let(:current_user) { user } - it { is_expected.to be_disallowed(:create_instance_runners) } + it { is_expected.to be_disallowed(:create_instance_runner) } end context 'with anonymous' do let(:current_user) { nil } - it { is_expected.to be_disallowed(:create_instance_runners) } + it { is_expected.to be_disallowed(:create_instance_runner) } end context 'create_runner_workflow_for_admin flag disabled' do @@ -678,42 +697,48 @@ RSpec.describe GlobalPolicy, feature_category: :shared do let(:current_user) { admin_user } context 'when admin mode is enabled', :enable_admin_mode do - it { is_expected.to be_disallowed(:create_instance_runners) } + it { is_expected.to be_disallowed(:create_instance_runner) } end context 'when admin mode is disabled' do - it { is_expected.to be_disallowed(:create_instance_runners) } + it { is_expected.to be_disallowed(:create_instance_runner) } end end context 'with project_bot' do let(:current_user) { project_bot } - it { is_expected.to be_disallowed(:create_instance_runners) } + it { is_expected.to be_disallowed(:create_instance_runner) } end context 'with migration_bot' do let(:current_user) { migration_bot } - it { is_expected.to be_disallowed(:create_instance_runners) } + it { is_expected.to be_disallowed(:create_instance_runner) } end context 'with security_bot' do let(:current_user) { security_bot } + it { is_expected.to be_disallowed(:create_instance_runner) } + end + + context 'with llm_bot' do + let(:current_user) { llm_bot } + it { is_expected.to be_disallowed(:create_instance_runners) } end context 'with regular user' do let(:current_user) { user } - it { is_expected.to be_disallowed(:create_instance_runners) } + it { is_expected.to be_disallowed(:create_instance_runner) } end context 'with anonymous' do let(:current_user) { nil } - it { is_expected.to be_disallowed(:create_instance_runners) } + it { is_expected.to be_disallowed(:create_instance_runner) } end end end |