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
83a939cb
Commit
83a939cb
authored
Aug 28, 2020
by
Max Woolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves spec performance of EE::AuditEventService
This reduced average run time from ~8sec to ~1.5sec
parent
30ba441f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
ee/spec/services/audit_event_service_spec.rb
ee/spec/services/audit_event_service_spec.rb
+12
-11
No files found.
ee/spec/services/audit_event_service_spec.rb
View file @
83a939cb
...
...
@@ -3,9 +3,9 @@
require
'spec_helper'
RSpec
.
describe
AuditEventService
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
,
current_sign_in_ip:
'192.168.68.104'
)
}
let
(
:project_member
)
{
create
(
:project_member
,
user:
user
,
expires_at:
1
.
day
.
from_now
)
}
let
(
:project
)
{
build_stubbed
(
:project
)
}
let
_it_be
(
:user
)
{
create
(
:user
,
current_sign_in_ip:
'192.168.68.104'
)
}
let
_it_be
(
:project_member
)
{
create
(
:project_member
,
user:
user
,
expires_at:
1
.
day
.
from_now
)
}
let
(
:request_ip_address
)
{
'127.0.0.1'
}
let
(
:details
)
{
{
action: :destroy
,
ip_address:
request_ip_address
}
}
...
...
@@ -13,23 +13,24 @@ RSpec.describe AuditEventService do
describe
'#for_member'
do
let
(
:event
)
{
service
.
for_member
(
project_member
).
security_event
}
let
(
:event_details
)
{
event
[
:details
]
}
it
'generates event'
do
expect
(
event
[
:details
]
[
:target_details
]).
to
eq
(
user
.
name
)
expect
(
event
_details
[
:target_details
]).
to
eq
(
user
.
name
)
end
it
'handles deleted users'
do
expect
(
project_member
).
to
receive
(
:user
).
and_return
(
nil
)
expect
(
event
[
:details
]
[
:target_details
]).
to
eq
(
'Deleted User'
)
expect
(
event
_details
[
:target_details
]).
to
eq
(
'Deleted User'
)
end
context
'user access expiry'
do
let
(
:service
)
{
described_class
.
new
(
nil
,
project
,
{
action: :expired
})
}
it
'generates a system event'
do
expect
(
event
[
:details
]
[
:remove
]).
to
eq
(
'user_access'
)
expect
(
event
[
:details
]
[
:system_event
]).
to
be_truthy
expect
(
event
[
:details
]
[
:reason
]).
to
include
(
'access expired on'
)
expect
(
event
_details
[
:remove
]).
to
eq
(
'user_access'
)
expect
(
event
_details
[
:system_event
]).
to
be_truthy
expect
(
event
_details
[
:reason
]).
to
include
(
'access expired on'
)
end
end
...
...
@@ -37,13 +38,13 @@ RSpec.describe AuditEventService do
let
(
:details
)
{
{
action: :create
}
}
it
'stores author name'
,
:aggregate_failures
do
expect
(
event
.
details
[
:author_name
]).
to
eq
(
user
.
name
)
expect
(
event
_
details
[
:author_name
]).
to
eq
(
user
.
name
)
expect
(
event
.
author_name
).
to
eq
(
user
.
name
)
end
end
it
'generates a system event'
do
expect
(
event
[
:details
]
[
:target_type
]).
to
eq
(
'User'
)
expect
(
event
_details
[
:target_type
]).
to
eq
(
'User'
)
expect
(
event
.
target_type
).
to
eq
(
'User'
)
end
...
...
@@ -470,7 +471,7 @@ RSpec.describe AuditEventService do
end
it
'logs an audit event'
do
expect
{
event
}.
to
change
(
AuditEvent
,
:count
)
.
by
(
1
)
expect
{
event
}.
to
change
{
AuditEvent
.
count
}
.
by
(
1
)
end
it
'does not have the entity_path'
do
...
...
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