From 9c4a1b2883378af46f4b6feafab9acf91b8e4072 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Mon, 3 Jul 2017 17:48:08 +0300 Subject: [PATCH] Bug 18890: Fix cities.t The update also causes some tests authorization tests to fail with HTTP 400 response instead of the expected 401/403. It seems that the parameters were not properly validated before and the tests were mistakenly passing. To test: 1. prove t/db_dependent/api/v1/cities.t --- t/db_dependent/api/v1/cities.t | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/t/db_dependent/api/v1/cities.t b/t/db_dependent/api/v1/cities.t index ac8fe43..ba7a001 100644 --- a/t/db_dependent/api/v1/cities.t +++ b/t/db_dependent/api/v1/cities.t @@ -224,9 +224,17 @@ subtest 'update() tests' => sub { my $city_id = $builder->build( { source => 'City' } )->{cityid}; + # Full object update on PUT + my $city_with_updated_field = { + city_name => "London", + city_state => "City State", + city_zipcode => "City Zipcode", + city_country => "City Country" + }; + # Unauthorized attempt to update my $tx = $t->ua->build_tx( PUT => "/api/v1/cities/$city_id" => json => - { city_name => 'New unauthorized name change' } ); + $city_with_updated_field ); $tx->req->cookies( { name => 'CGISESSID', value => $unauthorized_session_id } ); $tx->req->env( { REMOTE_ADDR => $remote_address } ); @@ -249,14 +257,6 @@ subtest 'update() tests' => sub { [ { message => "Missing property.", path => "/body/city_zipcode" } ] ); - # Full object update on PUT - my $city_with_updated_field = { - city_name => "London", - city_state => "City State", - city_zipcode => "City Zipcode", - city_country => "City Country" - }; - $tx = $t->ua->build_tx( PUT => "/api/v1/cities/$city_id" => json => $city_with_updated_field ); $tx->req->cookies( -- 2.7.4