summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2018-04-05 12:22:34 -0500
committerMayra Cabrera <mcabrera@gitlab.com>2018-04-06 21:20:16 -0500
commit8315861c9a50675b4f4f4ca536f0da90f27994f3 (patch)
treeb5f25e5dbd74621ef77d480ba69f4f21d5c00d7d /spec/services
parent72220a99d1cdbcf8a914f9e765c43e63eaee2548 (diff)
downloadgitlab-ce-8315861c9a50675b4f4f4ca536f0da90f27994f3.tar.gz
Include ProjectDeployTokens
Also: - Changes scopes from serializer to use boolean columns - Fixes broken specs
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/auth/container_registry_authentication_service_spec.rb1
-rw-r--r--spec/services/deploy_tokens/create_service_spec.rb30
2 files changed, 20 insertions, 11 deletions
diff --git a/spec/services/auth/container_registry_authentication_service_spec.rb b/spec/services/auth/container_registry_authentication_service_spec.rb
index 290eeae828e..0949ec24c50 100644
--- a/spec/services/auth/container_registry_authentication_service_spec.rb
+++ b/spec/services/auth/container_registry_authentication_service_spec.rb
@@ -558,6 +558,7 @@ describe Auth::ContainerRegistryAuthenticationService do
let(:project) { create(:project, :public) }
context 'when pulling and pushing' do
+ let(:current_user) { create(:deploy_token, projects: [project]) }
let(:current_params) do
{ scope: "repository:#{project.full_path}:pull,push" }
end
diff --git a/spec/services/deploy_tokens/create_service_spec.rb b/spec/services/deploy_tokens/create_service_spec.rb
index df18213cf84..4830f17faa8 100644
--- a/spec/services/deploy_tokens/create_service_spec.rb
+++ b/spec/services/deploy_tokens/create_service_spec.rb
@@ -13,42 +13,50 @@ describe DeployTokens::CreateService, :clean_gitlab_redis_shared_state do
expect { subject }.to change { DeployToken.count }.by(1)
end
- it 'returns a DeployToken' do
- expect(subject).to be_an_instance_of DeployToken
+ it 'should create a new ProjectDeployToken' do
+ expect { subject }.to change { ProjectDeployToken.count }.by(1)
end
- it 'should assign the DeployToken to the project' do
- expect(subject.project).to eq(project)
+ it 'returns a DeployToken' do
+ expect(subject).to be_an_instance_of DeployToken
end
it 'should store the token on redis' do
- redis_key = subject.redis_shared_state_key(user.id)
+ redis_key = DeployToken.redis_shared_state_key(user.id)
+ subject
expect(Gitlab::Redis::SharedState.with { |redis| redis.get(redis_key) }).not_to be_nil
end
- it 'should not store deploy token attributes on redis' do
- redis_key = subject.redis_shared_state_key(user.id) + ":attributes"
+ it 'should not store deploy token attributes on redis' do
+ redis_key = DeployToken.redis_shared_state_key(user.id) + ":attributes"
+ subject
expect(Gitlab::Redis::SharedState.with { |redis| redis.get(redis_key) }).to be_nil
end
end
context 'when the deploy token is invalid' do
- let(:deploy_token_params) { attributes_for(:deploy_token, scopes: []) }
+ let(:deploy_token_params) { attributes_for(:deploy_token, read_repository: false, read_registry: false) }
- it 'it should not create a new DeployToken' do
+ it 'should not create a new DeployToken' do
expect { subject }.not_to change { DeployToken.count }
end
+ it 'should not create a new ProjectDeployToken' do
+ expect { subject }.not_to change { ProjectDeployToken.count }
+ end
+
it 'should not store the token on redis' do
- redis_key = subject.redis_shared_state_key(user.id)
+ redis_key = DeployToken.redis_shared_state_key(user.id)
+ subject
expect(Gitlab::Redis::SharedState.with { |redis| redis.get(redis_key) }).to be_nil
end
it 'should store deploy token attributes on redis' do
- redis_key = subject.redis_shared_state_key(user.id) + ":attributes"
+ redis_key = DeployToken.redis_shared_state_key(user.id) + ":attributes"
+ subject
expect(Gitlab::Redis::SharedState.with { |redis| redis.get(redis_key) }).not_to be_nil
end