Skip to content

Commit

Permalink
Add security-related test to the new settle endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptiste Jonglez committed Mar 31, 2024
1 parent 9a84858 commit 01d515c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ihatemoney/tests/budget_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,24 @@ def test_access_other_projects(self):
member = models.Person.query.filter(models.Person.id == 1).one_or_none()
assert member is None

# test new settle endpoint to add bills with wrong payer / payed_for
self.client.post("/exit")
self.client.post(
"/authenticate", data={"id": "tartiflette", "password": "tartiflette"}
)
self.client.post(
"/tartiflette/settle",
data={
"sender_id": 4,
"receiver_id": 5,
"amount": "42.0",
},
)
piratebill = models.Bill.query.filter(
models.Bill.bill_type == models.BillType.REIMBURSEMENT
).one_or_none()
assert piratebill is None, "piratebill 3 should not exist"

@pytest.mark.skip(reason="Currency conversion is broken")
def test_currency_switch(self):
# A project should be editable
Expand Down
1 change: 1 addition & 0 deletions ihatemoney/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@ def add_settlement_bill():
)
return redirect(url_for(".settle_bill"))

# TODO: check that sender and receiver ID are valid and part of this project

settlement = Bill(
amount=form.amount.data,
Expand Down

0 comments on commit 01d515c

Please sign in to comment.