From cd02cc3017563f25ec51b37c1889ec179fc6f2a2 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 12 Jan 2022 15:25:59 -0500 Subject: [PATCH] Remove LegacyCustomer Such customers are not longer a common or valid case. --- forms/legacy_customer_admin_info.rb | 29 -------------- forms/legacy_customer_info.rb | 4 -- forms/legacy_customer_info_partial.rb | 11 ----- lib/customer_info_form.rb | 1 - lib/customer_repo.rb | 11 +---- lib/legacy_customer.rb | 58 --------------------------- test/test_customer_info.rb | 18 --------- test/test_customer_repo.rb | 21 +--------- 8 files changed, 2 insertions(+), 151 deletions(-) delete mode 100644 forms/legacy_customer_admin_info.rb delete mode 100644 forms/legacy_customer_info.rb delete mode 100644 forms/legacy_customer_info_partial.rb delete mode 100644 lib/legacy_customer.rb diff --git a/forms/legacy_customer_admin_info.rb b/forms/legacy_customer_admin_info.rb deleted file mode 100644 index fdf3a64..0000000 --- a/forms/legacy_customer_admin_info.rb +++ /dev/null @@ -1,29 +0,0 @@ -result! -title "Customer Info" - -render "legacy_customer_info_partial", info: @admin_info.info - -field( - var: "jid", - label: "JID", - value: @admin_info.jid.unproxied.to_s -) - -field( - var: "cheo_jid", - label: "Cheo JID", - value: @admin_info.jid.to_s -) - -field( - var: "api", - label: "API", - value: @admin_info.api.to_s -) - -field( - var: "link", - label: "Link", - type: "jid-single", - value: "#{@admin_info.info.tel}@#{CONFIG[:upstream_domain]}" -) diff --git a/forms/legacy_customer_info.rb b/forms/legacy_customer_info.rb deleted file mode 100644 index 7e78941..0000000 --- a/forms/legacy_customer_info.rb +++ /dev/null @@ -1,4 +0,0 @@ -result! -title "Account Info" - -render "legacy_customer_info_partial" diff --git a/forms/legacy_customer_info_partial.rb b/forms/legacy_customer_info_partial.rb deleted file mode 100644 index 46c8b7e..0000000 --- a/forms/legacy_customer_info_partial.rb +++ /dev/null @@ -1,11 +0,0 @@ -field( - var: "account_status", - label: "Account Status", - value: "Legacy" -) - -field( - var: "tel", - label: "Phone Number", - value: @info.tel -) diff --git a/lib/customer_info_form.rb b/lib/customer_info_form.rb index 597ecec..259ca53 100644 --- a/lib/customer_info_form.rb +++ b/lib/customer_info_form.rb @@ -3,7 +3,6 @@ require_relative "bwmsgsv2_repo" require_relative "customer_repo" require_relative "proxied_jid" -require_relative "legacy_customer" class CustomerInfoForm def initialize(customer_repo=CustomerRepo.new(sgx_repo: Bwmsgsv2Repo.new)) diff --git a/lib/customer_repo.rb b/lib/customer_repo.rb index 10e4872..b38e16e 100644 --- a/lib/customer_repo.rb +++ b/lib/customer_repo.rb @@ -3,7 +3,6 @@ require "lazy_object" require_relative "customer" -require_relative "legacy_customer" require_relative "polyfill" class CustomerRepo @@ -34,7 +33,7 @@ class CustomerRepo find($1) else @redis.get("jmp_customer_id-#{jid}").then do |customer_id| - next find_legacy_customer(jid) unless customer_id + raise "No customer" unless customer_id find_inner(customer_id, jid) end @@ -94,14 +93,6 @@ protected TrivialBackendSgxRepo.new.get(customer_id).with(registered?: false) end - def find_legacy_customer(jid) - @redis.lindex("catapult_cred-#{jid}", 3).then do |tel| - raise NotFound, "No customer" unless tel - - LegacyCustomer.new(Blather::JID.new(jid), tel) - end - end - def hydrate_plan(customer_id, raw_customer) raw_customer.dup.tap do |data| data[:plan] = CustomerPlan.new( diff --git a/lib/legacy_customer.rb b/lib/legacy_customer.rb deleted file mode 100644 index 3767d6c..0000000 --- a/lib/legacy_customer.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -require "value_semantics/monkey_patched" -require_relative "proxied_jid" - -class LegacyCustomer - attr_reader :jid, :tel - - def initialize(jid, tel) - @jid = jid - @tel = tel - end - - def customer_id - nil - end - - def info - EMPromise.resolve(nil).then do - Info.new(tel: tel) - end - end - - def admin_info - EMPromise.all([ - info, - api - ]).then do |info, api| - AdminInfo.new(info: info, jid: jid, api: api) - end - end - - def api - API.for(self) - end - - class Info - value_semantics do - tel String - end - - def form - FormTemplate.render("legacy_customer_info", info: self) - end - end - - class AdminInfo - value_semantics do - info Info - jid ProxiedJID, coerce: ProxiedJID.method(:new) - api API - end - - def form - FormTemplate.render("legacy_customer_admin_info", admin_info: self) - end - end -end diff --git a/test/test_customer_info.rb b/test/test_customer_info.rb index abf5776..cd3a3a9 100644 --- a/test/test_customer_info.rb +++ b/test/test_customer_info.rb @@ -100,24 +100,6 @@ class CustomerInfoTest < Minitest::Test end em :test_inactive_admin_info_does_not_crash - def test_legacy_customer_info_does_not_crash - cust = LegacyCustomer.new( - Blather::JID.new("legacy@example.com"), - "+12223334444" - ) - assert cust.info.sync.form - end - em :test_legacy_customer_info_does_not_crash - - def test_legacy_customer_admin_info_does_not_crash - cust = LegacyCustomer.new( - Blather::JID.new("legacy@example.com"), - "+12223334444" - ) - assert cust.admin_info.sync.form - end - em :test_legacy_customer_admin_info_does_not_crash - def test_missing_customer_admin_info_does_not_crash cust = CustomerInfoForm::NoCustomer.new assert cust.admin_info.form diff --git a/test/test_customer_repo.rb b/test/test_customer_repo.rb index b067e63..e85702a 100644 --- a/test/test_customer_repo.rb +++ b/test/test_customer_repo.rb @@ -29,12 +29,7 @@ class CustomerRepoTest < Minitest::Test "catapult_jid-+14445556666" => "test_v2@example.com", "catapult_cred-test_v2@example.com" => [ "test_bw_customer", "", "", "+14445556666" - ], - # legacy customer - "catapult_cred-legacy@example.com" => [ - "catapult_user", "", "", "+12223334444" - ], - "catapult_jid-+12223334444" => "legacy@example.com" + ] ) FAKE_DB = FakeDB.new( @@ -99,13 +94,6 @@ class CustomerRepoTest < Minitest::Test end em :test_find_by_jid_not_found - def test_find_legacy_customer - customer = @repo.find_by_jid("legacy@example.com").sync - assert_kind_of LegacyCustomer, customer - assert_equal "+12223334444", customer.tel - end - em :test_find_legacy_customer - def test_find_sgx_customer_by_phone customer = @repo.find_by_tel("+13334445555").sync assert_kind_of Customer, customer @@ -120,13 +108,6 @@ class CustomerRepoTest < Minitest::Test end em :test_find_v2_customer_by_phone - def test_find_legacy_customer_by_phone - customer = @repo.find_by_tel("+12223334444").sync - assert_kind_of LegacyCustomer, customer - assert_equal "legacy@example.com", customer.jid.to_s - end - em :test_find_legacy_customer_by_phone - def test_find_missing_phone assert_raises do @repo.find_by_tel("+15556667777").sync -- 2.38.4