2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-15 11:31:14 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 23:08:05 -04:00
|
|
|
RSpec.describe Import::GiteaController do
|
2016-12-15 11:31:14 -05:00
|
|
|
include ImportSpecHelper
|
|
|
|
|
|
|
|
let(:provider) { :gitea }
|
|
|
|
let(:host_url) { 'https://try.gitea.io' }
|
|
|
|
|
|
|
|
include_context 'a GitHub-ish import controller'
|
|
|
|
|
|
|
|
def assign_host_url
|
2016-12-16 11:43:34 -05:00
|
|
|
session[:gitea_host_url] = host_url
|
2016-12-15 11:31:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET new" do
|
|
|
|
it_behaves_like 'a GitHub-ish import controller: GET new' do
|
|
|
|
before do
|
|
|
|
assign_host_url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "POST personal_access_token" do
|
|
|
|
it_behaves_like 'a GitHub-ish import controller: POST personal_access_token'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET status" do
|
|
|
|
it_behaves_like 'a GitHub-ish import controller: GET status' do
|
2020-03-05 10:07:52 -05:00
|
|
|
let(:extra_assign_expectations) { { gitea_host_url: host_url } }
|
|
|
|
|
2016-12-15 11:31:14 -05:00
|
|
|
before do
|
|
|
|
assign_host_url
|
|
|
|
end
|
2020-03-05 10:07:52 -05:00
|
|
|
|
2020-08-11 08:09:55 -04:00
|
|
|
it "requests provider repos list" do
|
|
|
|
expect(stub_client(repos: [], orgs: [])).to receive(:repos)
|
|
|
|
|
|
|
|
get :status
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
end
|
|
|
|
|
2020-03-05 10:07:52 -05:00
|
|
|
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 }
|
|
|
|
|
|
|
|
it 'denies network request' do
|
|
|
|
get :status, format: :json
|
|
|
|
|
|
|
|
expect(controller).to redirect_to(new_import_url)
|
2020-04-06 20:09:33 -04:00
|
|
|
expect(flash[:alert]).to eq('Specified URL cannot be used: "Only allowed schemes are http, https"')
|
2020-03-05 10:07:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-12-15 11:31:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'POST create' do
|
|
|
|
it_behaves_like 'a GitHub-ish import controller: POST create' do
|
|
|
|
before do
|
|
|
|
assign_host_url
|
|
|
|
end
|
|
|
|
end
|
2020-01-23 19:08:51 -05:00
|
|
|
|
|
|
|
it_behaves_like 'project import rate limiter'
|
2016-12-15 11:31:14 -05:00
|
|
|
end
|
2018-11-07 11:44:21 -05:00
|
|
|
|
|
|
|
describe "GET realtime_changes" do
|
|
|
|
it_behaves_like 'a GitHub-ish import controller: GET realtime_changes' do
|
|
|
|
before do
|
|
|
|
assign_host_url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-12-15 11:31:14 -05:00
|
|
|
end
|