Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-12 15:09:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-12 15:09:17 +0300
commitcd52759ee33051b8ad7b88b02ba7954e4fad7018 (patch)
treef1096c68e457aef7f5201acd16e4a751ff538026 /spec/requests/api/deploy_tokens_spec.rb
parent18f7828977b74bf6e5153594a098ef90e773b3b7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/deploy_tokens_spec.rb')
-rw-r--r--spec/requests/api/deploy_tokens_spec.rb71
1 files changed, 59 insertions, 12 deletions
diff --git a/spec/requests/api/deploy_tokens_spec.rb b/spec/requests/api/deploy_tokens_spec.rb
index fa46b8017cb..fa20635056f 100644
--- a/spec/requests/api/deploy_tokens_spec.rb
+++ b/spec/requests/api/deploy_tokens_spec.rb
@@ -148,21 +148,21 @@ describe API::DeployTokens do
end
end
- describe 'DELETE /groups/:id/deploy_tokens/:token_id' do
+ describe 'DELETE /projects/:id/deploy_tokens/:token_id' do
subject do
- delete api("/groups/#{group.id}/deploy_tokens/#{group_deploy_token.id}", user)
+ delete api("/projects/#{project.id}/deploy_tokens/#{deploy_token.id}", user)
response
end
context 'when unauthenticated' do
let(:user) { nil }
- it { is_expected.to have_gitlab_http_status(:forbidden) }
+ it { is_expected.to have_gitlab_http_status(:not_found) }
end
context 'when authenticated as non-admin user' do
before do
- group.add_developer(user)
+ project.add_developer(user)
end
it { is_expected.to have_gitlab_http_status(:forbidden) }
@@ -170,26 +170,26 @@ describe API::DeployTokens do
context 'when authenticated as maintainer' do
before do
- group.add_maintainer(user)
+ project.add_maintainer(user)
end
- it 'deletes the deploy token' do
- expect { subject }.to change { group.deploy_tokens.count }.by(-1)
+ it { is_expected.to have_gitlab_http_status(:no_content) }
- expect(group.deploy_tokens).to be_empty
+ it 'deletes the deploy token' do
+ expect { subject }.to change { project.deploy_tokens.count }.by(-1)
end
context 'invalid request' do
it 'returns not found with invalid group id' do
- delete api("/groups/bad_id/deploy_tokens/#{group_deploy_token.id}", user)
+ delete api("/projects/bad_id/deploy_tokens/#{group_deploy_token.id}", user)
expect(response).to have_gitlab_http_status(:not_found)
end
- it 'returns not found with invalid deploy token id' do
- delete api("/groups/#{group.id}/deploy_tokens/bad_id", user)
+ it 'returns bad_request with invalid token id' do
+ delete api("/projects/#{project.id}/deploy_tokens/123abc", user)
- expect(response).to have_gitlab_http_status(:not_found)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
@@ -262,4 +262,51 @@ describe API::DeployTokens do
it_behaves_like 'creating a deploy token', :group, :forbidden
end
end
+
+ describe 'DELETE /groups/:id/deploy_tokens/:token_id' do
+ subject do
+ delete api("/groups/#{group.id}/deploy_tokens/#{group_deploy_token.id}", user)
+ response
+ end
+
+ context 'when unauthenticated' do
+ let(:user) { nil }
+
+ it { is_expected.to have_gitlab_http_status(:forbidden) }
+ end
+
+ context 'when authenticated as non-admin user' do
+ before do
+ group.add_developer(user)
+ end
+
+ it { is_expected.to have_gitlab_http_status(:forbidden) }
+ end
+
+ context 'when authenticated as maintainer' do
+ before do
+ group.add_maintainer(user)
+ end
+
+ it 'deletes the deploy token' do
+ expect { subject }.to change { group.deploy_tokens.count }.by(-1)
+
+ expect(group.deploy_tokens).to be_empty
+ end
+
+ context 'invalid request' do
+ it 'returns bad request with invalid group id' do
+ delete api("/groups/bad_id/deploy_tokens/#{group_deploy_token.id}", user)
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+
+ it 'returns not found with invalid deploy token id' do
+ delete api("/groups/#{group.id}/deploy_tokens/bad_id", user)
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+ end
+ end
end