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
a8e04b32
Commit
a8e04b32
authored
Sep 26, 2017
by
Gabriel Mazetto
Committed by
Nick Thomas
Sep 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move project repositories between namespaces when renaming users
parent
31a79544
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
12 deletions
+49
-12
app/models/concerns/storage/legacy_namespace.rb
app/models/concerns/storage/legacy_namespace.rb
+2
-0
changelogs/unreleased/38126-security-username-change.yml
changelogs/unreleased/38126-security-username-change.yml
+5
-0
spec/controllers/profiles_controller_spec.rb
spec/controllers/profiles_controller_spec.rb
+37
-5
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+5
-7
No files found.
app/models/concerns/storage/legacy_namespace.rb
View file @
a8e04b32
...
@@ -7,6 +7,8 @@ module Storage
...
@@ -7,6 +7,8 @@ module Storage
raise
Gitlab
::
UpdatePathError
.
new
(
'Namespace cannot be moved, because at least one project has tags in container registry'
)
raise
Gitlab
::
UpdatePathError
.
new
(
'Namespace cannot be moved, because at least one project has tags in container registry'
)
end
end
expires_full_path_cache
# Move the namespace directory in all storage paths used by member projects
# Move the namespace directory in all storage paths used by member projects
repository_storage_paths
.
each
do
|
repository_storage_path
|
repository_storage_paths
.
each
do
|
repository_storage_path
|
# Ensure old directory exists before moving it
# Ensure old directory exists before moving it
...
...
changelogs/unreleased/38126-security-username-change.yml
0 → 100644
View file @
a8e04b32
---
title
:
Move project repositories between namespaces when renaming users
merge_request
:
author
:
type
:
security
spec/controllers/profiles_controller_spec.rb
View file @
a8e04b32
require
(
'spec_helper'
)
require
(
'spec_helper'
)
describe
ProfilesController
do
describe
ProfilesController
,
:request_store
do
describe
"PUT update"
do
let
(
:user
)
{
create
(
:user
)
}
it
"allows an email update from a user without an external email address"
do
user
=
create
(
:user
)
describe
'PUT update'
do
it
'allows an email update from a user without an external email address'
do
sign_in
(
user
)
sign_in
(
user
)
put
:update
,
put
:update
,
...
@@ -15,7 +16,7 @@ describe ProfilesController do
...
@@ -15,7 +16,7 @@ describe ProfilesController do
expect
(
user
.
unconfirmed_email
).
to
eq
(
'john@gmail.com'
)
expect
(
user
.
unconfirmed_email
).
to
eq
(
'john@gmail.com'
)
end
end
it
"ignores an email update from a user with an external email address"
do
it
'ignores an email update from a user with an external email address'
do
ldap_user
=
create
(
:omniauth_user
,
external_email:
true
)
ldap_user
=
create
(
:omniauth_user
,
external_email:
true
)
sign_in
(
ldap_user
)
sign_in
(
ldap_user
)
...
@@ -28,4 +29,35 @@ describe ProfilesController do
...
@@ -28,4 +29,35 @@ describe ProfilesController do
expect
(
ldap_user
.
unconfirmed_email
).
not_to
eq
(
'john@gmail.com'
)
expect
(
ldap_user
.
unconfirmed_email
).
not_to
eq
(
'john@gmail.com'
)
end
end
end
end
describe
'PUT update_username'
do
let
(
:namespace
)
{
user
.
namespace
}
let
(
:project
)
{
create
(
:project_empty_repo
,
namespace:
namespace
)
}
let
(
:gitlab_shell
)
{
Gitlab
::
Shell
.
new
}
let
(
:new_username
)
{
'renamedtosomethingelse'
}
it
'allows username change'
do
sign_in
(
user
)
put
:update_username
,
user:
{
username:
new_username
}
user
.
reload
expect
(
response
.
status
).
to
eq
(
302
)
expect
(
user
.
username
).
to
eq
(
new_username
)
end
it
'moves dependent projects to new namespace'
do
sign_in
(
user
)
put
:update_username
,
user:
{
username:
new_username
}
user
.
reload
expect
(
response
.
status
).
to
eq
(
302
)
expect
(
gitlab_shell
.
exists?
(
project
.
repository_storage_path
,
"
#{
new_username
}
/
#{
project
.
path
}
.git"
)).
to
be_truthy
end
end
end
end
spec/models/namespace_spec.rb
View file @
a8e04b32
...
@@ -2,6 +2,7 @@ require 'spec_helper'
...
@@ -2,6 +2,7 @@ require 'spec_helper'
describe
Namespace
do
describe
Namespace
do
let!
(
:namespace
)
{
create
(
:namespace
)
}
let!
(
:namespace
)
{
create
(
:namespace
)
}
let
(
:gitlab_shell
)
{
Gitlab
::
Shell
.
new
}
describe
'associations'
do
describe
'associations'
do
it
{
is_expected
.
to
have_many
:projects
}
it
{
is_expected
.
to
have_many
:projects
}
...
@@ -151,11 +152,10 @@ describe Namespace do
...
@@ -151,11 +152,10 @@ describe Namespace do
end
end
end
end
describe
'#move_dir'
do
describe
'#move_dir'
,
:request_store
do
before
do
before
do
@namespace
=
create
:namespace
@namespace
=
create
:namespace
@project
=
create
(
:project_empty_repo
,
namespace:
@namespace
)
@project
=
create
(
:project_empty_repo
,
namespace:
@namespace
)
allow
(
@namespace
).
to
receive
(
:path_changed?
).
and_return
(
true
)
end
end
it
"raises error when directory exists"
do
it
"raises error when directory exists"
do
...
@@ -163,11 +163,9 @@ describe Namespace do
...
@@ -163,11 +163,9 @@ describe Namespace do
end
end
it
"moves dir if path changed"
do
it
"moves dir if path changed"
do
new_path
=
@namespace
.
full_path
+
"_new"
@namespace
.
update_attributes
(
path:
@namespace
.
full_path
+
'_new'
)
allow
(
@namespace
).
to
receive
(
:full_path_was
).
and_return
(
@namespace
.
full_path
)
allow
(
@namespace
).
to
receive
(
:full_path
).
and_return
(
new_path
)
expect
(
gitlab_shell
.
exists?
(
@project
.
repository_storage_path
,
"
#{
@namespace
.
path
}
/
#{
@project
.
path
}
.git"
)).
to
be_truthy
expect
(
@namespace
).
to
receive
(
:remove_exports!
)
expect
(
@namespace
.
move_dir
).
to
be_truthy
end
end
context
"when any project has container images"
do
context
"when any project has container images"
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