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
07ed4699
Commit
07ed4699
authored
Mar 25, 2021
by
Doug Stull
Committed by
Dylan Griffith
Mar 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add audit events for ee invite service
- bring inline with create service.
parent
d07ce7af
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
4 deletions
+40
-4
app/services/members/invite_service.rb
app/services/members/invite_service.rb
+5
-1
ee/app/services/ee/members/invite_service.rb
ee/app/services/ee/members/invite_service.rb
+14
-3
ee/changelogs/unreleased/323078-combine-concepts-in-inviting-member-service-classes-2.yml
...combine-concepts-in-inviting-member-service-classes-2.yml
+5
-0
ee/spec/services/ee/members/invite_service_spec.rb
ee/spec/services/ee/members/invite_service_spec.rb
+16
-0
No files found.
app/services/members/invite_service.rb
View file @
07ed4699
...
...
@@ -84,7 +84,11 @@ module Members
def
add_member
(
email
)
new_member
=
source
.
add_user
(
email
,
params
[
:access_level
],
current_user:
current_user
,
expires_at:
params
[
:expires_at
])
errors
[
email
]
=
new_member
.
errors
.
full_messages
.
to_sentence
if
new_member
.
invalid?
if
new_member
.
invalid?
errors
[
email
]
=
new_member
.
errors
.
full_messages
.
to_sentence
else
after_execute
(
member:
new_member
)
end
end
def
result
...
...
ee/app/services/ee/members/invite_service.rb
View file @
07ed4699
...
...
@@ -3,11 +3,8 @@
module
EE
module
Members
module
InviteService
extend
::
Gitlab
::
Utils
::
Override
private
override
:validate_emails!
def
validate_emails!
super
...
...
@@ -25,6 +22,20 @@ module EE
source
.
actual_limits
.
exceeded?
(
:daily_invites
,
invite_count
+
emails
.
count
)
end
def
after_execute
(
member
:)
super
log_audit_event
(
member:
member
)
end
def
log_audit_event
(
member
:)
::
AuditEventService
.
new
(
current_user
,
member
.
source
,
action: :create
).
for_member
(
member
).
security_event
end
end
end
end
ee/changelogs/unreleased/323078-combine-concepts-in-inviting-member-service-classes-2.yml
0 → 100644
View file @
07ed4699
---
title
:
Add missing audit logging to invite service
merge_request
:
57358
author
:
type
:
other
ee/spec/services/ee/members/invite_service_spec.rb
View file @
07ed4699
...
...
@@ -81,5 +81,21 @@ RSpec.describe Members::InviteService, :aggregate_failures do
expect
(
result
[
:status
]).
to
eq
(
:success
)
end
end
context
'with Audit Event logging'
do
context
'when there are valid members created'
do
it
'creates Audit Events'
do
expect
{
result
}.
to
change
{
AuditEvent
.
count
}.
by
(
2
)
end
end
context
'when there are some invalid members'
do
let
(
:params
)
{
{
email:
%w[_bogus_ email2@example.org]
,
access_level:
Gitlab
::
Access
::
GUEST
}
}
it
'only creates Audit Events for valid members'
do
expect
{
result
}.
to
change
{
AuditEvent
.
count
}.
by
(
1
)
end
end
end
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