Skip to content
Snippets Groups Projects
Commit 72e68394 authored by Illya Klymov's avatar Illya Klymov :rocket:
Browse files

Respect namespace_id for bitbucket server importer

Always pass namespace_id to status page of bitbucket server importer

Changelog: fixed
parent b7333a6c
No related branches found
No related tags found
1 merge request!90830Respect namespace_id for bitbucket server importer
......@@ -49,7 +49,7 @@ def configure
session[bitbucket_server_username_key] = params[:bitbucket_server_username]
session[bitbucket_server_url_key] = params[:bitbucket_server_url]
redirect_to status_import_bitbucket_server_path
redirect_to status_import_bitbucket_server_path(namespace_id: params[:namespace_id])
end
# We need to re-expose controller's internal method 'status' as action.
......@@ -115,7 +115,7 @@ def bitbucket_auth
unless session[bitbucket_server_url_key].present? &&
session[bitbucket_server_username_key].present? &&
session[personal_access_token_key].present?
redirect_to new_import_bitbucket_server_path
redirect_to new_import_bitbucket_server_path(namespace_id: params[:namespace_id])
end
end
......@@ -170,9 +170,6 @@ def bitbucket_connection_error(error)
}
}, status: :unprocessable_entity
end
format.html do
redirect_to new_import_bitbucket_server_path
end
end
end
end
......@@ -10,7 +10,7 @@
%p
= _('Enter in your Bitbucket Server URL and personal access token below')
= form_tag configure_import_bitbucket_server_path, method: :post do
= form_tag configure_import_bitbucket_server_path(namespace_id: params[:namespace_id]), method: :post do
.form-group.row
= label_tag :bitbucket_server_url, 'Bitbucket Server URL', class: 'col-form-label col-md-2'
.col-md-4
......
......@@ -5,4 +5,4 @@
= sprite_icon('bitbucket', css_class: 'gl-mr-2')
= _('Import projects from Bitbucket Server')
= render 'import/githubish_status', provider: 'bitbucket_server', paginatable: true, extra_data: { reconfigure_path: configure_import_bitbucket_server_path }
= render 'import/githubish_status', provider: 'bitbucket_server', paginatable: true, default_namespace: @namespace, extra_data: { reconfigure_path: configure_import_bitbucket_server_path }
......@@ -31,7 +31,7 @@
Bitbucket Cloud
- if bitbucket_server_import_enabled?
%div
= link_to status_import_bitbucket_server_path, class: "gl-button btn-default btn import_bitbucket js-import-project-btn", data: { platform: 'bitbucket_server', **tracking_attrs_data(track_label, 'click_button', 'bitbucket_server') } do
= link_to status_import_bitbucket_server_path(namespace_id: namespace_id), class: "gl-button btn-default btn import_bitbucket js-import-project-btn", data: { platform: 'bitbucket_server', **tracking_attrs_data(track_label, 'click_button', 'bitbucket_server') } do
.gl-button-icon
= sprite_icon('bitbucket')
Bitbucket Server
......
......@@ -134,6 +134,15 @@ def assign_session_tokens
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(status_import_bitbucket_server_path)
end
it 'passes namespace_id to status page if provided' do
namespace_id = 5
allow(controller).to receive(:allow_local_requests?).and_return(true)
post :configure, params: { personal_access_token: token, bitbucket_server_username: username, bitbucket_server_url: url, namespace_id: namespace_id }
expect(response).to redirect_to(status_import_bitbucket_server_path(namespace_id: namespace_id))
end
end
describe 'GET status' do
......@@ -160,6 +169,14 @@ def assign_session_tokens
expect(json_response.dig("provider_repos", 0, "id")).to eq(@repo.full_name)
end
it 'redirects to connection form if session is missing auth data' do
session[:bitbucket_server_url] = nil
get :status, format: :html
expect(response).to redirect_to(new_import_bitbucket_server_path)
end
it_behaves_like 'import controller status' do
let(:repo) { @repo }
let(:repo_id) { "#{@repo.project_key}/#{@repo.slug}" }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment