Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
575e90ad
Commit
575e90ad
authored
Feb 17, 2021
by
Tan Le
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update IP address verification in specs
parent
79bf1c38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
ee/spec/services/ee/audit_events/protected_branch_audit_event_service_spec.rb
...audit_events/protected_branch_audit_event_service_spec.rb
+6
-4
No files found.
ee/spec/services/ee/audit_events/protected_branch_audit_event_service_spec.rb
View file @
575e90ad
...
...
@@ -2,13 +2,14 @@
require
'spec_helper'
RSpec
.
describe
EE
::
AuditEvents
::
ProtectedBranchAuditEventService
do
RSpec
.
describe
EE
::
AuditEvents
::
ProtectedBranchAuditEventService
,
:request_store
do
let
(
:merge_level
)
{
'Maintainers'
}
let
(
:push_level
)
{
'No one'
}
let_it_be
(
:author
)
{
create
(
:user
,
:with_sign_ins
)
}
let_it_be
(
:entity
)
{
create
(
:project
,
creator:
author
)
}
let_it_be
(
:protected_branch
)
{
create
(
:protected_branch
,
:no_one_can_push
,
project:
entity
)
}
let
(
:logger
)
{
instance_spy
(
Gitlab
::
AuditJsonLogger
)
}
let
(
:ip_address
)
{
'192.168.15.18'
}
describe
'#security_event'
do
shared_examples
'loggable'
do
|
action
|
...
...
@@ -17,6 +18,7 @@ RSpec.describe EE::AuditEvents::ProtectedBranchAuditEventService do
before
do
stub_licensed_features
(
admin_audit_log:
true
)
allow
(
Gitlab
::
RequestContext
.
instance
).
to
receive
(
:client_ip
).
and_return
(
ip_address
)
end
it
'creates an event'
,
:aggregate_failures
do
...
...
@@ -33,13 +35,13 @@ RSpec.describe EE::AuditEvents::ProtectedBranchAuditEventService do
target_details:
protected_branch
.
name
,
push_access_levels:
[
push_level
],
merge_access_levels:
[
merge_level
],
ip_address:
'127.0.0.1'
ip_address:
ip_address
)
expect
(
security_event
.
author_id
).
to
eq
(
author
.
id
)
expect
(
security_event
.
entity_id
).
to
eq
(
entity
.
id
)
expect
(
security_event
.
entity_type
).
to
eq
(
'Project'
)
expect
(
security_event
.
ip_address
).
to
eq
(
'127.0.0.1'
)
expect
(
security_event
.
ip_address
).
to
eq
(
ip_address
)
end
it
'logs to a file with the provided details'
do
...
...
@@ -59,7 +61,7 @@ RSpec.describe EE::AuditEvents::ProtectedBranchAuditEventService do
target_id:
protected_branch
.
id
,
target_type:
'ProtectedBranch'
,
action
=>
'protected_branch'
,
ip_address:
'127.0.0.1'
ip_address:
ip_address
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment