.rubocop.yml 🔗
@@ -10,6 +10,10 @@ Metrics/MethodLength:
Exclude:
- test/*
+Metrics/ClassLength:
+ Exclude:
+ - test/*
+
Metrics/AbcSize:
Exclude:
- test/*
Stephen Paul Weber created
Adds the settings to redis that jmp-fwdcalls will use to route inbound calls.
Not done by the sgx registration even though fwdcalls is currently a plug-over,
and of course won't be once fwdcalls dies so do it here.
.rubocop.yml | 4 ++++
lib/registration.rb | 22 +++++++++++++++++++++-
test/test_registration.rb | 19 ++++++++++++++++++-
3 files changed, 43 insertions(+), 2 deletions(-)
@@ -10,6 +10,10 @@ Metrics/MethodLength:
Exclude:
- test/*
+Metrics/ClassLength:
+ Exclude:
+ - test/*
+
Metrics/AbcSize:
Exclude:
- test/*
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require "erb"
+
require_relative "./oob"
class Registration
@@ -285,7 +287,7 @@ class Registration
def write
BandwidthTNOrder.create(@tel).then(&:poll).then(
- ->(_) { @customer.register!(@tel).then { BLATHER << @reply } },
+ ->(_) { customer_active_tel_purchased },
lambda do |_|
@reply.note_type = :error
@reply.note_text =
@@ -295,5 +297,23 @@ class Registration
end
)
end
+
+ protected
+
+ def cheogram_sip_addr
+ "sip:#{ERB::Util.url_encode(@reply.to.stripped.to_s)}@sip.cheogram.com"
+ end
+
+ def customer_active_tel_purchased
+ @customer.register!(@tel).then {
+ EMPromise.all([
+ REDIS.set("catapult_fwd-#{@tel}", cheogram_sip_addr),
+ REDIS.set(
+ "catapult_fwd_timeout-#{@reply.to.stripped}",
+ 25 # ~5 seconds / ring, 5 rings
+ )
+ ])
+ }.then { BLATHER << @reply }
+ end
end
end
@@ -289,10 +289,13 @@ class RegistrationTest < Minitest::Test
class FinishTest < Minitest::Test
Registration::Finish::BLATHER = Minitest::Mock.new
+ Registration::Finish::REDIS = Minitest::Mock.new
def setup
+ iq = Blather::Stanza::Iq::Command.new
+ iq.from = "test\\40example.com@cheogram.com"
@finish = Registration::Finish.new(
- Blather::Stanza::Iq::Command.new,
+ iq,
Customer.new("test"),
"+15555550000"
)
@@ -322,6 +325,19 @@ class RegistrationTest < Minitest::Test
EMPromise.resolve(OpenStruct.new(error?: false)),
["test", "+15555550000"]
)
+ Registration::Finish::REDIS.expect(
+ :set,
+ nil,
+ [
+ "catapult_fwd-+15555550000",
+ "sip:test%5C40example.com%40cheogram.com@sip.cheogram.com"
+ ]
+ )
+ Registration::Finish::REDIS.expect(
+ :set,
+ nil,
+ ["catapult_fwd_timeout-test\\40example.com@cheogram.com", 25]
+ )
Registration::Finish::BLATHER.expect(
:<<,
nil,
@@ -337,6 +353,7 @@ class RegistrationTest < Minitest::Test
@finish.write.sync
assert_requested create_order
BACKEND_SGX.verify
+ Registration::Finish::REDIS.verify
Registration::Finish::BLATHER.verify
end
em :test_write