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
45376a74
Commit
45376a74
authored
Aug 17, 2018
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix: Project deletion may not log audit events during user deletion"
This reverts commit
ad2af8f8
.
parent
ad2af8f8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
35 deletions
+26
-35
app/services/projects/destroy_service.rb
app/services/projects/destroy_service.rb
+3
-0
app/services/users/destroy_service.rb
app/services/users/destroy_service.rb
+3
-4
changelogs/unreleased/49796-project-deletion-may-not-log-audit-events-during-user-deletion.yml
...eletion-may-not-log-audit-events-during-user-deletion.yml
+0
-5
spec/services/users/destroy_service_spec.rb
spec/services/users/destroy_service_spec.rb
+13
-26
spec/workers/project_destroy_worker_spec.rb
spec/workers/project_destroy_worker_spec.rb
+7
-0
No files found.
app/services/projects/destroy_service.rb
View file @
45376a74
...
@@ -84,6 +84,9 @@ module Projects
...
@@ -84,6 +84,9 @@ module Projects
end
end
def
remove_repository
(
path
)
def
remove_repository
(
path
)
# Skip repository removal. We use this flag when remove user or group
return
true
if
params
[
:skip_repo
]
==
true
# There is a possibility project does not have repository or wiki
# There is a possibility project does not have repository or wiki
return
true
unless
repo_exists?
(
path
)
return
true
unless
repo_exists?
(
path
)
...
...
app/services/users/destroy_service.rb
View file @
45376a74
...
@@ -4,8 +4,6 @@ module Users
...
@@ -4,8 +4,6 @@ module Users
class
DestroyService
class
DestroyService
prepend
::
EE
::
Users
::
DestroyService
prepend
::
EE
::
Users
::
DestroyService
DestroyError
=
Class
.
new
(
StandardError
)
attr_accessor
:current_user
attr_accessor
:current_user
def
initialize
(
current_user
)
def
initialize
(
current_user
)
...
@@ -50,8 +48,9 @@ module Users
...
@@ -50,8 +48,9 @@ module Users
namespace
.
prepare_for_destroy
namespace
.
prepare_for_destroy
user
.
personal_projects
.
each
do
|
project
|
user
.
personal_projects
.
each
do
|
project
|
success
=
::
Projects
::
DestroyService
.
new
(
project
,
current_user
).
execute
# Skip repository removal because we remove directory with namespace
raise
DestroyError
,
"Project
#{
project
.
id
}
can't be deleted"
unless
success
# that contain all this repositories
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
skip_repo:
project
.
legacy_storage?
).
execute
end
end
yield
(
user
)
if
block_given?
yield
(
user
)
if
block_given?
...
...
changelogs/unreleased/49796-project-deletion-may-not-log-audit-events-during-user-deletion.yml
deleted
100644 → 0
View file @
ad2af8f8
---
title
:
'
Fix:
Project
deletion
may
not
log
audit
events
during
user
deletion'
merge_request
:
author
:
type
:
fixed
spec/services/users/destroy_service_spec.rb
View file @
45376a74
...
@@ -20,7 +20,7 @@ describe Users::DestroyService do
...
@@ -20,7 +20,7 @@ describe Users::DestroyService do
it
'will delete the project'
do
it
'will delete the project'
do
expect_next_instance_of
(
Projects
::
DestroyService
)
do
|
destroy_service
|
expect_next_instance_of
(
Projects
::
DestroyService
)
do
|
destroy_service
|
expect
(
destroy_service
).
to
receive
(
:execute
).
once
.
and_return
(
true
)
expect
(
destroy_service
).
to
receive
(
:execute
).
once
end
end
service
.
execute
(
user
)
service
.
execute
(
user
)
...
@@ -35,7 +35,7 @@ describe Users::DestroyService do
...
@@ -35,7 +35,7 @@ describe Users::DestroyService do
it
'destroys a project in pending_delete'
do
it
'destroys a project in pending_delete'
do
expect_next_instance_of
(
Projects
::
DestroyService
)
do
|
destroy_service
|
expect_next_instance_of
(
Projects
::
DestroyService
)
do
|
destroy_service
|
expect
(
destroy_service
).
to
receive
(
:execute
).
once
.
and_return
(
true
)
expect
(
destroy_service
).
to
receive
(
:execute
).
once
end
end
service
.
execute
(
user
)
service
.
execute
(
user
)
...
@@ -172,36 +172,23 @@ describe Users::DestroyService do
...
@@ -172,36 +172,23 @@ describe Users::DestroyService do
end
end
describe
"user personal's repository removal"
do
describe
"user personal's repository removal"
do
context
'storages'
do
before
do
before
do
perform_enqueued_jobs
{
service
.
execute
(
user
)
}
perform_enqueued_jobs
{
service
.
execute
(
user
)
}
end
end
context
'legacy storage'
do
let!
(
:project
)
{
create
(
:project
,
:empty_repo
,
:legacy_storage
,
namespace:
user
.
namespace
)
}
it
'removes repository'
do
expect
(
gitlab_shell
.
exists?
(
project
.
repository_storage
,
"
#{
project
.
disk_path
}
.git"
)).
to
be_falsey
end
end
context
'hashed
storage'
do
context
'legacy
storage'
do
let!
(
:project
)
{
create
(
:project
,
:empty_repo
,
namespace:
user
.
namespace
)
}
let!
(
:project
)
{
create
(
:project
,
:empty_repo
,
:legacy_storage
,
namespace:
user
.
namespace
)
}
it
'removes repository'
do
it
'removes repository'
do
expect
(
gitlab_shell
.
exists?
(
project
.
repository_storage
,
"
#{
project
.
disk_path
}
.git"
)).
to
be_falsey
expect
(
gitlab_shell
.
exists?
(
project
.
repository_storage
,
"
#{
project
.
disk_path
}
.git"
)).
to
be_falsey
end
end
end
end
end
context
'repository removal status is taken into account'
do
context
'hashed storage'
do
it
'raises exception'
do
let!
(
:project
)
{
create
(
:project
,
:empty_repo
,
namespace:
user
.
namespace
)
}
expect_next_instance_of
(
::
Projects
::
DestroyService
)
do
|
destroy_service
|
expect
(
destroy_service
).
to
receive
(
:execute
).
and_return
(
false
)
end
expect
{
service
.
execute
(
user
)
}
it
'removes repository'
do
.
to
raise_error
(
Users
::
DestroyService
::
DestroyError
,
"Project
#{
project
.
id
}
can't be deleted"
)
expect
(
gitlab_shell
.
exists?
(
project
.
repository_storage
,
"
#{
project
.
disk_path
}
.git"
)).
to
be_falsey
end
end
end
end
end
end
...
...
spec/workers/project_destroy_worker_spec.rb
View file @
45376a74
...
@@ -18,6 +18,13 @@ describe ProjectDestroyWorker do
...
@@ -18,6 +18,13 @@ describe ProjectDestroyWorker do
expect
(
Dir
.
exist?
(
path
)).
to
be_falsey
expect
(
Dir
.
exist?
(
path
)).
to
be_falsey
end
end
it
'deletes the project but skips repo deletion'
do
subject
.
perform
(
project
.
id
,
project
.
owner
.
id
,
{
"skip_repo"
=>
true
})
expect
(
Project
.
all
).
not_to
include
(
project
)
expect
(
Dir
.
exist?
(
path
)).
to
be_truthy
end
it
'does not raise error when project could not be found'
do
it
'does not raise error when project could not be found'
do
expect
do
expect
do
subject
.
perform
(
-
1
,
project
.
owner
.
id
,
{})
subject
.
perform
(
-
1
,
project
.
owner
.
id
,
{})
...
...
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