From e7e24e7c891bb87db31091571ba54776d30213a8 Mon Sep 17 00:00:00 2001 From: Gerhard Jungwirth Date: Thu, 10 Dec 2015 16:46:14 +0100 Subject: [PATCH] MT#15693 check deleting contract 1 which should fail Change-Id: Ic513c90de1b8d88f8d2efe5d2957557d5d0227f2 --- t/api-rest/api-contracts.t | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/t/api-rest/api-contracts.t b/t/api-rest/api-contracts.t index dee4d65da0..3013589d61 100644 --- a/t/api-rest/api-contracts.t +++ b/t/api-rest/api-contracts.t @@ -715,6 +715,25 @@ my @allcontracts = (); } +# terminate contract 1 should fail +{ + $req = HTTP::Request->new('GET', $uri.'/api/contracts/1'); + $res = $ua->request($req); + is($res->code, 200, "check existence of contract with id (1)"); + my $contract_1 = JSON::from_json($res->decoded_content); + is($contract_1->{id}, 1, 'id of contract (1) is 1'); + is($contract_1->{type}, 'reseller', 'tpye of contract (1) is "reseller"'); + + $req = HTTP::Request->new('PATCH', $uri.'/api/contracts/1'); + $req->header('Content-Type' => 'application/json-patch+json'); + $req->header('Prefer' => 'return=representation'); + $req->content(JSON::to_json([ + { "op" => "replace", "path" => "/status", "value" => "terminated" } + ])); + $res = $ua->request($req); + is($res->code, 403, "check that its impossible to termination contract (1)"); +} + sub _strip_future_mappings { my ($mappings) = @_; my @stripped_mappings = ();