Skip to content

Commit

Permalink
[api] do not allow to create maintenance_release request, when releas…
Browse files Browse the repository at this point in the history
…e_target is not defined
  • Loading branch information
adrianschroeter committed Oct 27, 2011
1 parent abed521 commit ffe09ff
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/api/app/controllers/request_controller.rb
Expand Up @@ -477,6 +477,18 @@ def create_create
end
end

if action.value("type") == "maintenance_release"
# get sure that the releasetarget definition exists or we release without binaries
prj = DbProject.get_by_name(action.source.project)
prj.repositories.each do |repo|
unless repo.release_targets.count > 0
render_error :status => 404, :errorcode => "repository_without_releasetarget",
:message => "Release target definition is missing in #{prj.name} / #{repo.name}"
return
end
end
end

# source update checks
#FIXME2.3: support this also for maintenance requests
if action.value("type") == "submit"
Expand Down
25 changes: 25 additions & 0 deletions src/api/test/functional/maintenance_test.rb
Expand Up @@ -497,6 +497,31 @@ def test_create_maintenance_project_and_release_packages
assert_response :success
end

def test_create_invalid_release_request
prepare_request_with_user "tom", "thunder"
# branch a package with simple branch command (not mbranch)
post "/source/BaseDistro/pack1", :cmd => :branch
assert_response :success
# check source link
get "/source/home:tom:branches:BaseDistro:Update/pack1/_link"
assert_response :success

prepare_request_with_user "maintenance_coord", "power"
post "/request?cmd=create", '<request>
<action type="maintenance_release">
<source project="home:tom:branches:BaseDistro:Update" />
</action>
<state name="new" />
</request>'
assert_response 404
assert_tag :tag => "status", :attributes => { :code => "repository_without_releasetarget" }

# cleanup
prepare_request_with_user "tom", "thunder"
delete "/source/home:tom:branches:BaseDistro:Update"
assert_response :success
end

def test_try_to_release_without_permissions_binary_permissions
prepare_request_with_user "tom", "thunder"
# create project
Expand Down

0 comments on commit ffe09ff

Please sign in to comment.