diff --git a/test/test_web.rb b/test/test_web.rb index dc79046fe3a2e56b17095f07a980045dfbc3df50..facfa6ec6430ab67bdb4a2642fb7203f848b64d0 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 799c60c506203ea3d7f64636a7de83efe6c7b163..0bb579d262aa8f6ed363d0a6d7a78c1dec23d21b 100644 --- a/web.rb +++ b/web.rb @@ -368,7 +368,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"], @@ -380,7 +380,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