Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/git_access_spec.rb')
-rw-r--r--spec/lib/gitlab/git_access_spec.rb44
1 files changed, 35 insertions, 9 deletions
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb
index 9e25b2e4789..31a5bc737ba 100644
--- a/spec/lib/gitlab/git_access_spec.rb
+++ b/spec/lib/gitlab/git_access_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::GitAccess do
+RSpec.describe Gitlab::GitAccess, :aggregate_failures do
include TermsHelper
include GitHelpers
include AdminModeHelper
@@ -78,9 +78,7 @@ RSpec.describe Gitlab::GitAccess do
let(:auth_result_type) { :ci }
it "doesn't block http pull" do
- aggregate_failures do
- expect { pull_access_check }.not_to raise_error
- end
+ expect { pull_access_check }.not_to raise_error
end
end
end
@@ -153,6 +151,20 @@ RSpec.describe Gitlab::GitAccess do
it 'does not block pushes with "not found"' do
expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:auth_upload])
end
+
+ it 'logs' do
+ allow(Gitlab::AppJsonLogger).to receive(:info).with(
+ hash_including(
+ "class" => "AuthorizedProjectUpdate::ProjectRecalculatePerUserWorker"
+ )
+ )
+ expect(Gitlab::AppJsonLogger).to receive(:info).with(
+ message: 'Actor was :ci',
+ project_id: project.id
+ ).once
+
+ pull_access_check
+ end
end
context 'when actor is DeployToken' do
@@ -231,7 +243,7 @@ RSpec.describe Gitlab::GitAccess do
context 'key is expired' do
let(:actor) { create(:deploy_key, :expired) }
- it 'does not allow expired keys', :aggregate_failures do
+ it 'does not allow expired keys' do
expect { pull_access_check }.to raise_forbidden('Your SSH key has expired.')
expect { push_access_check }.to raise_forbidden('Your SSH key has expired.')
end
@@ -242,7 +254,7 @@ RSpec.describe Gitlab::GitAccess do
stub_application_setting(rsa_key_restriction: 4096)
end
- it 'does not allow keys which are too small', :aggregate_failures do
+ it 'does not allow keys which are too small' do
expect(actor).not_to be_valid
expect { pull_access_check }.to raise_forbidden('Your SSH key must be at least 4096 bits.')
expect { push_access_check }.to raise_forbidden('Your SSH key must be at least 4096 bits.')
@@ -254,7 +266,7 @@ RSpec.describe Gitlab::GitAccess do
stub_application_setting(rsa_key_restriction: ApplicationSetting::FORBIDDEN_KEY_VALUE)
end
- it 'does not allow keys which are too small', :aggregate_failures do
+ it 'does not allow keys which are too small' do
expect(actor).not_to be_valid
expect { pull_access_check }.to raise_forbidden(/Your SSH key type is forbidden/)
expect { push_access_check }.to raise_forbidden(/Your SSH key type is forbidden/)
@@ -736,6 +748,20 @@ RSpec.describe Gitlab::GitAccess do
context 'pull code' do
it { expect { pull_access_check }.not_to raise_error }
+
+ it 'logs' do
+ expect(Gitlab::AppJsonLogger).to receive(:info).with(
+ hash_including(
+ "class" => "AuthorizedProjectUpdate::ProjectRecalculatePerUserWorker"
+ )
+ ).once
+ expect(Gitlab::AppJsonLogger).to receive(:info).with(
+ message: 'Actor was :ci',
+ project_id: project.id
+ ).once
+
+ pull_access_check
+ end
end
end
end
@@ -1163,13 +1189,13 @@ RSpec.describe Gitlab::GitAccess do
-> { push_access_check }]
end
- it 'blocks access when the user did not accept terms', :aggregate_failures do
+ it 'blocks access when the user did not accept terms' do
actions.each do |action|
expect { action.call }.to raise_forbidden(/must accept the Terms of Service in order to perform this action/)
end
end
- it 'allows access when the user accepted the terms', :aggregate_failures do
+ it 'allows access when the user accepted the terms' do
accept_terms(user)
actions.each do |action|