Skip to content

Missing verified email url #3406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tests/unit/forklift/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,10 @@ def test_fails_with_admin_flag_set(self, pyramid_config, db_request):
),
})

db_request.route_url = pretend.call_recorder(
lambda route, **kw: "/the/help/url/"
)

with pytest.raises(HTTPForbidden) as excinfo:
legacy.file_upload(db_request)

Expand All @@ -1052,7 +1056,7 @@ def test_fails_with_admin_flag_set(self, pyramid_config, db_request):
assert resp.status_code == 403
assert resp.status == ("403 New Project Registration Temporarily "
"Disabled See "
"https://pypi.org/help#admin-intervention for "
"/the/help/url/ for "
"details")

def test_upload_fails_without_file(self, pyramid_config, db_request):
Expand Down Expand Up @@ -2742,6 +2746,10 @@ def test_upload_requires_verified_email(self, pyramid_config, db_request,
db_request.find_service = lambda svc, name=None: storage_service
db_request.remote_addr = "10.10.10.10"

db_request.route_url = pretend.call_recorder(
lambda route, **kw: "/the/help/url/"
)

if expected_success:
resp = legacy.file_upload(db_request)
assert resp.status_code == 200
Expand All @@ -2755,7 +2763,7 @@ def test_upload_requires_verified_email(self, pyramid_config, db_request,
"addresses, please verify at least one "
"address before registering a new project "
"on PyPI. See "
"https://pypi.org/help/#verified-email "
"/the/help/url/ "
"for more information.").format(user.username)
)

Expand Down
13 changes: 9 additions & 4 deletions warehouse/forklift/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,10 @@ def file_upload(request):
raise _exc_with_message(
HTTPForbidden,
("New Project Registration Temporarily Disabled "
"See https://pypi.org/help#admin-intervention for details"),
"See {projecthelp} for details")
.format(
projecthelp=request.route_url(
'help', _anchor='admin-intervention')),
) from None

# Ensure that user has at least one verified email address. This should
Expand All @@ -811,9 +814,11 @@ def file_upload(request):
HTTPBadRequest,
("User {!r} has no verified email addresses, please verify "
"at least one address before registering a new project on "
"PyPI. See https://pypi.org/help/#verified-email "
"for more information.")
.format(request.user.username),
"PyPI. See {projecthelp} for more information.")
.format(
request.user.username,
projecthelp=request.route_url(
'help', _anchor='verified-email')),
) from None

# Before we create the project, we're going to check our blacklist to
Expand Down