2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe LfsRequest do
|
2018-03-17 18:26:18 +05:30
|
|
|
include ProjectForksHelper
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
controller(Repositories::GitHttpClientController) do
|
2018-03-17 18:26:18 +05:30
|
|
|
# `described_class` is not available in this context
|
2020-03-13 15:44:24 +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 }
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:forbidden)
|
2019-10-31 01:37:42 +05:30
|
|
|
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' }
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2019-10-31 01:37:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'project is private' do
|
|
|
|
let(:project) { create(:project, :private) }
|
|
|
|
|
|
|
|
it 'returns 404' do
|
|
|
|
get :show, params: { id: project.id }
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2019-10-31 01:37:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|