From b89aeade96e8cf1be4d6471b8a0cfff363428a37 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 18 Oct 2021 14:16:32 -0500 Subject: [PATCH] Move to v2 if at all safe --- lib/bwmsgsv2_repo.rb | 2 +- lib/customer_fwd.rb | 12 ++++++++++-- test/test_registration.rb | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/bwmsgsv2_repo.rb b/lib/bwmsgsv2_repo.rb index 28480ba..72a4f5f 100644 --- a/lib/bwmsgsv2_repo.rb +++ b/lib/bwmsgsv2_repo.rb @@ -45,7 +45,7 @@ class Bwmsgsv2Repo customer_fwd.timeout.to_i ) ]).then do - set_default_location(tel) if customer_fwd.v2_sip? + set_default_location(tel) if customer_fwd.v2_safe? end end diff --git a/lib/customer_fwd.rb b/lib/customer_fwd.rb index fcb9659..1fb5a4b 100644 --- a/lib/customer_fwd.rb +++ b/lib/customer_fwd.rb @@ -52,18 +52,22 @@ class CustomerFwd BANDWIDTH_VOICE.create_call(account, body: request).data.call_id end - def v2_sip? + def v2_safe? false end class Tel < CustomerFwd + def v2_safe? + true + end + def to uri.sub(/^tel:/, "") end end class SIP < CustomerFwd - def v2_sip? + def v2_safe? uri.end_with?(CONFIG[:sip][:realm]) end @@ -73,6 +77,10 @@ class CustomerFwd end class XMPP < CustomerFwd + def v2_safe? + true + end + def to jid = uri.sub(/^xmpp:/, "") "sip:#{ERB::Util.url_encode(jid)}@sip.cheogram.com" diff --git a/test/test_registration.rb b/test/test_registration.rb index f0c5385..eba4a4a 100644 --- a/test/test_registration.rb +++ b/test/test_registration.rb @@ -563,6 +563,10 @@ class RegistrationTest < Minitest::Test "Content-Type" => "application/json" } ).to_return(status: 201) + stub_request( + :post, + "https://dashboard.bandwidth.com/v1.0/accounts//sites//sippeers//movetns" + ) Registration::Finish::REDIS.expect( :del, nil, -- 2.38.5