diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 07:33:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 07:33:21 +0000 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/lib/gitlab/audit | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) | |
download | gitlab-ce-36a59d088eca61b834191dacea009677a96c052f.tar.gz |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/lib/gitlab/audit')
-rw-r--r-- | spec/lib/gitlab/audit/deploy_token_author_spec.rb | 17 | ||||
-rw-r--r-- | spec/lib/gitlab/audit/null_author_spec.rb | 9 |
2 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/gitlab/audit/deploy_token_author_spec.rb b/spec/lib/gitlab/audit/deploy_token_author_spec.rb new file mode 100644 index 00000000000..449b7456a80 --- /dev/null +++ b/spec/lib/gitlab/audit/deploy_token_author_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Audit::DeployTokenAuthor do + describe '#initialize' do + it 'sets correct attributes' do + expect(described_class.new(name: 'Lorem deploy token')) + .to have_attributes(id: -2, name: 'Lorem deploy token') + end + + it 'sets default name when it is not provided' do + expect(described_class.new) + .to have_attributes(id: -2, name: 'Deploy Token') + end + end +end diff --git a/spec/lib/gitlab/audit/null_author_spec.rb b/spec/lib/gitlab/audit/null_author_spec.rb index 7203a0cd816..2045139a5f7 100644 --- a/spec/lib/gitlab/audit/null_author_spec.rb +++ b/spec/lib/gitlab/audit/null_author_spec.rb @@ -48,6 +48,15 @@ RSpec.describe Gitlab::Audit::NullAuthor do expect(subject.for(-1, audit_event)).to be_a(Gitlab::Audit::CiRunnerTokenAuthor) expect(subject.for(-1, audit_event)).to have_attributes(id: -1, name: 'Authentication token: cde456') end + + it 'returns DeployTokenAuthor when id equals -2', :aggregate_failures do + allow(audit_event).to receive(:[]).with(:author_name).and_return('Test deploy token') + allow(audit_event).to receive(:details).and_return({}) + allow(audit_event).to receive(:target_type) + + expect(subject.for(-2, audit_event)).to be_a(Gitlab::Audit::DeployTokenAuthor) + expect(subject.for(-2, audit_event)).to have_attributes(id: -2, name: 'Test deploy token') + end end describe '#current_sign_in_ip' do |