Commit 9267a9b1 authored by Tomasz Maczukin's avatar Tomasz Maczukin Committed by Kamil Trzcinski

Send token of depenent job

Artifacts download for authorization is using a job token of job to
which the artifact belongs. In APIv1 the token was sent with dependent
jobs details and in APIv4 it was designed to also contain it.

However I forgot about this parameter while working on
`/api/v4/jobs/request` endpoint.

This commit adds a missing parameter which is required for APIv4 to work
properly.
parent e79ab111
...@@ -768,7 +768,7 @@ module API ...@@ -768,7 +768,7 @@ module API
end end
class Dependency < Grape::Entity class Dependency < Grape::Entity
expose :id, :name expose :id, :name, :token
expose :artifacts_file, using: ArtifactFile, if: ->(job, _) { job.artifacts? } expose :artifacts_file, using: ArtifactFile, if: ->(job, _) { job.artifacts? }
end end
......
...@@ -417,7 +417,8 @@ describe API::Runner do ...@@ -417,7 +417,8 @@ describe API::Runner do
end end
context 'when project and pipeline have multiple jobs' do context 'when project and pipeline have multiple jobs' do
let!(:test_job) { create(:ci_build, pipeline: pipeline, name: 'deploy', stage: 'deploy', stage_idx: 1) } let!(:job) { create(:ci_build_tag, pipeline: pipeline, token: 'job-token', name: 'spinach', stage: 'test', stage_idx: 0) }
let!(:test_job) { create(:ci_build, pipeline: pipeline, token: 'test-job-token', name: 'deploy', stage: 'deploy', stage_idx: 1) }
before { job.success } before { job.success }
...@@ -427,7 +428,7 @@ describe API::Runner do ...@@ -427,7 +428,7 @@ describe API::Runner do
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['id']).to eq(test_job.id) expect(json_response['id']).to eq(test_job.id)
expect(json_response['dependencies'].count).to eq(1) expect(json_response['dependencies'].count).to eq(1)
expect(json_response['dependencies'][0]).to include('id' => job.id, 'name' => 'spinach') expect(json_response['dependencies'][0]).to include('id' => job.id, 'name' => 'spinach', 'token' => job.token)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment