From f5ad677abc6062e3abf1a4aea211640673c2cdc8 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 20 Sep 2022 14:04:13 -0500 Subject: [PATCH] Actually handle outbound attempt from unknown customer --- test/test_web.rb | 21 +++++++++++++++++++++ views/outbound/no_customer.slim | 3 +++ web.rb | 6 ++++-- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 views/outbound/no_customer.slim diff --git a/test/test_web.rb b/test/test_web.rb index 3cfe8280c8d0d02245d7e5450bb0a53dbf68141f..b1a5b1f9b38a91fc738dbba51a3725297f926981 100644 --- a/test/test_web.rb +++ b/test/test_web.rb @@ -265,6 +265,27 @@ class WebTest < Minitest::Test end em :test_outbound_atlimit + def test_outbound_no_customer + post( + "/outbound/calls", + { + from: "no_such_customer", + to: "+15557654321", + callId: "acall" + }.to_json, + { "CONTENT_TYPE" => "application/json" } + ) + + assert last_response.ok? + assert_equal( + "" \ + "Your credentials are invalid, please contact support." \ + "", + last_response.body + ) + end + em :test_outbound_no_customer + def test_outbound_atlimit_digits post( "/outbound/calls", diff --git a/views/outbound/no_customer.slim b/views/outbound/no_customer.slim new file mode 100644 index 0000000000000000000000000000000000000000..a9d6f4534064f1e86cbba7b61abffe40b486cbf5 --- /dev/null +++ b/views/outbound/no_customer.slim @@ -0,0 +1,3 @@ +doctype xml +Response + SpeakSentence Your credentials are invalid, please contact support. diff --git a/web.rb b/web.rb index d79a1828ca3084108b54c1c0b4959fec35000183..958980f7e83fdab1ebec589549d9535245f6c890 100644 --- a/web.rb +++ b/web.rb @@ -366,7 +366,7 @@ class Web < Roda from = params["from"].sub(/^\+1/, "") customer_repo( sgx_repo: Bwmsgsv2Repo.new - ).find_by_format(from).then do |c| + ).find_by_format(from).then { |c| call_attempt_repo.find_outbound( c, params["to"], @@ -378,7 +378,9 @@ class Web < Roda call_attempt_repo.starting_call(c, params["callId"]) render(*ca.to_render) end - end + }.catch_only(CustomerRepo::NotFound) { + render "outbound/no_customer" + } end end end