|
8 | 8 | from passageidentity import PassageError |
9 | 9 | from passageidentity.openapi_client.models.app_info import AppInfo |
10 | 10 | from passageidentity.openapi_client.models.magic_link import MagicLink |
11 | | -from passageidentity.openapi_client.models.update_user_request import UpdateUserRequest |
12 | | -from passageidentity.openapi_client.models.user_info import UserInfo |
13 | 11 | from passageidentity.passage import Passage |
14 | 12 |
|
15 | 13 | load_dotenv() |
16 | 14 | f = Faker() |
| 15 | + |
17 | 16 | PASSAGE_USER_ID = os.environ.get("PASSAGE_USER_ID") or "" |
18 | 17 | PASSAGE_APP_ID = os.environ.get("PASSAGE_APP_ID") or "" |
19 | 18 | PASSAGE_API_KEY = os.environ.get("PASSAGE_API_KEY") or "" |
@@ -57,164 +56,10 @@ def test_create_magic_link() -> None: |
57 | 56 | assert magic_link.ttl == 12 # type: ignore[attr-defined] |
58 | 57 |
|
59 | 58 |
|
60 | | -def test_get_user_info_valid() -> None: |
61 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
62 | | - user = cast(UserInfo, psg.getUser(PASSAGE_USER_ID)) |
63 | | - assert user.id == PASSAGE_USER_ID |
64 | | - |
65 | | - |
66 | | -def test_get_user_info_by_identifier_valid() -> None: |
67 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
68 | | - |
69 | | - email = f.email() |
70 | | - new_user = cast(UserInfo, psg.createUser({"email": email})) # type: ignore[arg-type] |
71 | | - assert new_user.email == email |
72 | | - |
73 | | - user_by_identifier = cast(UserInfo, psg.getUserByIdentifier(email)) |
74 | | - assert user_by_identifier.id == new_user.id |
75 | | - |
76 | | - user = cast(UserInfo, psg.getUser(new_user.id)) |
77 | | - assert user.id == new_user.id |
78 | | - |
79 | | - assert user_by_identifier == user |
80 | | - assert psg.deleteUser(new_user.id) |
81 | | - |
82 | | - |
83 | | -def test_get_user_info_by_identifier_valid_upper_case() -> None: |
84 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
85 | | - |
86 | | - email = f.email() |
87 | | - new_user = cast(UserInfo, psg.createUser({"email": email})) # type: ignore[arg-type] |
88 | | - assert new_user.email == email |
89 | | - |
90 | | - user_by_identifier = cast(UserInfo, psg.getUserByIdentifier(email.upper())) |
91 | | - assert user_by_identifier.id == new_user.id |
92 | | - |
93 | | - user = cast(UserInfo, psg.getUser(new_user.id)) |
94 | | - assert user.id == new_user.id |
95 | | - |
96 | | - assert user_by_identifier == user |
97 | | - assert psg.deleteUser(new_user.id) |
98 | | - |
99 | | - |
100 | | -def test_get_user_info_by_identifier_phone_valid() -> None: |
101 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
102 | | - |
103 | | - phone = "+15005550030" |
104 | | - new_user = cast(UserInfo, psg.createUser({"phone": phone})) # type: ignore[arg-type] |
105 | | - assert new_user.phone == phone |
106 | | - |
107 | | - user_by_identifier = cast(UserInfo, psg.getUserByIdentifier(phone)) |
108 | | - assert user_by_identifier.id == new_user.id |
109 | | - |
110 | | - user = cast(UserInfo, psg.getUser(new_user.id)) |
111 | | - assert user.id == new_user.id |
112 | | - |
113 | | - assert user_by_identifier == user |
114 | | - assert psg.deleteUser(new_user.id) |
115 | | - |
116 | | - |
117 | | -def test_get_user_info_by_identifier_error() -> None: |
118 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
119 | | - |
120 | | - with pytest.raises(PassageError, match="Could not find user with identifier"): |
121 | | - psg.getUserByIdentifier("error@passage.id") |
122 | | - |
123 | | - |
124 | | -def test_activate_user() -> None: |
125 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
126 | | - user = cast(UserInfo, psg.activateUser(PASSAGE_USER_ID)) |
127 | | - assert user.status == "active" |
128 | | - |
129 | | - |
130 | | -def test_deactivate_user() -> None: |
131 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
132 | | - |
133 | | - user = cast(UserInfo, psg.getUser(PASSAGE_USER_ID)) |
134 | | - user = cast(UserInfo, psg.deactivateUser(user.id)) |
135 | | - assert user.status == "inactive" |
136 | | - |
137 | | - |
138 | | -def test_list_user_devices() -> None: |
139 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
140 | | - |
141 | | - devices = cast(list, psg.listUserDevices(PASSAGE_USER_ID)) |
142 | | - assert len(devices) == 2 |
143 | | - |
144 | | - |
145 | | -def test_update_user_phone() -> None: |
146 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
147 | | - |
148 | | - phone = "+15005550021" |
149 | | - new_user = cast(UserInfo, psg.createUser({"phone": phone})) # type: ignore[arg-type] |
150 | | - |
151 | | - phone = "+15005550022" |
152 | | - user = cast(UserInfo, psg.updateUser(new_user.id, {"phone": phone})) # type: ignore[arg-type] |
153 | | - assert user.phone == phone |
154 | | - assert psg.deleteUser(new_user.id) |
155 | | - |
156 | | - |
157 | | -def test_update_user_email() -> None: |
158 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
159 | | - |
160 | | - email = f.email() |
161 | | - req = UpdateUserRequest(email=email) |
162 | | - user = cast(UserInfo, psg.updateUser(PASSAGE_USER_ID, req)) |
163 | | - assert user.email == email |
164 | | - |
165 | | - |
166 | | -def test_update_user_with_metadata() -> None: |
167 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
168 | | - |
169 | | - email = f.email() |
170 | | - user = cast(UserInfo, psg.updateUser(PASSAGE_USER_ID, {"email": email, "user_metadata": {"example1": "qwe"}})) # type: ignore[arg-type] |
171 | | - assert user.email == email |
172 | | - assert user.user_metadata["example1"] == "qwe" # type: ignore[index] |
173 | | - |
174 | | - user = cast(UserInfo, psg.updateUser(PASSAGE_USER_ID, {"email": email, "user_metadata": {"example1": "asd"}})) # type: ignore[arg-type] |
175 | | - assert user.email == email |
176 | | - assert user.user_metadata["example1"] == "asd" # type: ignore[index] |
177 | | - |
178 | | - |
179 | | -def test_create_user_with_metadata() -> None: |
180 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
181 | | - |
182 | | - email = f.email() |
183 | | - user = cast(UserInfo, psg.createUser({"email": email, "user_metadata": {"example1": "qwe"}})) # type: ignore[arg-type] |
184 | | - assert user.email == email |
185 | | - assert user.user_metadata["example1"] == "qwe" # type: ignore[index] |
186 | | - assert psg.deleteUser(user.id) |
187 | | - |
188 | | - |
189 | | -def test_get_user_info_user_does_not_exist() -> None: |
190 | | - pass |
191 | | - |
192 | | - |
193 | | -def test_create_and_delete_user() -> None: |
194 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
195 | | - |
196 | | - email = f.email() |
197 | | - new_user = cast(UserInfo, psg.createUser({"email": email})) # type: ignore[arg-type] |
198 | | - assert new_user.email == email |
199 | | - assert psg.deleteUser(new_user.id) |
200 | | - |
201 | | - |
202 | 59 | def test_smart_link_valid() -> None: |
203 | 60 | psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
204 | 61 |
|
205 | 62 | email = f.email() |
206 | 63 | magic_link = cast(MagicLink, psg.createMagicLink({"email": email})) # type: ignore[arg-type] |
207 | 64 | assert magic_link.identifier == email |
208 | 65 | assert not magic_link.activated |
209 | | - |
210 | | - |
211 | | -def test_sign_out() -> None: |
212 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
213 | | - |
214 | | - assert psg.signOut(PASSAGE_USER_ID) |
215 | | - |
216 | | - |
217 | | -def test_revoke_user_refresh_tokens() -> None: |
218 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
219 | | - |
220 | | - assert psg.revokeUserRefreshTokens(PASSAGE_USER_ID) |
0 commit comments