| 1 |
from unittest.mock import patch |
| 2 |
|
| 3 |
from allauth.mfa.adapter import get_adapter |
| 4 |
|
| 5 |
|
| 6 |
def test_build_totp_url_encodes_spaces_as_percent(user): |
| 7 |
"""Spaces in the issuer name should be percent-encoded (%20), not encoded as |
| 8 |
'+', so that authenticator apps display the issuer correctly. |
| 9 |
""" |
| 10 |
adapter = get_adapter() |
| 11 |
with patch.object(adapter, "get_totp_issuer", return_value="My Company"): |
| 12 |
url = adapter.build_totp_url(user, "JBSWY3DPEHPK3PXP") |
| 13 |
assert "issuer=My%20Company" in url |
| 14 |
assert "issuer=My+Company" not in url |