diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2018-04-10 07:31:30 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2018-04-10 07:31:30 +0000 |
commit | 3e35f65394fad201a9277667772f3ad9c6940d07 (patch) | |
tree | a29edb1313437b8a242d01142a8a00c94dc6cd2f /spec/models | |
parent | bc841c7db9c37f6ea91911cb921db07608d8bdec (diff) | |
download | gitlab-ce-3e35f65394fad201a9277667772f3ad9c6940d07.tar.gz |
Verify that deploy token has valid access when pulling container registry image
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/deploy_token_spec.rb | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/spec/models/deploy_token_spec.rb b/spec/models/deploy_token_spec.rb index 5a15c23def4..780b200e837 100644 --- a/spec/models/deploy_token_spec.rb +++ b/spec/models/deploy_token_spec.rb @@ -78,19 +78,30 @@ describe DeployToken do describe '#has_access_to?' do let(:project) { create(:project) } - subject(:deploy_token) { create(:deploy_token, projects: [project]) } + subject { deploy_token.has_access_to?(project) } - context 'when the deploy token has access to the project' do - it 'should return true' do - expect(deploy_token.has_access_to?(project)).to be_truthy - end + context 'when deploy token is active and related to project' do + let(:deploy_token) { create(:deploy_token, projects: [project]) } + + it { is_expected.to be_truthy } end - context 'when the deploy token does not have access to the project' do - it 'should return false' do - another_project = create(:project) - expect(deploy_token.has_access_to?(another_project)).to be_falsy - end + context 'when deploy token is active but not related to project' do + let(:deploy_token) { create(:deploy_token) } + + it { is_expected.to be_falsy } + end + + context 'when deploy token is revoked and related to project' do + let(:deploy_token) { create(:deploy_token, :revoked, projects: [project]) } + + it { is_expected.to be_falsy } + end + + context 'when deploy token is revoked and not related to the project' do + let(:deploy_token) { create(:deploy_token, :revoked) } + + it { is_expected.to be_falsy } end end |