approved_domains unproxied

Stephen Paul Weber created

Change summary

lib/registration.rb       | 5 +++--
test/test_registration.rb | 7 +++++--
2 files changed, 8 insertions(+), 4 deletions(-)

Detailed changes

lib/registration.rb 🔗

@@ -34,10 +34,11 @@ class Registration
 
 	class Activation
 		def self.for(customer, tel)
+			jid = ProxiedJID.new(customer.jid).unproxied
 			if customer.active?
 				Finish.new(customer, tel)
-			elsif CONFIG[:approved_domains].key?(customer.jid.domain.to_sym)
-				credit_to = CONFIG[:approved_domains][customer.jid.domain.to_sym]
+			elsif CONFIG[:approved_domains].key?(jid.domain.to_sym)
+				credit_to = CONFIG[:approved_domains][jid.domain.to_sym]
 				Allow.new(customer, tel, credit_to)
 			else
 				new(customer, tel)

test/test_registration.rb 🔗

@@ -55,12 +55,15 @@ class RegistrationTest < Minitest::Test
 	def test_for_not_activated_approved
 		sgx = OpenStruct.new(registered?: false)
 		web_manager = TelSelections.new(redis: FakeRedis.new)
-		web_manager.set("test@approved.example.com", "+15555550000")
+		web_manager.set("test\\40approved.example.com@component", "+15555550000")
 		iq = Blather::Stanza::Iq::Command.new
 		iq.from = "test@approved.example.com"
 		result = execute_command(iq) do
 			Registration.for(
-				customer(sgx: sgx, jid: Blather::JID.new("test@approved.example.com")),
+				customer(
+					sgx: sgx,
+					jid: Blather::JID.new("test\\40approved.example.com@component")
+				),
 				web_manager
 			)
 		end