test_registration.rb

  1# frozen_string_literal: true
  2
  3require "test_helper"
  4require "customer"
  5require "registration"
  6
  7class RegistrationTest < Minitest::Test
  8	def test_for_registered
  9		sgx = OpenStruct.new(
 10			registered?: OpenStruct.new(phone: "+15555550000")
 11		)
 12		iq = Blather::Stanza::Iq::Command.new
 13		iq.from = "test@example.com"
 14		result = execute_command(iq) do
 15			Registration.for(
 16				customer(sgx: sgx),
 17				Minitest::Mock.new
 18			)
 19		end
 20		assert_kind_of Registration::Registered, result
 21	end
 22	em :test_for_registered
 23
 24	def test_for_activated
 25		web_manager = TelSelections.new(redis: FakeRedis.new)
 26		web_manager.set("test@example.net", "+15555550000")
 27		result = execute_command do
 28			sgx = OpenStruct.new(registered?: false)
 29			Registration.for(
 30				customer(
 31					plan_name: "test_usd",
 32					expires_at: Time.now + 999,
 33					sgx: sgx
 34				),
 35				web_manager
 36			)
 37		end
 38		assert_kind_of Registration::Finish, result
 39	end
 40	em :test_for_activated
 41
 42	def test_for_not_activated_approved
 43		sgx = OpenStruct.new(registered?: false)
 44		web_manager = TelSelections.new(redis: FakeRedis.new)
 45		web_manager.set("test\\40approved.example.com@component", "+15555550000")
 46		iq = Blather::Stanza::Iq::Command.new
 47		iq.from = "test@approved.example.com"
 48		result = execute_command(iq) do
 49			Registration.for(
 50				customer(
 51					sgx: sgx,
 52					jid: Blather::JID.new("test\\40approved.example.com@component")
 53				),
 54				web_manager
 55			)
 56		end
 57		assert_kind_of Registration::Activation::Allow, result
 58	end
 59	em :test_for_not_activated_approved
 60
 61	def test_for_not_activated_with_customer_id
 62		sgx = OpenStruct.new(registered?: false)
 63		web_manager = TelSelections.new(redis: FakeRedis.new)
 64		web_manager.set("test@example.net", "+15555550000")
 65		iq = Blather::Stanza::Iq::Command.new
 66		iq.from = "test@example.com"
 67		result = execute_command(iq) do
 68			Registration.for(
 69				customer(sgx: sgx),
 70				web_manager
 71			)
 72		end
 73		assert_kind_of Registration::Activation, result
 74	end
 75	em :test_for_not_activated_with_customer_id
 76
 77	class ActivationTest < Minitest::Test
 78		Command::COMMAND_MANAGER = Minitest::Mock.new
 79		def setup
 80			@activation = Registration::Activation.new("test", "+15555550000")
 81		end
 82
 83		def test_write
 84			stub_request(
 85				:get,
 86				"https://dashboard.bandwidth.com/v1.0/tns/+15555550000"
 87			).to_return(status: 201, body: <<~RESPONSE)
 88				<TelephoneNumberResponse>
 89					<TelephoneNumber>5555550000</TelephoneNumber>
 90				</TelephoneNumberResponse>
 91			RESPONSE
 92			stub_request(
 93				:get,
 94				"https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter"
 95			).to_return(status: 201, body: <<~RESPONSE)
 96				<TelephoneNumberResponse>
 97					<TelephoneNumberDetails>
 98						<State>KE</State>
 99						<RateCenter>FA</RateCenter>
100					</TelephoneNumberDetails>
101				</TelephoneNumberResponse>
102			RESPONSE
103			Command::COMMAND_MANAGER.expect(
104				:write,
105				EMPromise.reject(:test_result),
106				[Matching.new do |iq|
107					assert_equal :form, iq.form.type
108					assert_equal(
109						"You've selected +15555550000 (FA, KE) as your JMP number.",
110						iq.form.instructions.lines.first.chomp
111					)
112				end]
113			)
114			assert_equal(
115				:test_result,
116				execute_command { @activation.write.catch { |e| e } }
117			)
118			assert_mock Command::COMMAND_MANAGER
119		end
120		em :test_write
121	end
122
123	class AllowTest < Minitest::Test
124		Command::COMMAND_MANAGER = Minitest::Mock.new
125		Registration::Activation::Allow::DB = Minitest::Mock.new
126
127		def test_write_credit_to_nil
128			cust = Minitest::Mock.new(customer("test"))
129			allow = Registration::Activation::Allow.new(cust, "+15555550000", nil)
130
131			stub_request(
132				:get,
133				"https://dashboard.bandwidth.com/v1.0/tns/+15555550000"
134			).to_return(status: 201, body: <<~RESPONSE)
135				<TelephoneNumberResponse>
136					<TelephoneNumber>5555550000</TelephoneNumber>
137				</TelephoneNumberResponse>
138			RESPONSE
139			stub_request(
140				:get,
141				"https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter"
142			).to_return(status: 201, body: <<~RESPONSE)
143				<TelephoneNumberResponse>
144					<TelephoneNumberDetails>
145						<State>KE</State>
146						<RateCenter>FA</RateCenter>
147					</TelephoneNumberDetails>
148				</TelephoneNumberResponse>
149			RESPONSE
150			Command::COMMAND_MANAGER.expect(
151				:write,
152				EMPromise.resolve(Blather::Stanza::Iq::Command.new.tap { |iq|
153					iq.form.fields = [{ var: "plan_name", value: "test_usd" }]
154				}),
155				[Matching.new do |iq|
156					assert_equal :form, iq.form.type
157					assert_equal(
158						"You've selected +15555550000 (FA, KE) as your JMP number.",
159						iq.form.instructions.lines.first.chomp
160					)
161					assert_equal 1, iq.form.fields.length
162				end]
163			)
164			Registration::Activation::Allow::DB.expect(
165				:transaction,
166				EMPromise.reject(:test_result)
167			) do |&blk|
168				blk.call
169				true
170			end
171			cust.expect(:with_plan, cust, ["test_usd"])
172			cust.expect(:activate_plan_starting_now, nil)
173			assert_equal(
174				:test_result,
175				execute_command { allow.write.catch { |e| e } }
176			)
177			assert_mock Command::COMMAND_MANAGER
178		end
179		em :test_write_credit_to_nil
180
181		def test_write_credit_to_refercust
182			cust = Minitest::Mock.new(customer("test"))
183			allow = Registration::Activation::Allow.new(
184				cust, "+15555550000", "refercust"
185			)
186
187			stub_request(
188				:get,
189				"https://dashboard.bandwidth.com/v1.0/tns/+15555550000"
190			).to_return(status: 201, body: <<~RESPONSE)
191				<TelephoneNumberResponse>
192					<TelephoneNumber>5555550000</TelephoneNumber>
193				</TelephoneNumberResponse>
194			RESPONSE
195			stub_request(
196				:get,
197				"https://dashboard.bandwidth.com/v1.0/tns/5555550000/ratecenter"
198			).to_return(status: 201, body: <<~RESPONSE)
199				<TelephoneNumberResponse>
200					<TelephoneNumberDetails>
201						<State>KE</State>
202						<RateCenter>FA</RateCenter>
203					</TelephoneNumberDetails>
204				</TelephoneNumberResponse>
205			RESPONSE
206			Command::COMMAND_MANAGER.expect(
207				:write,
208				EMPromise.resolve(Blather::Stanza::Iq::Command.new.tap { |iq|
209					iq.form.fields = [{ var: "plan_name", value: "test_usd" }]
210				}),
211				[Matching.new do |iq|
212					assert_equal :form, iq.form.type
213					assert_equal(
214						"You've selected +15555550000 (FA, KE) as your JMP number.",
215						iq.form.instructions.lines.first.chomp
216					)
217					assert_equal 1, iq.form.fields.length
218				end]
219			)
220			Registration::Activation::Allow::DB.expect(
221				:transaction,
222				EMPromise.reject(:test_result)
223			) do |&blk|
224				blk.call
225				true
226			end
227			Registration::Activation::Allow::DB.expect(
228				:exec,
229				nil,
230				[String, ["refercust", "test"]]
231			)
232			cust.expect(:with_plan, cust, ["test_usd"])
233			cust.expect(:activate_plan_starting_now, nil)
234			assert_equal(
235				:test_result,
236				execute_command { allow.write.catch { |e| e } }
237			)
238			assert_mock Command::COMMAND_MANAGER
239		end
240		em :test_write_credit_to_refercust
241	end
242
243	class PaymentTest < Minitest::Test
244		CustomerFinancials::BRAINTREE = Minitest::Mock.new
245
246		def test_for_bitcoin
247			cust = Minitest::Mock.new(customer)
248			cust.expect(
249				:add_btc_address,
250				EMPromise.resolve("testaddr")
251			)
252			iq = Blather::Stanza::Iq::Command.new
253			iq.form.fields = [
254				{ var: "activation_method", value: "bitcoin" },
255				{ var: "plan_name", value: "test_usd" }
256			]
257			result = Registration::Payment.for(iq, cust, "+15555550000")
258			assert_kind_of Registration::Payment::Bitcoin, result
259		end
260
261		def test_for_credit_card
262			braintree_customer = Minitest::Mock.new
263			CustomerFinancials::BRAINTREE.expect(
264				:customer,
265				braintree_customer
266			)
267			braintree_customer.expect(
268				:find,
269				EMPromise.resolve(OpenStruct.new(payment_methods: [])),
270				["test"]
271			)
272			iq = Blather::Stanza::Iq::Command.new
273			iq.from = "test@example.com"
274			iq.form.fields = [
275				{ var: "activation_method", value: "credit_card" },
276				{ var: "plan_name", value: "test_usd" }
277			]
278			result = Registration::Payment.for(
279				iq,
280				customer,
281				"+15555550000"
282			).sync
283			assert_kind_of Registration::Payment::CreditCard, result
284		end
285		em :test_for_credit_card
286
287		def test_for_code
288			iq = Blather::Stanza::Iq::Command.new
289			iq.form.fields = [
290				{ var: "activation_method", value: "code" },
291				{ var: "plan_name", value: "test_usd" }
292			]
293			result = Registration::Payment.for(
294				iq,
295				customer,
296				"+15555550000"
297			)
298			assert_kind_of Registration::Payment::InviteCode, result
299		end
300
301		class BitcoinTest < Minitest::Test
302			Registration::Payment::Bitcoin::BTC_SELL_PRICES = Minitest::Mock.new
303			CustomerFinancials::REDIS = Minitest::Mock.new
304
305			def setup
306				@customer = Minitest::Mock.new(
307					customer(plan_name: "test_usd")
308				)
309				@customer.expect(
310					:add_btc_address,
311					EMPromise.resolve("testaddr")
312				)
313				@bitcoin = Registration::Payment::Bitcoin.new(
314					@customer,
315					"+15555550000"
316				)
317			end
318
319			def test_write
320				CustomerFinancials::REDIS.expect(
321					:smembers,
322					EMPromise.resolve([]),
323					["jmp_customer_btc_addresses-test"]
324				)
325				reply_text = <<~NOTE
326					Activate your account by sending at least 1.000000 BTC to
327					testaddr
328
329					You will receive a notification when your payment is complete.
330				NOTE
331				blather = Minitest::Mock.new
332				blather.expect(
333					:<<,
334					nil,
335					[Matching.new do |reply|
336						assert_equal :canceled, reply.status
337						assert_equal :info, reply.note_type
338						assert_equal reply_text, reply.note.content
339						true
340					end]
341				)
342				Registration::Payment::Bitcoin::BTC_SELL_PRICES.expect(
343					:usd,
344					EMPromise.resolve(BigDecimal(1))
345				)
346				@bitcoin.stub(:save, EMPromise.resolve(nil)) do
347					execute_command(blather: blather) do
348						@bitcoin.write
349					end
350				end
351				assert_mock blather
352			end
353			em :test_write
354		end
355
356		class CreditCardTest < Minitest::Test
357			def setup
358				@credit_card = Registration::Payment::CreditCard.new(
359					customer,
360					"+15555550000"
361				)
362			end
363
364			def test_for
365				customer = Minitest::Mock.new(customer)
366				customer.expect(
367					:payment_methods,
368					EMPromise.resolve(OpenStruct.new(default_payment_method: :test))
369				)
370				assert_kind_of(
371					Registration::Payment::CreditCard::Activate,
372					Registration::Payment::CreditCard.for(
373						customer,
374						"+15555550000"
375					).sync
376				)
377			end
378			em :test_for
379
380			def test_write
381				result = execute_command do
382					Command::COMMAND_MANAGER.expect(
383						:write,
384						EMPromise.reject(:test_result),
385						[Matching.new do |reply|
386							assert_equal [:execute, :next], reply.allowed_actions
387							assert_equal(
388								"Add credit card, then return here to continue: " \
389								"http://creditcard.example.com",
390								reply.note.content
391							)
392						end]
393					)
394
395					@credit_card.write.catch { |e| e }
396				end
397
398				assert_equal :test_result, result
399			end
400			em :test_write
401		end
402
403		class ActivateTest < Minitest::Test
404			Registration::Payment::CreditCard::Activate::Finish =
405				Minitest::Mock.new
406			Registration::Payment::CreditCard::Activate::Transaction =
407				Minitest::Mock.new
408			Command::COMMAND_MANAGER = Minitest::Mock.new
409
410			def test_write
411				transaction = PromiseMock.new
412				transaction.expect(
413					:insert,
414					EMPromise.resolve(nil)
415				)
416				customer = Minitest::Mock.new(
417					customer(plan_name: "test_usd")
418				)
419				Registration::Payment::CreditCard::Activate::Transaction.expect(
420					:sale,
421					transaction
422				) do |acustomer, amount:, payment_method:|
423					assert_operator customer, :===, acustomer
424					assert_equal CONFIG[:activation_amount], amount
425					assert_equal :test_default_method, payment_method
426				end
427				customer.expect(:bill_plan, nil)
428				Registration::Payment::CreditCard::Activate::Finish.expect(
429					:new,
430					OpenStruct.new(write: nil),
431					[customer, "+15555550000"]
432				)
433				execute_command do
434					Registration::Payment::CreditCard::Activate.new(
435						customer,
436						:test_default_method,
437						"+15555550000"
438					).write
439				end
440				Registration::Payment::CreditCard::Activate::Transaction.verify
441				transaction.verify
442				customer.verify
443				Registration::Payment::CreditCard::Activate::Finish.verify
444			end
445			em :test_write
446
447			def test_write_declines
448				customer = Minitest::Mock.new(
449					customer(plan_name: "test_usd")
450				)
451				iq = Blather::Stanza::Iq::Command.new
452				iq.from = "test@example.com"
453				msg = Registration::Payment::CreditCard::Activate::DECLINE_MESSAGE
454				Command::COMMAND_MANAGER.expect(
455					:write,
456					EMPromise.reject(:test_result),
457					[Matching.new do |reply|
458						assert_equal :error, reply.note_type
459						assert_equal(
460							"#{msg}: http://creditcard.example.com",
461							reply.note.content
462						)
463					end]
464				)
465				result = execute_command do
466					Registration::Payment::CreditCard::Activate::Transaction.expect(
467						:sale,
468						EMPromise.reject("declined")
469					) do |acustomer, amount:, payment_method:|
470						assert_operator customer, :===, acustomer
471						assert_equal CONFIG[:activation_amount], amount
472						assert_equal :test_default_method, payment_method
473					end
474
475					Registration::Payment::CreditCard::Activate.new(
476						customer,
477						:test_default_method,
478						"+15555550000"
479					).write.catch { |e| e }
480				end
481				assert_equal :test_result, result
482				Registration::Payment::CreditCard::Activate::Transaction.verify
483			end
484			em :test_write_declines
485		end
486
487		class InviteCodeTest < Minitest::Test
488			Registration::Payment::InviteCode::DB =
489				Minitest::Mock.new
490			Registration::Payment::InviteCode::REDIS =
491				Minitest::Mock.new
492			Command::COMMAND_MANAGER = Minitest::Mock.new
493			Registration::Payment::InviteCode::Finish =
494				Minitest::Mock.new
495			def test_write
496				customer = customer(plan_name: "test_usd")
497				Registration::Payment::InviteCode::DB.expect(:transaction, true, [])
498				Registration::Payment::InviteCode::Finish.expect(
499					:new,
500					OpenStruct.new(write: nil),
501					[
502						customer,
503						"+15555550000"
504					]
505				)
506				execute_command do
507					Registration::Payment::InviteCode::REDIS.expect(
508						:get,
509						EMPromise.resolve(nil),
510						["jmp_invite_tries-test"]
511					)
512					Command::COMMAND_MANAGER.expect(
513						:write,
514						EMPromise.resolve(
515							Blather::Stanza::Iq::Command.new.tap { |iq|
516								iq.form.fields = [{ var: "code", value: "abc" }]
517							}
518						),
519						[Matching.new do |reply|
520							assert_equal :form, reply.form.type
521							assert_nil reply.form.instructions
522						end]
523					)
524
525					Registration::Payment::InviteCode.new(
526						customer,
527						"+15555550000"
528					).write
529				end
530				assert_mock Command::COMMAND_MANAGER
531				assert_mock Registration::Payment::InviteCode::DB
532				assert_mock Registration::Payment::InviteCode::REDIS
533				assert_mock Registration::Payment::InviteCode::Finish
534			end
535			em :test_write
536
537			def test_write_bad_code
538				result = execute_command do
539					customer = customer(plan_name: "test_usd")
540					Registration::Payment::InviteCode::REDIS.expect(
541						:get,
542						EMPromise.resolve(0),
543						["jmp_invite_tries-test"]
544					)
545					Registration::Payment::InviteCode::DB.expect(:transaction, []) do
546						raise Registration::Payment::InviteCode::Invalid, "wut"
547					end
548					Registration::Payment::InviteCode::REDIS.expect(
549						:incr,
550						EMPromise.resolve(nil),
551						["jmp_invite_tries-test"]
552					)
553					Registration::Payment::InviteCode::REDIS.expect(
554						:expire,
555						EMPromise.resolve(nil),
556						["jmp_invite_tries-test", 60 * 60]
557					)
558					Command::COMMAND_MANAGER.expect(
559						:write,
560						EMPromise.resolve(
561							Blather::Stanza::Iq::Command.new.tap { |iq|
562								iq.form.fields = [{ var: "code", value: "abc" }]
563							}
564						),
565						[Matching.new do |reply|
566							assert_equal :form, reply.form.type
567							assert_nil reply.form.instructions
568						end]
569					)
570					Command::COMMAND_MANAGER.expect(
571						:write,
572						EMPromise.reject(:test_result),
573						[Matching.new do |reply|
574							assert_equal :form, reply.form.type
575							assert_equal "wut", reply.form.instructions
576						end]
577					)
578
579					Registration::Payment::InviteCode.new(
580						customer,
581						"+15555550000"
582					).write.catch { |e| e }
583				end
584				assert_equal :test_result, result
585				assert_mock Command::COMMAND_MANAGER
586				assert_mock Registration::Payment::InviteCode::DB
587				assert_mock Registration::Payment::InviteCode::REDIS
588			end
589			em :test_write_bad_code
590
591			def test_write_bad_code_over_limit
592				result = execute_command do
593					customer = customer(plan_name: "test_usd")
594					Registration::Payment::InviteCode::REDIS.expect(
595						:get,
596						EMPromise.resolve(11),
597						["jmp_invite_tries-test"]
598					)
599					Command::COMMAND_MANAGER.expect(
600						:write,
601						EMPromise.resolve(
602							Blather::Stanza::Iq::Command.new.tap { |iq|
603								iq.form.fields = [{ var: "code", value: "abc" }]
604							}
605						),
606						[Matching.new do |reply|
607							assert_equal :form, reply.form.type
608							assert_nil reply.form.instructions
609						end]
610					)
611					Registration::Payment::InviteCode::REDIS.expect(
612						:incr,
613						EMPromise.resolve(nil),
614						["jmp_invite_tries-test"]
615					)
616					Registration::Payment::InviteCode::REDIS.expect(
617						:expire,
618						EMPromise.resolve(nil),
619						["jmp_invite_tries-test", 60 * 60]
620					)
621					Command::COMMAND_MANAGER.expect(
622						:write,
623						EMPromise.reject(:test_result),
624						[Matching.new do |reply|
625							assert_equal :form, reply.form.type
626							assert_equal "Too many wrong attempts", reply.form.instructions
627						end]
628					)
629					Registration::Payment::InviteCode.new(
630						customer,
631						"+15555550000"
632					).write.catch { |e| e }
633				end
634				assert_equal :test_result, result
635				assert_mock Command::COMMAND_MANAGER
636				assert_mock Registration::Payment::InviteCode::REDIS
637			end
638			em :test_write_bad_code_over_limit
639		end
640	end
641
642	class FinishTest < Minitest::Test
643		Command::COMMAND_MANAGER = Minitest::Mock.new
644		Registration::Finish::TEL_SELECTIONS = FakeTelSelections.new
645		Registration::Finish::REDIS = Minitest::Mock.new
646		Bwmsgsv2Repo::REDIS = Minitest::Mock.new
647
648		def setup
649			@sgx = Minitest::Mock.new(TrivialBackendSgxRepo.new.get("test"))
650			iq = Blather::Stanza::Iq::Command.new
651			iq.from = "test\\40example.com@cheogram.com"
652			@finish = Registration::Finish.new(
653				customer(sgx: @sgx),
654				"+15555550000"
655			)
656		end
657
658		def test_write
659			create_order = stub_request(
660				:post,
661				"https://dashboard.bandwidth.com/v1.0/accounts//orders"
662			).to_return(status: 201, body: <<~RESPONSE)
663				<OrderResponse>
664					<Order>
665						<id>test_order</id>
666					</Order>
667				</OrderResponse>
668			RESPONSE
669			stub_request(
670				:get,
671				"https://dashboard.bandwidth.com/v1.0/accounts//orders/test_order"
672			).to_return(status: 201, body: <<~RESPONSE)
673				<OrderResponse>
674					<OrderStatus>COMPLETE</OrderStatus>
675					<CompletedNumbers>
676						<TelephoneNumber>
677							<FullNumber>5555550000</FullNumber>
678						</TelephoneNumber>
679					</CompletedNumbers>
680				</OrderResponse>
681			RESPONSE
682			stub_request(
683				:post,
684				"https://dashboard.bandwidth.com/v1.0/accounts//sites//sippeers//movetns"
685			)
686			Registration::Finish::REDIS.expect(
687				:del,
688				nil,
689				["pending_tel_for-test@example.net"]
690			)
691			Bwmsgsv2Repo::REDIS.expect(
692				:set,
693				nil,
694				[
695					"catapult_fwd-+15555550000",
696					"xmpp:test@example.net"
697				]
698			)
699			Bwmsgsv2Repo::REDIS.expect(
700				:set,
701				nil,
702				["catapult_fwd_timeout-customer_test@component", 25]
703			)
704			blather = Minitest::Mock.new
705			blather.expect(
706				:<<,
707				nil,
708				[Matching.new do |reply|
709					assert_equal :completed, reply.status
710					assert_equal :info, reply.note_type
711					assert_equal(
712						"Your JMP account has been activated as +15555550000",
713						reply.note.content
714					)
715				end]
716			)
717			execute_command(blather: blather) do
718				@sgx.expect(
719					:register!,
720					EMPromise.resolve(@sgx.with(registered?: IBR.new.tap do |ibr|
721						ibr.phone = "+15555550000"
722					end)),
723					["+15555550000"]
724				)
725
726				@finish.write
727			end
728			assert_requested create_order
729			assert_mock @sgx
730			assert_mock Registration::Finish::REDIS
731			assert_mock Bwmsgsv2Repo::REDIS
732			assert_mock blather
733		end
734		em :test_write
735
736		def test_write_tn_fail
737			create_order = stub_request(
738				:post,
739				"https://dashboard.bandwidth.com/v1.0/accounts//orders"
740			).to_return(status: 201, body: <<~RESPONSE)
741				<OrderResponse>
742					<Order>
743						<id>test_order</id>
744					</Order>
745				</OrderResponse>
746			RESPONSE
747			stub_request(
748				:get,
749				"https://dashboard.bandwidth.com/v1.0/accounts//orders/test_order"
750			).to_return(status: 201, body: <<~RESPONSE)
751				<OrderResponse>
752					<OrderStatus>FAILED</OrderStatus>
753				</OrderResponse>
754			RESPONSE
755
756			result = execute_command do
757				Command::COMMAND_MANAGER.expect(
758					:write,
759					EMPromise.reject(:test_result),
760					[Matching.new do |iq|
761						assert_equal :form, iq.form.type
762						assert_equal(
763							"The JMP number +15555550000 is no longer available.",
764							iq.form.instructions
765						)
766					end]
767				)
768
769				@finish.write.catch { |e| e }
770			end
771
772			assert_equal :test_result, result
773			assert_mock Command::COMMAND_MANAGER
774			assert_instance_of(
775				TelSelections::ChooseTel,
776				Registration::Finish::TEL_SELECTIONS["test@example.com"]
777			)
778			assert_requested create_order
779		end
780		em :test_write_tn_fail
781	end
782end