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
54f1f026
Commit
54f1f026
authored
Jun 10, 2020
by
GitLab Release Tools Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'dev/master'
parents
7283e591
04d64eb7
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
227 additions
and
11 deletions
+227
-11
CHANGELOG-EE.md
CHANGELOG-EE.md
+21
-0
CHANGELOG.md
CHANGELOG.md
+12
-0
ee/app/mailers/ee/emails/projects.rb
ee/app/mailers/ee/emails/projects.rb
+11
-0
ee/app/mailers/ee/preview/notify_preview.rb
ee/app/mailers/ee/preview/notify_preview.rb
+4
-0
ee/app/services/ee/notification_service.rb
ee/app/services/ee/notification_service.rb
+8
-0
ee/app/services/ee/users/destroy_service.rb
ee/app/services/ee/users/destroy_service.rb
+8
-4
ee/app/views/notify/mirror_was_disabled_email.html.haml
ee/app/views/notify/mirror_was_disabled_email.html.haml
+5
-0
ee/app/views/notify/mirror_was_disabled_email.text.erb
ee/app/views/notify/mirror_was_disabled_email.text.erb
+3
-0
ee/spec/mailers/notify_spec.rb
ee/spec/mailers/notify_spec.rb
+27
-0
ee/spec/services/ee/notification_service_spec.rb
ee/spec/services/ee/notification_service_spec.rb
+119
-0
ee/spec/services/ee/users/destroy_service_spec.rb
ee/spec/services/ee/users/destroy_service_spec.rb
+9
-7
No files found.
CHANGELOG-EE.md
View file @
54f1f026
Please view this file on the master branch, on stable branches it's out of date.
Please view this file on the master branch, on stable branches it's out of date.
## 13.0.6 (2020-06-10)
### Security (1 change)
-
Do not set fallback mirror user.
## 13.0.4 (2020-06-03)
## 13.0.4 (2020-06-03)
-
No changes.
-
No changes.
...
@@ -343,6 +350,13 @@ Please view this file on the master branch, on stable branches it's out of date.
...
@@ -343,6 +350,13 @@ Please view this file on the master branch, on stable branches it's out of date.
-
Translate unauthenticated user string for Audit Event. !31856 (Sashi Kumar)
-
Translate unauthenticated user string for Audit Event. !31856 (Sashi Kumar)
## 12.10.11 (2020-06-10)
### Security (1 change)
-
Do not set fallback mirror user.
## 12.10.8 (2020-05-28)
## 12.10.8 (2020-05-28)
### Fixed (1 change)
### Fixed (1 change)
...
@@ -433,6 +447,13 @@ Please view this file on the master branch, on stable branches it's out of date.
...
@@ -433,6 +447,13 @@ Please view this file on the master branch, on stable branches it's out of date.
-
Add health status counts to usage data. !28964
-
Add health status counts to usage data. !28964
## 12.9.10 (2020-06-10)
### Security (1 change)
-
Do not set fallback mirror user.
## 12.9.8 (2020-05-27)
## 12.9.8 (2020-05-27)
### Security (3 changes)
### Security (3 changes)
...
...
CHANGELOG.md
View file @
54f1f026
...
@@ -2,6 +2,10 @@
...
@@ -2,6 +2,10 @@
documentation
](
doc/development/changelog.md
)
for instructions on adding your own
documentation
](
doc/development/changelog.md
)
for instructions on adding your own
entry.
entry.
## 13.0.6 (2020-06-10)
-
No changes.
## 13.0.4 (2020-06-03)
## 13.0.4 (2020-06-03)
### Security (1 change)
### Security (1 change)
...
@@ -610,6 +614,10 @@ entry.
...
@@ -610,6 +614,10 @@ entry.
-
Use visitUrl in Alert management. !32414
-
Use visitUrl in Alert management. !32414
## 12.10.11 (2020-06-10)
-
No changes.
## 12.10.8 (2020-05-28)
## 12.10.8 (2020-05-28)
### Fixed (2 changes)
### Fixed (2 changes)
...
@@ -1138,6 +1146,10 @@ entry.
...
@@ -1138,6 +1146,10 @@ entry.
-
Remove store_mentions! in Snippets::CreateService. !29581 (Sashi Kumar)
-
Remove store_mentions! in Snippets::CreateService. !29581 (Sashi Kumar)
## 12.9.10 (2020-06-10)
-
No changes.
## 12.9.8 (2020-05-27)
## 12.9.8 (2020-05-27)
### Security (13 changes)
### Security (13 changes)
...
...
ee/app/mailers/ee/emails/projects.rb
View file @
54f1f026
...
@@ -11,6 +11,17 @@ module EE
...
@@ -11,6 +11,17 @@ module EE
subject:
subject
(
'Repository mirroring paused'
))
subject:
subject
(
'Repository mirroring paused'
))
end
end
def
mirror_was_disabled_email
(
project_id
,
user_id
,
deleted_user_name
)
@project
=
::
Project
.
find
(
project_id
)
user
=
::
User
.
find_by_id
(
user_id
)
@deleted_user_name
=
deleted_user_name
return
unless
user
mail
(
to:
user
.
notification_email_for
(
@project
.
group
),
subject:
subject
(
'Repository mirroring disabled'
))
end
def
project_mirror_user_changed_email
(
new_mirror_user_id
,
deleted_user_name
,
project_id
)
def
project_mirror_user_changed_email
(
new_mirror_user_id
,
deleted_user_name
,
project_id
)
@project
=
::
Project
.
find
(
project_id
)
@project
=
::
Project
.
find
(
project_id
)
@deleted_user_name
=
deleted_user_name
@deleted_user_name
=
deleted_user_name
...
...
ee/app/mailers/ee/preview/notify_preview.rb
View file @
54f1f026
...
@@ -24,6 +24,10 @@ module EE
...
@@ -24,6 +24,10 @@ module EE
::
Notify
.
mirror_was_hard_failed_email
(
project
.
id
,
user
.
id
).
message
::
Notify
.
mirror_was_hard_failed_email
(
project
.
id
,
user
.
id
).
message
end
end
def
mirror_was_disabled_email
::
Notify
.
mirror_was_disabled_email
(
project
.
id
,
user
.
id
,
'deleted_user_name'
).
message
end
def
project_mirror_user_changed_email
def
project_mirror_user_changed_email
::
Notify
.
project_mirror_user_changed_email
(
user
.
id
,
'deleted_user_name'
,
project
.
id
).
message
::
Notify
.
project_mirror_user_changed_email
(
user
.
id
,
'deleted_user_name'
,
project
.
id
).
message
end
end
...
...
ee/app/services/ee/notification_service.rb
View file @
54f1f026
...
@@ -38,6 +38,14 @@ module EE
...
@@ -38,6 +38,14 @@ module EE
end
end
end
end
def
mirror_was_disabled
(
project
,
deleted_user_name
)
return
if
project
.
emails_disabled?
owners_and_maintainers_without_invites
(
project
).
each
do
|
recipient
|
mailer
.
mirror_was_disabled_email
(
project
.
id
,
recipient
.
user
.
id
,
deleted_user_name
).
deliver_later
end
end
def
new_epic
(
epic
)
def
new_epic
(
epic
)
new_resource_email
(
epic
,
:new_epic_email
)
new_resource_email
(
epic
,
:new_epic_email
)
end
end
...
...
ee/app/services/ee/users/destroy_service.rb
View file @
54f1f026
...
@@ -20,10 +20,14 @@ module EE
...
@@ -20,10 +20,14 @@ module EE
user_mirrors
=
::
Project
.
where
(
mirror_user:
user
)
# rubocop: disable CodeReuse/ActiveRecord
user_mirrors
=
::
Project
.
where
(
mirror_user:
user
)
# rubocop: disable CodeReuse/ActiveRecord
user_mirrors
.
find_each
do
|
mirror
|
user_mirrors
.
find_each
do
|
mirror
|
new_mirror_user
=
first_mirror_owner
(
user
,
mirror
)
mirror
.
update
(
mirror:
false
,
mirror_user:
nil
)
::
Gitlab
::
ErrorTracking
.
track_exception
(
mirror
.
update
(
mirror_user:
new_mirror_user
)
RuntimeError
.
new
(
'Disabled mirroring'
),
::
NotificationService
.
new
.
project_mirror_user_changed
(
new_mirror_user
,
user
.
name
,
mirror
)
user_id:
user
.
id
,
project_id:
mirror
.
id
)
::
NotificationService
.
new
.
mirror_was_disabled
(
mirror
,
user
.
name
)
end
end
end
end
...
...
ee/app/views/notify/mirror_was_disabled_email.html.haml
0 → 100644
View file @
54f1f026
%p
Repository mirroring on
#{
@project
.
full_path
}
was disabled because the mirror user
#{
sanitize_name
(
@deleted_user_name
)
}
was deleted.
%p
To re-enable mirroring, update your
#{
link_to
(
"repository mirroring settings"
,
project_settings_repository_url
(
@project
))
}
.
ee/app/views/notify/mirror_was_disabled_email.text.erb
0 → 100644
View file @
54f1f026
Repository mirroring on
<%=
@project
.
full_path
%>
was disabled because the mirror user
<%=
sanitize_name
(
@deleted_user_name
)
%>
was deleted.
To re-enable mirroring, update your repository settings at
<%=
project_settings_repository_url
(
@project
)
%>
.
ee/spec/mailers/notify_spec.rb
View file @
54f1f026
...
@@ -372,6 +372,33 @@ RSpec.describe Notify do
...
@@ -372,6 +372,33 @@ RSpec.describe Notify do
end
end
end
end
describe
'mirror was disabled'
do
let
(
:project
)
{
create
(
:project
)
}
subject
{
described_class
.
mirror_was_disabled_email
(
project
.
id
,
user
.
id
,
'deleted_user_name'
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'has the correct subject and body'
do
is_expected
.
to
have_subject
(
"
#{
project
.
name
}
| Repository mirroring disabled"
)
is_expected
.
to
have_body_text
(
project
.
full_path
)
is_expected
.
to
have_body_text
(
project_settings_repository_url
(
project
))
is_expected
.
to
have_body_text
(
'deleted_user_name'
)
end
context
'user was deleted'
do
before
do
user
.
destroy!
end
it
'does not send email'
do
expect
(
subject
.
message
).
to
be_a_kind_of
ActionMailer
::
Base
::
NullMail
end
end
end
describe
'mirror user changed'
do
describe
'mirror user changed'
do
let
(
:mirror_user
)
{
create
(
:user
)
}
let
(
:mirror_user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:mirror
,
mirror_user_id:
mirror_user
.
id
)
}
let
(
:project
)
{
create
(
:project
,
:mirror
,
mirror_user_id:
mirror_user
.
id
)
}
...
...
ee/spec/services/ee/notification_service_spec.rb
View file @
54f1f026
...
@@ -307,6 +307,125 @@ RSpec.describe EE::NotificationService, :mailer do
...
@@ -307,6 +307,125 @@ RSpec.describe EE::NotificationService, :mailer do
end
end
end
end
describe
'mirror was disabled'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let
(
:deleted_username
)
{
'deleted_user_name'
}
context
'when the project has invited members'
do
let!
(
:project_member
)
{
create
(
:project_member
,
:invited
,
project:
project
)
}
it
'sends email'
do
expect
(
Notify
).
to
receive
(
:mirror_was_disabled_email
).
with
(
project
.
id
,
project
.
owner
.
id
,
deleted_username
).
and_call_original
subject
.
mirror_was_disabled
(
project
,
deleted_username
)
end
it_behaves_like
'project emails are disabled'
do
let
(
:notification_target
)
{
project
}
let
(
:notification_trigger
)
{
subject
.
mirror_was_disabled
(
project
,
deleted_username
)
}
around
do
|
example
|
perform_enqueued_jobs
{
example
.
run
}
end
end
end
context
'when user is owner'
do
it
'sends email'
do
expect
(
Notify
).
to
receive
(
:mirror_was_disabled_email
).
with
(
project
.
id
,
project
.
owner
.
id
,
deleted_username
).
and_call_original
subject
.
mirror_was_disabled
(
project
,
deleted_username
)
end
it_behaves_like
'project emails are disabled'
do
let
(
:notification_target
)
{
project
}
let
(
:notification_trigger
)
{
subject
.
mirror_was_disabled
(
project
,
deleted_username
)
}
around
do
|
example
|
perform_enqueued_jobs
{
example
.
run
}
end
end
context
'when owner is blocked'
do
it
'does not send email'
do
project
.
owner
.
block!
expect
(
Notify
).
not_to
receive
(
:mirror_was_disabled_email
)
subject
.
mirror_was_disabled
(
project
,
deleted_username
)
end
context
'when project belongs to group'
do
it
'does not send email to the blocked owner'
do
blocked_user
=
create
(
:user
,
:blocked
)
group
=
create
(
:group
,
:public
)
group
.
add_owner
(
blocked_user
)
group
.
add_owner
(
user
)
project
=
create
(
:project
,
namespace:
group
)
expect
(
Notify
).
not_to
receive
(
:mirror_was_disabled_email
).
with
(
project
.
id
,
blocked_user
.
id
,
deleted_username
).
and_call_original
expect
(
Notify
).
to
receive
(
:mirror_was_disabled_email
).
with
(
project
.
id
,
user
.
id
,
deleted_username
).
and_call_original
subject
.
mirror_was_disabled
(
project
,
deleted_username
)
end
end
end
end
context
'when user is maintainer'
do
it
'sends email'
do
project
.
add_maintainer
(
user
)
expect
(
Notify
).
to
receive
(
:mirror_was_disabled_email
).
with
(
project
.
id
,
project
.
owner
.
id
,
deleted_username
).
and_call_original
expect
(
Notify
).
to
receive
(
:mirror_was_disabled_email
).
with
(
project
.
id
,
user
.
id
,
deleted_username
).
and_call_original
subject
.
mirror_was_disabled
(
project
,
deleted_username
)
end
end
context
'when user is not owner nor maintainer'
do
it
'does not send email'
do
project
.
add_developer
(
user
)
expect
(
Notify
).
not_to
receive
(
:mirror_was_disabled_email
).
with
(
project
.
id
,
user
.
id
,
deleted_username
).
and_call_original
expect
(
Notify
).
to
receive
(
:mirror_was_disabled_email
).
with
(
project
.
id
,
project
.
creator
.
id
,
deleted_username
).
and_call_original
subject
.
mirror_was_disabled
(
project
,
deleted_username
)
end
context
'when user is group owner'
do
it
'sends email'
do
group
=
create
(
:group
,
:public
)
do
|
group
|
group
.
add_owner
(
user
)
end
project
=
create
(
:project
,
namespace:
group
)
expect
(
Notify
).
to
receive
(
:mirror_was_disabled_email
).
with
(
project
.
id
,
user
.
id
,
deleted_username
).
and_call_original
subject
.
mirror_was_disabled
(
project
,
deleted_username
)
end
end
context
'when user is group maintainer'
do
it
'sends email'
do
group
=
create
(
:group
,
:public
)
do
|
group
|
group
.
add_maintainer
(
user
)
end
project
=
create
(
:project
,
namespace:
group
)
expect
(
Notify
).
to
receive
(
:mirror_was_disabled_email
).
with
(
project
.
id
,
user
.
id
,
deleted_username
).
and_call_original
subject
.
mirror_was_disabled
(
project
,
deleted_username
)
end
end
end
end
context
'mirror user changed'
do
context
'mirror user changed'
do
let
(
:mirror_user
)
{
create
(
:user
)
}
let
(
:mirror_user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:mirror
,
mirror_user_id:
mirror_user
.
id
)
}
let
(
:project
)
{
create
(
:project
,
:mirror
,
mirror_user_id:
mirror_user
.
id
)
}
...
...
ee/spec/services/ee/users/destroy_service_spec.rb
View file @
54f1f026
...
@@ -21,15 +21,17 @@ RSpec.describe Users::DestroyService do
...
@@ -21,15 +21,17 @@ RSpec.describe Users::DestroyService do
context
'when project is a mirror'
do
context
'when project is a mirror'
do
let
(
:project
)
{
create
(
:project
,
:mirror
,
mirror_user_id:
user
.
id
)
}
let
(
:project
)
{
create
(
:project
,
:mirror
,
mirror_user_id:
user
.
id
)
}
it
'
assigns mirror_user to a project own
er'
do
it
'
disables mirror and does not assign a new mirror_us
er'
do
new_mirror_user
=
project
.
team
.
owners
.
first
expect
(
::
Gitlab
::
ErrorTracking
).
to
receive
(
:track_exception
)
expect_any_instance_of
(
EE
::
NotificationService
)
allow_next_instance_of
(
::
NotificationService
)
do
|
notification
|
.
to
receive
(
:project_mirror_user_changed
)
expect
(
notification
).
to
receive
(
:mirror_was_disabled
)
.
with
(
new_mirror_user
,
user
.
name
,
project
)
.
with
(
project
,
user
.
name
)
.
and_call_original
end
expect
{
operation
}.
to
change
{
project
.
reload
.
mirror_user
}
expect
{
operation
}.
to
change
{
project
.
reload
.
mirror_user
}
.
from
(
user
).
to
(
nil
)
.
from
(
user
).
to
(
new_mirror_user
)
.
and
change
{
project
.
reload
.
mirror
}.
from
(
true
).
to
(
false
)
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