1
1
from __future__ import annotations
2
2
3
- import random
4
- import string
5
- from typing import TYPE_CHECKING , Any , Union
3
+ from typing import Any
6
4
7
5
import pytest
8
- from gotrue import Session , User
9
-
10
- if TYPE_CHECKING :
11
- from supabase import Client
12
-
13
-
14
- def _random_string (length : int = 10 ) -> str :
15
- """Generate random string."""
16
- return "" .join (random .choices (string .ascii_uppercase + string .digits , k = length ))
17
-
18
-
19
- def _assert_authenticated_user (data : Union [Session , User , str , None ]) -> None :
20
- """Raise assertion error if user is not logged in correctly."""
21
- assert data is not None
22
- assert isinstance (data , Session )
23
- assert data .user is not None
24
- assert data .user .aud == "authenticated"
25
6
26
7
27
8
@pytest .mark .xfail (
@@ -34,25 +15,3 @@ def test_incorrect_values_dont_instanciate_client(url: Any, key: Any) -> None:
34
15
from supabase import Client , create_client
35
16
36
17
_ : Client = create_client (url , key )
37
-
38
-
39
- @pytest .mark .skip (reason = "TO FIX: Session does not terminate with test included." )
40
- def test_client_auth (supabase : Client ) -> None :
41
- """Ensure we can create an auth user, and login with it."""
42
- # Create a random user login email and password.
43
- random_email = f"{ _random_string (10 )} @supamail.com"
44
- random_password = _random_string (20 )
45
- # Sign up (and sign in).
46
- user = supabase .auth .sign_up (
47
- email = random_email ,
48
- password = random_password ,
49
- phone = None ,
50
- )
51
- _assert_authenticated_user (user )
52
- # Sign out.
53
- supabase .auth .sign_out ()
54
- assert supabase .auth .user () is None
55
- assert supabase .auth .session () is None
56
- # Sign in (explicitly this time).
57
- user = supabase .auth .sign_in (email = random_email , password = random_password )
58
- _assert_authenticated_user (user )
0 commit comments