fix: deprecate passwords, use phone auth source of truth
This commit is contained in:
@@ -47,3 +47,32 @@ def test_phone_auth_creates_user_and_issues_tokens(client):
|
||||
user = User.objects.filter(phone_number="+966512345678").first()
|
||||
assert user is not None
|
||||
assert user.is_phone_verified is True
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@override_settings(OTP_PROVIDER="console")
|
||||
def test_phone_auth_refresh_endpoint_still_works(client):
|
||||
with patch("apps.accounts.services.otp.generate_code", return_value="123456"):
|
||||
request_response = client.post(
|
||||
reverse("phone_auth_request"),
|
||||
{"phone_number": "0512345678", "channel": "sms"},
|
||||
content_type="application/json",
|
||||
)
|
||||
request_id = request_response.json()["request_id"]
|
||||
|
||||
verify_response = client.post(
|
||||
reverse("phone_auth_verify"),
|
||||
{"request_id": request_id, "code": "123456"},
|
||||
content_type="application/json",
|
||||
)
|
||||
|
||||
assert verify_response.status_code == 200
|
||||
refresh = verify_response.json()["refresh"]
|
||||
|
||||
refresh_response = client.post(
|
||||
reverse("token_refresh"),
|
||||
{"refresh": refresh},
|
||||
content_type="application/json",
|
||||
)
|
||||
assert refresh_response.status_code == 200
|
||||
assert "access" in refresh_response.json()
|
||||
|
||||
Reference in New Issue
Block a user