2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe LfsRequest do
|
|
|
|
include ProjectForksHelper
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
controller(Repositories::GitHttpClientController) do
|
2018-03-17 18:26:18 +05:30
|
|
|
# `described_class` is not available in this context
|
2020-03-09 13:42:32 +05:30
|
|
|
include LfsRequest
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
def show
|
2019-02-15 15:39:39 +05:30
|
|
|
head :ok
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def project
|
2019-10-31 01:37:42 +05:30
|
|
|
@project ||= Project.find_by(id: params[:id])
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def download_request?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2019-10-31 01:37:42 +05:30
|
|
|
def upload_request?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def ci?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_lfs_setting(enabled: true)
|
|
|
|
end
|
|
|
|
|
2019-10-31 01:37:42 +05:30
|
|
|
context 'user is authenticated without access to lfs' do
|
|
|
|
before do
|
|
|
|
allow(controller).to receive(:authenticate_user)
|
|
|
|
allow(controller).to receive(:authentication_result) do
|
|
|
|
Gitlab::Auth::Result.new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with access to the project' do
|
|
|
|
it 'returns 403' do
|
|
|
|
get :show, params: { id: project.id }
|
|
|
|
|
|
|
|
expect(response.status).to eq(403)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without access to the project' do
|
|
|
|
context 'project does not exist' do
|
|
|
|
it 'returns 404' do
|
|
|
|
get :show, params: { id: 'does not exist' }
|
|
|
|
|
|
|
|
expect(response.status).to eq(404)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'project is private' do
|
|
|
|
let(:project) { create(:project, :private) }
|
|
|
|
|
|
|
|
it 'returns 404' do
|
|
|
|
get :show, params: { id: project.id }
|
|
|
|
|
|
|
|
expect(response.status).to eq(404)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|