Skip to content

Commit

Permalink
[Boomi] Encode string before calculating hash.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Sep 27, 2024
1 parent 78af749 commit f2616cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion perllib/Open311/Endpoint/Integration/Boomi.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ with 'Open311::Endpoint::Role::mySociety';
with 'Role::EndpointConfig';
with 'Role::Logger';

use Encode qw(encode_utf8);
use POSIX qw(strftime);
use MIME::Base64 qw(encode_base64);
use Open311::Endpoint::Service::UKCouncil::Boomi;
Expand Down Expand Up @@ -295,7 +296,7 @@ sub post_service_request_update {
# we don't get back a unique ID from Boomi, so calculate one ourselves
# XXX is this going to be mirrored back next time we fetch updates?
my @parts = map { $args->{$_} } qw/service_request_id description update_id updated_datetime/;
my $hash = substr(md5_hex(join('', @parts)), 0, 8);
my $hash = substr(md5_hex(encode_utf8(join('', @parts))), 0, 8);
my $update_id = $args->{service_request_id} . "_" . $hash;

if ($args->{description}) {
Expand Down
7 changes: 4 additions & 3 deletions t/open311/endpoint/surrey_boomi.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package Integrations::Surrey::Boomi::Dummy;
use utf8;
use Path::Tiny;
use Moo;
use HTTP::Response;
Expand Down Expand Up @@ -44,7 +45,7 @@ $lwp->mock(request => sub {
is_deeply $content, {
"comments" => [
{
"body" => "This is an update"
"body" => "This is an 🐙 update"
}
],
"ticketId" => "123456",
Expand Down Expand Up @@ -467,15 +468,15 @@ subtest "POST Service Request Update" => sub {
updated_datetime => '2023-05-02T12:00:00Z',
service_request_id => 'Zendesk_123456',
status => 'OPEN',
description => 'This is an update',
description => 'This is an 🐙 update',
last_name => "Smith",
first_name => "John",
update_id => '10000000',
);
is $res->code, 200;
is_deeply decode_json($res->content),
[ {
'update_id' => "Zendesk_123456_ac95b36b",
'update_id' => "Zendesk_123456_59275cb0",
} ], 'correct json returned';

restore_time();
Expand Down

0 comments on commit f2616cb

Please sign in to comment.