diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2018-04-16 15:47:35 -0500 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2018-04-20 12:18:41 -0500 |
commit | 0903456a0704bd5c4e594c423f0325b29cd99013 (patch) | |
tree | 291e585e1afdbb6857c6d4a49d71a124c4a4e82c /spec/models/project_spec.rb | |
parent | 3c3cab8b329ce83ae7d1c669a6933dcb16fcd552 (diff) | |
download | gitlab-ce-0903456a0704bd5c4e594c423f0325b29cd99013.tar.gz |
Expose deploy token to CI/CD jobs as environment variable
- If a deploy token with a name 'gitlab-deploy-token' is exists for the
project, CI_DEPLOY_USER and CI_DEPLOY_PASSWORD variables will be
expose
Diffstat (limited to 'spec/models/project_spec.rb')
-rw-r--r-- | spec/models/project_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 2675c2f52c1..86ad80106af 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -3585,4 +3585,31 @@ describe Project do it { is_expected.not_to be_valid } end end + + describe '#gitlab_deploy_token' do + let(:project) { create(:project) } + + subject { project.gitlab_deploy_token } + + context 'when there is a gitlab deploy token associated' do + let!(:deploy_token) { create(:deploy_token, :gitlab_deploy_token, projects: [project]) } + + it { is_expected.to eq(deploy_token) } + end + + context 'when there is no a gitlab deploy token associated' do + it { is_expected.to be_nil } + end + + context 'when there is a gitlab deploy token associated but is has been revoked' do + let!(:deploy_token) { create(:deploy_token, :gitlab_deploy_token, :revoked, projects: [project]) } + it { is_expected.to be_nil } + end + + context 'when there is a gitlab deploy token associated but it has expired' do + let!(:deploy_token) { create(:deploy_token, :gitlab_deploy_token, :expired, projects: [project]) } + + it { is_expected.to be_nil } + end + end end |