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
a8d7e5a7
Commit
a8d7e5a7
authored
Dec 14, 2020
by
George Koltsov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Group Migration filtering
parent
d7840984
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
3 deletions
+42
-3
app/controllers/import/bulk_imports_controller.rb
app/controllers/import/bulk_imports_controller.rb
+22
-1
spec/controllers/import/bulk_imports_controller_spec.rb
spec/controllers/import/bulk_imports_controller_spec.rb
+19
-1
spec/features/groups/import_export/connect_instance_spec.rb
spec/features/groups/import_export/connect_instance_spec.rb
+1
-1
No files found.
app/controllers/import/bulk_imports_controller.rb
View file @
a8d7e5a7
# frozen_string_literal: true
class
Import::BulkImportsController
<
ApplicationController
include
ActionView
::
Helpers
::
SanitizeHelper
before_action
:ensure_group_import_enabled
before_action
:verify_blocked_uri
,
only: :status
...
...
@@ -43,7 +45,22 @@ class Import::BulkImportsController < ApplicationController
end
def
importable_data
client
.
get
(
'groups'
,
top_level_only:
true
).
parsed_response
client
.
get
(
'groups'
,
query_params
).
parsed_response
end
# Default query string params used to fetch groups from GitLab source instance
#
# top_level_only: fetch only top level groups (subgroups are fetched during import itself)
# min_access_level: fetch only groups user has maintainer or above permissions
# search: optional search param to search user's groups by a keyword
def
query_params
query_params
=
{
top_level_only:
true
,
min_access_level:
Gitlab
::
Access
::
MAINTAINER
}
query_params
[
:search
]
=
sanitized_filter_param
if
sanitized_filter_param
query_params
end
def
client
...
...
@@ -131,4 +148,8 @@ class Import::BulkImportsController < ApplicationController
access_token:
session
[
access_token_key
]
}
end
def
sanitized_filter_param
@filter
||=
sanitize
(
params
[
:filter
])
&
.
downcase
end
end
spec/controllers/import/bulk_imports_controller_spec.rb
View file @
a8d7e5a7
...
...
@@ -63,9 +63,16 @@ RSpec.describe Import::BulkImportsController do
)
end
let
(
:client_params
)
do
{
top_level_only:
true
,
min_access_level:
Gitlab
::
Access
::
MAINTAINER
}
end
before
do
allow
(
controller
).
to
receive
(
:client
).
and_return
(
client
)
allow
(
client
).
to
receive
(
:get
).
with
(
'groups'
,
top_level_only:
true
).
and_return
(
client_response
)
allow
(
client
).
to
receive
(
:get
).
with
(
'groups'
,
client_params
).
and_return
(
client_response
)
end
it
'returns serialized group data'
do
...
...
@@ -73,6 +80,17 @@ RSpec.describe Import::BulkImportsController do
expect
(
json_response
).
to
eq
({
importable_data:
client_response
.
parsed_response
}.
as_json
)
end
context
'when filtering'
do
it
'returns filtered result'
do
filter
=
'test'
search_params
=
client_params
.
merge
(
search:
filter
)
expect
(
client
).
to
receive
(
:get
).
with
(
'groups'
,
search_params
).
and_return
(
client_response
)
get
:status
,
format: :json
,
params:
{
filter:
filter
}
end
end
end
context
'when host url is local or not http'
do
...
...
spec/features/groups/import_export/connect_instance_spec.rb
View file @
a8d7e5a7
...
...
@@ -24,7 +24,7 @@ RSpec.describe 'Import/Export - Connect to another instance', :js do
pat
=
'demo-pat'
stub_path
=
'stub-group'
stub_request
(
:get
,
"%{url}/api/v4/groups?page=1&per_page=30&top_level_only=true"
%
{
url:
source_url
}).
to_return
(
stub_request
(
:get
,
"%{url}/api/v4/groups?page=1&per_page=30&top_level_only=true
&min_access_level=40
"
%
{
url:
source_url
}).
to_return
(
body:
[{
id:
2595438
,
web_url:
'https://gitlab.com/groups/auto-breakfast'
,
...
...
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