Skip to content

Commit b4cf014

Browse files
fix(tests): Use unique email in flaky custom auth integration test (#7113)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7beff52 commit b4cf014

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

api/tests/integration/custom_auth/end_to_end/test_custom_auth_integration.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_register_and_login__full_workflow__succeeds_with_password_reset(
2626
) -> None:
2727
# Given
2828
# try to register without first_name / last_name
29-
email = "test@example.com"
29+
email = f"test-{uuid.uuid4()}@example.com"
3030
password = FFAdminUser.objects.make_random_password()
3131
register_data = {
3232
"email": email,
@@ -105,7 +105,7 @@ def test_register__without_invite_when_disabled__returns_forbidden(
105105
db: None, api_client: APIClient
106106
) -> None:
107107
# Given
108-
email = "test@example.com"
108+
email = f"test-{uuid.uuid4()}@example.com"
109109
password = FFAdminUser.objects.make_random_password()
110110
register_data = {
111111
"email": email,
@@ -128,7 +128,7 @@ def test_register__with_invite_when_registration_disabled__returns_created(
128128
api_client: APIClient,
129129
) -> None:
130130
# Given
131-
email = "test@example.com"
131+
email = f"test-{uuid.uuid4()}@example.com"
132132
password = FFAdminUser.objects.make_random_password()
133133
organisation = Organisation.objects.create(name="Test Organisation")
134134
register_data = {
@@ -164,7 +164,7 @@ def test_register_and_login__activation_flow_enabled__succeeds_after_activation(
164164
"""
165165

166166
# Given user registration data
167-
email = "test@example.com"
167+
email = f"test-{uuid.uuid4()}@example.com"
168168
password = FFAdminUser.objects.make_random_password()
169169
register_data = {
170170
"email": email,
@@ -226,7 +226,7 @@ def test_login__mfa_enabled__succeeds_with_totp_and_backup_code(
226226
api_client: APIClient,
227227
) -> None:
228228
# Given
229-
email = "test@example.com"
229+
email = f"test-{uuid.uuid4()}@example.com"
230230
password = FFAdminUser.objects.make_random_password()
231231
register_data = {
232232
"email": email,
@@ -307,7 +307,7 @@ def test_register_and_login__jwt_cookie_enabled__sets_and_clears_cookies(
307307
api_client: APIClient,
308308
) -> None:
309309
# Given
310-
email = "test@example.com"
310+
email = f"test-{uuid.uuid4()}@example.com"
311311
password = FFAdminUser.objects.make_random_password()
312312
register_url = reverse("api-v1:custom_auth:ffadminuser-list")
313313
login_url = reverse("api-v1:custom_auth:custom-mfa-authtoken-login")
@@ -377,7 +377,7 @@ def test_login_workflow__jwt_cookie__mfa_enabled(
377377
api_client: APIClient,
378378
) -> None:
379379
# Given
380-
email = "test@example.com"
380+
email = f"test-{uuid.uuid4()}@example.com"
381381
password = FFAdminUser.objects.make_random_password()
382382
register_url = reverse("api-v1:custom_auth:ffadminuser-list")
383383
create_mfa_method_url = reverse(
@@ -438,7 +438,7 @@ def test_login_workflow__jwt_cookie__cors_headers_expected(
438438
api_client: APIClient,
439439
) -> None:
440440
# Given
441-
email = "test@example.com"
441+
email = f"test-{uuid.uuid4()}@example.com"
442442
password = FFAdminUser.objects.make_random_password()
443443
register_url = reverse("api-v1:custom_auth:ffadminuser-list")
444444
protected_resource_url = reverse("api-v1:projects:project-list")
@@ -467,7 +467,7 @@ def test_login__jwt_cookie_with_invalid_token__returns_unauthorized_without_cook
467467
api_client: APIClient,
468468
) -> None:
469469
# Given
470-
email = "test@example.com"
470+
email = f"test-{uuid.uuid4()}@example.com"
471471
password = FFAdminUser.objects.make_random_password()
472472
register_url = reverse("api-v1:custom_auth:ffadminuser-list")
473473
protected_resource_url = reverse("api-v1:projects:project-list")
@@ -504,7 +504,7 @@ def test_login__exceeds_throttle_rate__returns_too_many_requests(
504504
mocker.patch(
505505
"rest_framework.throttling.ScopedRateThrottle.get_rate", return_value="1/minute"
506506
)
507-
email = "test@example.com"
507+
email = f"test-{uuid.uuid4()}@example.com"
508508
password = FFAdminUser.objects.make_random_password()
509509
register_data = {
510510
"email": email,
@@ -619,11 +619,11 @@ def test_delete_token__valid_token__returns_no_content_and_invalidates(
619619
assert client.delete(delete_token_url).status_code == status.HTTP_401_UNAUTHORIZED
620620

621621

622-
def test_register__with_sign_up_type__stores_sign_up_type(client, db, settings): # type: ignore[no-untyped-def]
622+
def test_register__with_sign_up_type__stores_sign_up_type(client, db): # type: ignore[no-untyped-def]
623623
# Given
624624
password = FFAdminUser.objects.make_random_password()
625625
sign_up_type = "NO_INVITE"
626-
email = "test@example.com"
626+
email = f"test-{uuid.uuid4()}@example.com"
627627
register_data = {
628628
"email": email,
629629
"password": password,
@@ -655,7 +655,7 @@ def test_register__superuser_flag_on_selfhosted__creates_superuser(
655655
# Given
656656
mocker.patch("custom_auth.serializers.is_saas", return_value=False)
657657

658-
email = "test@example.com"
658+
email = f"test-{uuid.uuid4()}@example.com"
659659
password = FFAdminUser.objects.make_random_password()
660660
register_data = {
661661
"email": email,
@@ -683,7 +683,7 @@ def test_register__superuser_flag_on_saas__does_not_create_superuser(
683683
# Given
684684
mocker.patch("custom_auth.serializers.is_saas", return_value=True)
685685

686-
email = "test@example.com"
686+
email = f"test-{uuid.uuid4()}@example.com"
687687
password = FFAdminUser.objects.make_random_password()
688688
register_data = {
689689
"email": email,
@@ -710,7 +710,7 @@ def test_register__superuser_flag_when_users_exist__returns_bad_request(
710710
# Given
711711
mocker.patch("custom_auth.serializers.is_saas", return_value=False)
712712

713-
email = "test@example.com"
713+
email = f"test-{uuid.uuid4()}@example.com"
714714
password = FFAdminUser.objects.make_random_password()
715715
register_data = {
716716
"email": email,
@@ -742,7 +742,7 @@ def test_register__marketing_consent_given__defaults_to_true(
742742
# Given
743743
password = FFAdminUser.objects.make_random_password()
744744
register_data = {
745-
"email": "test@example.com",
745+
"email": f"test-{uuid.uuid4()}@example.com",
746746
"password": password,
747747
"re_password": password,
748748
"first_name": "user",

0 commit comments

Comments
 (0)