summaryrefslogtreecommitdiff
path: root/spec/requests/ci
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2016-11-21 20:22:55 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2016-11-21 20:22:55 +0000
commit3c8d2148fc81cf75af322744221a0ff284216988 (patch)
treee9bc950f5b5c8b2515fd1ce52abb2e92662e272f /spec/requests/ci
parent3e3b2fab28af3412032be05252ae7868610346b2 (diff)
parent461195665b22291d5e57287efc0567b89a9ee262 (diff)
downloadgitlab-ce-3c8d2148fc81cf75af322744221a0ff284216988.tar.gz
Merge branch 'feature/send-registry-address-with-build-payload' into 'master'
Send registry address with build payload ## What does this MR do? Adds `registry_url` as a part of a build payload, when sending a response to a GitLab Runner which requested a new build. ## Are there points in the code the reviewer needs to double check? Change in `lib/ci/api/entities.rb`. ## Why was this MR needed? This is one of the steps needed to add support for private/protected registries hosted with GitLab CE/EE. ## Screenshots (if relevant) ## Does this MR meet the acceptance criteria? - [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added - [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [x] API support added - Tests - [x] Added for this feature/bug - [ ] All builds are passing - [ ] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html) - [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [ ] Branch has no merge conflicts with `master` (if it does - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) ## What are the relevant issue numbers? Related to gitlab-org/gitlab-ci-multi-runner#1828, gitlab-org/gitlab-ci-multi-runner!386, gitlab-org/gitlab-ci-multi-runner#1434 See merge request !7474
Diffstat (limited to 'spec/requests/ci')
-rw-r--r--spec/requests/ci/api/builds_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb
index a611c5e3823..a09d8689ff2 100644
--- a/spec/requests/ci/api/builds_spec.rb
+++ b/spec/requests/ci/api/builds_spec.rb
@@ -17,6 +17,10 @@ describe Ci::API::API do
let!(:build) { create(:ci_build, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
let(:user_agent) { 'gitlab-ci-multi-runner 1.5.2 (1-5-stable; go1.6.3; linux/amd64)' }
+ before do
+ stub_container_registry_config(enabled: false)
+ end
+
shared_examples 'no builds available' do
context 'when runner sends version in User-Agent' do
context 'for stable version' do
@@ -53,6 +57,41 @@ describe Ci::API::API do
it 'updates runner info' do
expect { register_builds }.to change { runner.reload.contacted_at }
end
+
+ context 'registry credentials' do
+ let(:registry_credentials) do
+ { 'type' => 'registry',
+ 'url' => 'registry.example.com:5005',
+ 'username' => 'gitlab-ci-token',
+ 'password' => build.token }
+ end
+
+ context 'when registry is enabled' do
+ before do
+ stub_container_registry_config(enabled: true, host_port: 'registry.example.com:5005')
+ end
+
+ it 'sends registry credentials key' do
+ register_builds info: { platform: :darwin }
+
+ expect(json_response).to have_key('credentials')
+ expect(json_response['credentials']).to include(registry_credentials)
+ end
+ end
+
+ context 'when registry is disabled' do
+ before do
+ stub_container_registry_config(enabled: false, host_port: 'registry.example.com:5005')
+ end
+
+ it 'does not send registry credentials' do
+ register_builds info: { platform: :darwin }
+
+ expect(json_response).to have_key('credentials')
+ expect(json_response['credentials']).not_to include(registry_credentials)
+ end
+ end
+ end
end
context 'when builds are finished' do