Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[match] Fixes Gitlab Secure Files API limit #21361

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions match/lib/match/storage/gitlab/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def authentication_value
def files
@files ||= begin
url = URI.parse(base_url)
# 100 is maximum number of Secure files available on Gitlab https://docs.gitlab.com/ee/api/secure_files.html
url.query = [url.query, "per_page=100"].compact.join('&')

request = Net::HTTP::Get.new(url.request_uri)

Expand Down
9 changes: 9 additions & 0 deletions match/spec/storage/gitlab/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@
expect(subject.files.count).to be(0)
end

it 'requests 100 files from the API' do
stub_request(:get, /gitlab.example.com/).
to_return(status: 200, body: [].to_json)

files = subject.files

assert_requested(:get, /gitlab.example.com/, query: "per_page=100")
end

it 'raises an exception for a non-json response' do
stub_request(:get, /gitlab.example.com/).
with(headers: { 'PRIVATE-TOKEN' => 'abc123' }).
Expand Down