Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/import/gitea_controller_spec.rb')
-rw-r--r--spec/controllers/import/gitea_controller_spec.rb26
1 files changed, 17 insertions, 9 deletions
diff --git a/spec/controllers/import/gitea_controller_spec.rb b/spec/controllers/import/gitea_controller_spec.rb
index 568712d29cb..3dfda909a93 100644
--- a/spec/controllers/import/gitea_controller_spec.rb
+++ b/spec/controllers/import/gitea_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Import::GiteaController do
+RSpec.describe Import::GiteaController, feature_category: :importers do
include ImportSpecHelper
let(:provider) { :gitea }
@@ -10,6 +10,10 @@ RSpec.describe Import::GiteaController do
include_context 'a GitHub-ish import controller'
+ before do
+ stub_application_setting(import_sources: ['gitea'])
+ end
+
def assign_host_url
session[:gitea_host_url] = host_url
end
@@ -42,19 +46,23 @@ RSpec.describe Import::GiteaController do
expect(response).to have_gitlab_http_status(:ok)
end
- context 'when host url is local or not http' do
- %w[https://localhost:3000 http://192.168.0.1 ftp://testing].each do |url|
- let(:host_url) { url }
+ shared_examples "unacceptable url" do |url, expected_error|
+ let(:host_url) { url }
- it 'denies network request' do
- get :status, format: :json
+ it 'denies network request' do
+ get :status, format: :json
- expect(controller).to redirect_to(new_import_url)
- expect(flash[:alert]).to eq('Specified URL cannot be used: "Only allowed schemes are http, https"')
- end
+ expect(controller).to redirect_to(new_import_url)
+ expect(flash[:alert]).to eq("Specified URL cannot be used: \"#{expected_error}\"")
end
end
+ context 'when host url is local or not http' do
+ include_examples 'unacceptable url', 'https://localhost:3000', 'Only allowed schemes are http, https'
+ include_examples 'unacceptable url', 'http://192.168.0.1', 'Only allowed schemes are http, https'
+ include_examples 'unacceptable url', 'ftp://testing', 'Only allowed schemes are http, https'
+ end
+
context 'when DNS Rebinding protection is enabled' do
let(:token) { 'gitea token' }