Skip to content

Commit

Permalink
[match] Fixes Gitlab Secure Files API limit (#21361)
Browse files Browse the repository at this point in the history
Co-authored-by: Darby Frey <dfrey@gitlab.com>
  • Loading branch information
darbyfrey and Darby Frey committed Jul 4, 2023
1 parent ba801c7 commit 37f2f6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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

0 comments on commit 37f2f6c

Please sign in to comment.