Skip to content

Commit

Permalink
Add test cases for the request creation API
Browse files Browse the repository at this point in the history
test if a regular user is able to set an approver if he isnt admin
test if admins are able to set any approver

Co-authored-by: Marcus Hüwe <suse-tux@gmx.de>
  • Loading branch information
2 people authored and coolo committed Nov 14, 2018
1 parent ec0e297 commit 88378eb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/api/test/functional/request_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,36 @@ def test_create_request_approve_and_review
assert_equal id, first_node['requestid']
end

def test_create_request_with_approver
req_template = <<~XML_REQUEST
<request>
<action type="submit">
<source project="home:Iggy" package="TestPack" rev="1"/>
<target project="home:fred" package="foopkg"/>
</action>
<review by_group="test_group"/>
<state approver="%<approver>s"/>
</request>
XML_REQUEST

login_Iggy
# request creation fails because we are not admin
post '/request?cmd=create', params: format(req_template, approver: 'fred')
assert_response 403
assert_xml_tag(tag: 'status', attributes: { code: 'create_bs_request_not_authorized' })
assert_xml_tag(tag: 'summary', content: 'You are not authorized to create this Bs request.')

# request creation succeeds because we are "Iggy"
post '/request?cmd=create', params: format(req_template, approver: 'Iggy')
assert_response :success

# as admin it should work
login_king
# request creation succeeds because we are "Iggy"
post '/request?cmd=create', params: format(req_template, approver: 'Iggy')
assert_response :success
end

def test_create_request_and_supersede
login_Iggy
req = load_backend_file('request/works')
Expand Down

0 comments on commit 88378eb

Please sign in to comment.