summaryrefslogtreecommitdiff
path: root/lib/ci/api/helpers.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2016-12-20 07:18:13 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2016-12-20 07:18:13 +0000
commitc1dbae90033c10bef1aaa3c5c34219c1d0e5ef61 (patch)
tree630974975271ba487ed99324098445c835483bce /lib/ci/api/helpers.rb
parentf8262e8533866306bb0ddce71546b159341fd5bc (diff)
parent18c9fc42249a08ff28cf9d5b9159b7bada168bcf (diff)
downloadgitlab-ce-c1dbae90033c10bef1aaa3c5c34219c1d0e5ef61.tar.gz
Merge branch 'fix-forbidden-for-build-api-for-deleted-project' into 'master'
Give forbidden if project for the build was deleted I guess we don't need a change log entry because this is just for an internal corner case fix. Closes #25309 See merge request !8091
Diffstat (limited to 'lib/ci/api/helpers.rb')
-rw-r--r--lib/ci/api/helpers.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/ci/api/helpers.rb b/lib/ci/api/helpers.rb
index e608f5f6cad..31fbd1da108 100644
--- a/lib/ci/api/helpers.rb
+++ b/lib/ci/api/helpers.rb
@@ -13,8 +13,19 @@ module Ci
forbidden! unless current_runner
end
- def authenticate_build_token!(build)
- forbidden! unless build_token_valid?(build)
+ def authenticate_build!(build)
+ validate_build!(build) do
+ forbidden! unless build_token_valid?(build)
+ end
+ end
+
+ def validate_build!(build)
+ not_found! unless build
+
+ yield if block_given?
+
+ forbidden!('Project has been deleted!') unless build.project
+ forbidden!('Build has been erased!') if build.erased?
end
def runner_registration_token_valid?