From 736f4e909515e4d0e5ec91e6aba02fbd153cf7f8 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 Signed-off-by: Mark Tompsett --- 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 aeace2f..fca3bdf 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.1.4