Skip to content

Commit

Permalink
Handle users passing us bad email IDs (#15831)
Browse files Browse the repository at this point in the history
* Add a failing test

* Handle users passing us bad email IDs
  • Loading branch information
di committed Apr 22, 2024
1 parent b09edd1 commit 1e35a5d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions tests/unit/manage/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,12 +691,13 @@ def test_reverify_email_ratelimit_exceeded(self, monkeypatch):
assert send_email.calls == []
assert email.user.record_event.calls == []

def test_reverify_email_not_found(self, monkeypatch):
@pytest.mark.parametrize("reverify_email_id", ["9999", "wutang"])
def test_reverify_email_not_found(self, monkeypatch, reverify_email_id):
def raise_no_result():
raise NoResultFound

request = pretend.stub(
POST={"reverify_email_id": "9999"},
POST={"reverify_email_id": reverify_email_id},
db=pretend.stub(
query=lambda *a: pretend.stub(
filter=lambda *a: pretend.stub(one=raise_no_result)
Expand Down
2 changes: 1 addition & 1 deletion warehouse/manage/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def reverify_email(self):
)
.one()
)
except NoResultFound:
except (NoResultFound, ValueError):
self.request.session.flash("Email address not found", queue="error")
return self.default_response

Expand Down

0 comments on commit 1e35a5d

Please sign in to comment.