sgx-jmp
created pr with
sgx-jmp/ban-self-parent.1
cmds
checkout latest patchset:
ssh pr.pico.sh pull sgx-jmp:ban-self-parent | git am -3checkout specific patchset revision:
ssh pr.pico.sh pull sgx-jmp:ban-self-parent [rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh sgx-jmp:ban-self-parentadd comment to patch request:
ssh pr.pico.sh comment sgx-jmp:ban-self-parent "lgtm!"
Patchset
sgx-jmp/ban-self-parent.1
Make sure a customer cannot parent itself
Stephen Paul Weber
2026-10-25T22:36:49ZSemantic diff summary
0 added,
0 modified,
0 signature changed,
0 removed
across 0 analyzed files
(2 files skipped: unsupported file type)
+1
-0
lib/customer_plan.rb
#
| ... | ... | @@ -71,6 +71,7 @@ class CustomerPlan | |
| 71 | 71 | ||
| 72 | 72 | def verify_parent! | |
| 73 | 73 | return unless parent_customer_id | |
| 74 | + | raise "Invalid parent account" if parent_customer_id == customer_id | |
| 74 | 75 | ||
| 75 | 76 | result = DB.query(<<~SQL, [parent_customer_id]) | |
| 76 | 77 | SELECT plan_name FROM customer_plans WHERE customer_id=$1 |
+10
-0
test/test_customer.rb
#
| ... | ... | @@ -114,6 +114,16 @@ class CustomerTest < Minitest::Test | |
| 114 | 114 | end | |
| 115 | 115 | em :test_bill_plan_update | |
| 116 | 116 | ||
| 117 | + | def test_save_plan_rejects_self_parent | |
| 118 | + | error = assert_raises(RuntimeError) do | |
| 119 | + | customer( | |
| 120 | + | plan_name: "test_usd", | |
| 121 | + | parent_customer_id: "test" | |
| 122 | + | ).save_plan! | |
| 123 | + | end | |
| 124 | + | assert_equal "Invalid parent account", error.message | |
| 125 | + | end | |
| 126 | + | ||
| 117 | 127 | def test_stanza_to | |
| 118 | 128 | Customer::BLATHER.expect( | |
| 119 | 129 | :<<, |