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
6e5f1607
Commit
6e5f1607
authored
Jun 17, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for audit event
parent
cce2753e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
5 deletions
+25
-5
changelogs/unreleased/services-usage-3.yml
changelogs/unreleased/services-usage-3.yml
+1
-1
ee/spec/requests/api/users_spec.rb
ee/spec/requests/api/users_spec.rb
+24
-4
No files found.
changelogs/unreleased/services-usage-3.yml
View file @
6e5f1607
---
---
title
:
Record audit event when a
n admin
creates a new SSH Key for themselves via the API
title
:
Record audit event when a
user
creates a new SSH Key for themselves via the API
merge_request
:
34645
merge_request
:
34645
author
:
Rajendra Kadam
author
:
Rajendra Kadam
type
:
fixed
type
:
fixed
ee/spec/requests/api/users_spec.rb
View file @
6e5f1607
...
@@ -62,10 +62,12 @@ RSpec.describe API::Users do
...
@@ -62,10 +62,12 @@ RSpec.describe API::Users do
end
end
context
'extended audit events'
do
context
'extended audit events'
do
before
do
stub_licensed_features
(
extended_audit_events:
true
)
end
describe
"PUT /users/:id"
do
describe
"PUT /users/:id"
do
it
"creates audit event when updating user with new password"
do
it
"creates audit event when updating user with new password"
do
stub_licensed_features
(
extended_audit_events:
true
)
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
params:
{
password:
'12345678'
}
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
params:
{
password:
'12345678'
}
expect
(
AuditEvent
.
count
).
to
eq
(
1
)
expect
(
AuditEvent
.
count
).
to
eq
(
1
)
...
@@ -74,13 +76,31 @@ RSpec.describe API::Users do
...
@@ -74,13 +76,31 @@ RSpec.describe API::Users do
describe
'POST /users/:id/block'
do
describe
'POST /users/:id/block'
do
it
'creates audit event when blocking user'
do
it
'creates audit event when blocking user'
do
stub_licensed_features
(
extended_audit_events:
true
)
expect
do
expect
do
post
api
(
"/users/
#{
user
.
id
}
/block"
,
admin
)
post
api
(
"/users/
#{
user
.
id
}
/block"
,
admin
)
end
.
to
change
{
AuditEvent
.
count
}.
by
(
1
)
end
.
to
change
{
AuditEvent
.
count
}.
by
(
1
)
end
end
end
end
describe
'POST /keys'
do
let
(
:key_attrs
)
{
attributes_for
:key
}
def
make_request
(
endpoint
,
user
)
post
api
(
endpoint
,
user
),
params:
key_attrs
end
it
'creates audit event when user adds a new SSH key'
do
expect
do
make_request
(
"/user/keys"
,
user
)
end
.
to
change
{
AuditEvent
.
count
}.
by
(
1
)
end
it
'creates audit event when admin adds a new key for a user'
do
expect
do
make_request
(
"/users/
#{
user
.
id
}
/keys"
,
admin
)
end
.
to
change
{
AuditEvent
.
count
}.
by
(
1
)
end
end
end
end
context
'shared_runners_minutes_limit'
do
context
'shared_runners_minutes_limit'
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