From 245d66ee8b9412c05afdc77121e814de4f5e72e6 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 19 Oct 2021 20:58:47 -0500 Subject: [PATCH] Don't send too big timeout to bandwidth --- lib/customer_fwd.rb | 2 +- test/test_customer_fwd.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/customer_fwd.rb b/lib/customer_fwd.rb index 0cb2cf0..9f575fc 100644 --- a/lib/customer_fwd.rb +++ b/lib/customer_fwd.rb @@ -22,7 +22,7 @@ class CustomerFwd end def initialize(s) - @timeout = s.nil? || s.to_i.negative? ? 300 : s.to_i + @timeout = s.nil? || s.to_i.negative? || s.to_i > 300 ? 300 : s.to_i end def zero? diff --git a/test/test_customer_fwd.rb b/test/test_customer_fwd.rb index de53030..8b76aa6 100644 --- a/test/test_customer_fwd.rb +++ b/test/test_customer_fwd.rb @@ -12,6 +12,11 @@ class Rantly end class CustomerFwdTest < Minitest::Test + def test_too_big_timeout + fwd = CustomerFwd.for(uri: "xmpp:test@example.com", timeout: 500) + assert_equal 300, fwd.timeout.to_i + end + property(:for_xmpp) { jid } def for_xmpp(jid) sip = "sip:#{ERB::Util.url_encode(jid.to_s)}@sip.cheogram.com" -- 2.34.5