~singpolyma/sgx-jmp

bc03f1eb92144f561469987fb4e25fb1d3079e8e — Stephen Paul Weber 8 months ago c3da8bd
approved_domains unproxied
2 files changed, 8 insertions(+), 4 deletions(-)

M lib/registration.rb
M test/test_registration.rb
M lib/registration.rb => lib/registration.rb +3 -2
@@ 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)

M test/test_registration.rb => test/test_registration.rb +5 -2
@@ 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