Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.0 on 2022-01-18 at 14:00 UTC+1 (a few minutes of down time)

Commit 26628fb9 authored by Valery Sizov's avatar Valery Sizov
Browse files

BB importer: Fixed bug with putting expired token to a project.clone_url

parent 6524c3e978ef
......@@ -49,6 +49,9 @@ def create
namespace = find_or_create_namespace(@target_namespace, current_user)
if current_user.can?(:create_projects, 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
else
render 'unauthorized'
......
module Bitbucket
class Client
attr_reader :connection
def initialize(options = {})
@connection = Connection.new(options)
end
......@@ -48,8 +50,6 @@ def user
private
attr_reader :connection
def get_collection(path, type)
paginator = Paginator.new(connection, path, type)
Collection.new(paginator)
......
......@@ -4,6 +4,8 @@ class Connection
DEFAULT_BASE_URI = 'https://api.bitbucket.org/'
DEFAULT_QUERY = {}
attr_reader :expires_at, :expires_in, :refresh_token, :token
def initialize(options = {})
@api_version = options.fetch(:api_version, DEFAULT_API_VERSION)
@base_uri = options.fetch(:base_uri, DEFAULT_BASE_URI)
......@@ -38,8 +40,6 @@ def refresh!
private
attr_reader :expires_at, :expires_in, :refresh_token, :token
def client
@client ||= OAuth2::Client.new(provider.app_id, provider.app_secret, options)
end
......
......@@ -21,7 +21,7 @@ def execute
visibility_level: repo.visibility_level,
import_type: 'bitbucket',
import_source: repo.full_name,
import_url: repo.clone_url(@session_data[:token]),
import_url: repo.clone_url(session_data[:token]),
import_data: { credentials: session_data }
).execute
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment