BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
fa7f409f
Commit
fa7f409f
authored
Mar 21, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sh-fix-issue-29739' into 'master'
Fix Error 500 when Bitbucket importer does not have authorization Closes #29739 See merge request !10105
parents
fc830c6f
07415e47
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
bitbucket_controller.rb
app/controllers/import/bitbucket_controller.rb
+4
-4
bitbucket_controller_spec.rb
spec/controllers/import/bitbucket_controller_spec.rb
+11
-0
No files found.
app/controllers/import/bitbucket_controller.rb
View file @
fa7f409f
...
...
@@ -44,15 +44,15 @@ class Import::BitbucketController < Import::BaseController
repo_owner
=
repo
.
owner
repo_owner
=
current_user
.
username
if
repo_owner
==
bitbucket_client
.
user
.
username
@target_namespace
=
params
[
:new_namespace
].
presence
||
repo_owner
namespace_path
=
params
[
:new_namespace
].
presence
||
repo_owner
namespace
=
find_or_create_namespace
(
@target_namespace
,
current_user
)
@target_namespace
=
find_or_create_namespace
(
namespace_path
,
current_user
)
if
current_user
.
can?
(
:create_projects
,
namespace
)
if
current_user
.
can?
(
:create_projects
,
@target_
namespace
)
# The token in a session can be expired, we need to get most recent one because
# Bitbucket::Connection class refreshes it.
session
[
:bitbucket_token
]
=
bitbucket_client
.
connection
.
token
@project
=
Gitlab
::
BitbucketImport
::
ProjectCreator
.
new
(
repo
,
@project_name
,
namespace
,
current_user
,
credentials
).
execute
@project
=
Gitlab
::
BitbucketImport
::
ProjectCreator
.
new
(
repo
,
@project_name
,
@target_
namespace
,
current_user
,
credentials
).
execute
else
render
'unauthorized'
end
...
...
spec/controllers/import/bitbucket_controller_spec.rb
View file @
fa7f409f
...
...
@@ -112,6 +112,17 @@ describe Import::BitbucketController do
post
:create
,
format: :js
end
end
context
'when the Bitbucket user is unauthorized'
do
render_views
it
'returns unauthorized'
do
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
user
).
to
receive
(
:can?
).
and_return
(
false
)
post
:create
,
format: :js
end
end
end
context
"when the repository owner is not the Bitbucket user"
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