6
6
7
7
8
8
import pytest
9
+ import requests .exceptions
9
10
10
11
11
12
class TestAuth :
12
13
13
14
user = None
14
15
anonymous_user = None
15
- custom_token = None
16
- custom_token_with_claims = None
17
- custom_user = None
18
- custom_user_with_claims = None
19
16
20
- @pytest .mark .xfail
21
17
def test_sign_in_with_non_existing_account_email_and_password (self , auth , email , password ):
22
- assert auth .sign_in_with_email_and_password (email , password )
18
+ with pytest .raises (requests .exceptions .HTTPError ) as exc_info :
19
+ auth .sign_in_with_email_and_password (email , password )
20
+ assert "EMAIL_NOT_FOUND" in str (exc_info .value )
23
21
24
22
def test_create_user_with_email_and_password (self , auth , email , password ):
25
23
assert auth .create_user_with_email_and_password (email , password )
26
24
27
- @pytest .mark .xfail
28
25
def test_create_user_with_existing_email_and_password (self , auth , email , password ):
29
- assert auth .create_user_with_email_and_password (email , password )
26
+ with pytest .raises (requests .exceptions .HTTPError ) as exc_info :
27
+ auth .create_user_with_email_and_password (email , password )
28
+ assert "EMAIL_EXISTS" in str (exc_info .value )
30
29
31
- @pytest .mark .xfail
32
30
def test_sign_in_with_email_and_wrong_password (self , auth , email ):
33
- assert auth .sign_in_with_email_and_password (email , 'WrongPassword123' )
31
+ with pytest .raises (requests .exceptions .HTTPError ) as exc_info :
32
+ auth .sign_in_with_email_and_password (email , 'WrongPassword123' )
33
+ assert "INVALID_PASSWORD" in str (exc_info .value )
34
34
35
35
def test_sign_in_with_email_and_password (self , auth , email , password ):
36
36
user = auth .sign_in_with_email_and_password (email , password )
@@ -43,24 +43,16 @@ def test_sign_in_anonymous(self, auth):
43
43
assert user
44
44
45
45
def test_create_custom_token (self , auth ):
46
- token = auth .create_custom_token ('CreateCustomToken1' )
47
- self .__class__ .custom_token = token
48
- assert token
46
+ with pytest .raises (AttributeError ):
47
+ auth .create_custom_token ('CreateCustomToken1' )
49
48
50
49
def test_create_custom_token_with_claims (self , auth ):
51
- token = auth .create_custom_token ('CreateCustomToken2' , {'premium' : True })
52
- self .__class__ .custom_token_with_claims = token
53
- assert token
50
+ with pytest .raises (AttributeError ):
51
+ auth .create_custom_token ('CreateCustomToken2' , {'premium' : True })
54
52
55
53
def test_sign_in_with_custom_token (self , auth ):
56
- user1 = auth .sign_in_with_custom_token (self .__class__ .custom_token )
57
- user2 = auth .sign_in_with_custom_token (self .__class__ .custom_token_with_claims )
58
-
59
- self .__class__ .custom_user = user1
60
- self .__class__ .custom_user_with_claims = user2
61
-
62
- assert user1
63
- assert user2
54
+ with pytest .raises (requests .exceptions .HTTPError ):
55
+ auth .sign_in_with_custom_token (None )
64
56
65
57
def test_refresh (self , auth ):
66
58
assert auth .refresh (self .__class__ .user .get ('refreshToken' ))
@@ -87,5 +79,89 @@ def test_update_profile_display_name(self, auth):
87
79
def test_delete_user_account (self , auth ):
88
80
assert auth .delete_user_account (self .__class__ .user .get ('idToken' ))
89
81
assert auth .delete_user_account (self .__class__ .anonymous_user .get ('idToken' ))
90
- assert auth .delete_user_account (self .__class__ .custom_user .get ('idToken' ))
91
- assert auth .delete_user_account (self .__class__ .custom_user_with_claims .get ('idToken' ))
82
+
83
+
84
+ class TestAuthAdmin :
85
+
86
+ user = None
87
+ anonymous_user = None
88
+ custom_token = None
89
+ custom_token_with_claims = None
90
+ custom_user = None
91
+ custom_user_with_claims = None
92
+
93
+ def test_sign_in_with_non_existing_account_email_and_password (self , auth_admin , email , password ):
94
+ with pytest .raises (requests .exceptions .HTTPError ) as exc_info :
95
+ auth_admin .sign_in_with_email_and_password (email , password )
96
+ assert "EMAIL_NOT_FOUND" in str (exc_info .value )
97
+
98
+ def test_create_user_with_email_and_password (self , auth_admin , email , password ):
99
+ assert auth_admin .create_user_with_email_and_password (email , password )
100
+
101
+ def test_create_user_with_existing_email_and_password (self , auth_admin , email , password ):
102
+ with pytest .raises (requests .exceptions .HTTPError ) as exc_info :
103
+ auth_admin .create_user_with_email_and_password (email , password )
104
+ assert "EMAIL_EXISTS" in str (exc_info .value )
105
+
106
+ def test_sign_in_with_email_and_wrong_password (self , auth_admin , email ):
107
+ with pytest .raises (requests .exceptions .HTTPError ) as exc_info :
108
+ auth_admin .sign_in_with_email_and_password (email , 'WrongPassword123' )
109
+ assert "INVALID_PASSWORD" in str (exc_info .value )
110
+
111
+ def test_sign_in_with_email_and_password (self , auth_admin , email , password ):
112
+ user = auth_admin .sign_in_with_email_and_password (email , password )
113
+ self .__class__ .user = user
114
+ assert user
115
+
116
+ def test_sign_in_anonymous (self , auth_admin ):
117
+ user = auth_admin .sign_in_anonymous ()
118
+ self .__class__ .anonymous_user = user
119
+ assert user
120
+
121
+ def test_create_custom_token (self , auth_admin ):
122
+ token = auth_admin .create_custom_token ('CreateCustomToken1' )
123
+ self .__class__ .custom_token = token
124
+ assert token
125
+
126
+ def test_create_custom_token_with_claims (self , auth_admin ):
127
+ token = auth_admin .create_custom_token ('CreateCustomToken2' , {'premium' : True })
128
+ self .__class__ .custom_token_with_claims = token
129
+ assert token
130
+
131
+ def test_sign_in_with_custom_token (self , auth_admin ):
132
+ user1 = auth_admin .sign_in_with_custom_token (self .__class__ .custom_token )
133
+ user2 = auth_admin .sign_in_with_custom_token (self .__class__ .custom_token_with_claims )
134
+
135
+ self .__class__ .custom_user = user1
136
+ self .__class__ .custom_user_with_claims = user2
137
+
138
+ assert user1
139
+ assert user2
140
+
141
+ def test_refresh (self , auth_admin ):
142
+ assert auth_admin .refresh (self .__class__ .user .get ('refreshToken' ))
143
+
144
+ def test_get_account_info (self , auth_admin ):
145
+ assert auth_admin .get_account_info (self .__class__ .user .get ('idToken' ))
146
+
147
+ def test_send_email_verification (self , auth_admin ):
148
+ assert auth_admin .send_email_verification (self .__class__ .user .get ('idToken' ))
149
+
150
+ def test_send_password_reset_email (self , auth_admin ):
151
+ assert auth_admin .send_password_reset_email (self .__class__ .user .get ('email' ))
152
+
153
+ @pytest .mark .xfail
154
+ def test_verify_password_reset_code (self , auth_admin ):
155
+ assert auth_admin .verify_password_reset_code ('123456' , 'NewTestPassword123' )
156
+
157
+ def test_update_profile_display_name (self , auth_admin ):
158
+ new_name = 'Test User'
159
+ user = auth_admin .update_profile (self .__class__ .user .get ('idToken' ), display_name = new_name )
160
+ assert user
161
+ assert new_name == user ['displayName' ]
162
+
163
+ def test_delete_user_account (self , auth_admin ):
164
+ assert auth_admin .delete_user_account (self .__class__ .user .get ('idToken' ))
165
+ assert auth_admin .delete_user_account (self .__class__ .anonymous_user .get ('idToken' ))
166
+ assert auth_admin .delete_user_account (self .__class__ .custom_user .get ('idToken' ))
167
+ assert auth_admin .delete_user_account (self .__class__ .custom_user_with_claims .get ('idToken' ))
0 commit comments