mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 20:36:27 +00:00
✨ Add email validation (#40)
* modify tests * ➕ Add email-validator to Dockerfiles * ♻️ Update random email generation * ♻️ Re-apply email validation after rebase Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@ from app import crud
|
||||
from app.core import config
|
||||
from app.db.session import db_session
|
||||
from app.schemas.user import UserCreate, UserUpdate
|
||||
from app.tests.utils.utils import get_server_api, random_lower_string
|
||||
from app.tests.utils.utils import get_server_api, random_lower_string, random_email
|
||||
|
||||
|
||||
def user_authentication_headers(server_api, email, password):
|
||||
@@ -18,7 +18,7 @@ def user_authentication_headers(server_api, email, password):
|
||||
|
||||
|
||||
def create_random_user():
|
||||
email = random_lower_string()
|
||||
email = random_email()
|
||||
password = random_lower_string()
|
||||
user_in = UserCreate(username=email, email=email, password=password)
|
||||
user = crud.user.create(db_session=db_session, obj_in=user_in)
|
||||
|
||||
@@ -2,7 +2,6 @@ import random
|
||||
import string
|
||||
|
||||
import requests
|
||||
|
||||
from app.core import config
|
||||
|
||||
|
||||
@@ -10,6 +9,10 @@ def random_lower_string():
|
||||
return "".join(random.choices(string.ascii_lowercase, k=32))
|
||||
|
||||
|
||||
def random_email():
|
||||
return f"{random_lower_string()}@{random_lower_string()}.com"
|
||||
|
||||
|
||||
def get_server_api():
|
||||
server_name = f"http://{config.SERVER_NAME}"
|
||||
return server_name
|
||||
|
||||
Reference in New Issue
Block a user