Skip to content

Commit 46017c5

Browse files
SCG:1.0.0:NA #2-workflowTest Added exploitable test cases
1 parent 27fcc86 commit 46017c5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_main.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,34 @@ def test_5(self):
5151
order_1 = c.Order(id="1", items=[service])
5252
self.assertEqual(c.validorder(order_1), "Invalid item type: service")
5353

54+
# Tricks the system and walks away with 1 television, despite valid payment & reimbursement
55+
def test_6(self):
56+
tv_item = c.Item(type="product", description="tv", amount=1000.00, quantity=1)
57+
payment = c.Item(
58+
type="payment", description="invoice_4", amount=1e19, quantity=1
59+
)
60+
payback = c.Item(
61+
type="payment", description="payback_4", amount=-1e19, quantity=1
62+
)
63+
order_4 = c.Order(id="4", items=[payment, tv_item, payback])
64+
self.assertEqual(
65+
c.validorder(order_4), "Order ID: 4 - Payment imbalance: $-1000.00"
66+
)
67+
68+
# Valid payments that should add up correctly, but do not
69+
def test_7(self):
70+
small_item = c.Item(
71+
type="product", description="accessory", amount=3.3, quantity=1
72+
)
73+
payment_1 = c.Item(
74+
type="payment", description="invoice_5_1", amount=1.1, quantity=1
75+
)
76+
payment_2 = c.Item(
77+
type="payment", description="invoice_5_2", amount=2.2, quantity=1
78+
)
79+
order_5 = c.Order(id="5", items=[small_item, payment_1, payment_2])
80+
self.assertEqual(c.validorder(order_5), "Order ID: 5 - Full payment received!")
81+
5482

5583
if __name__ == "__main__":
5684
unittest.main()

0 commit comments

Comments
 (0)