-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: remove tests for deprecated code
- Loading branch information
Showing
4 changed files
with
5 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
import os | ||
from typing import cast | ||
|
||
import pytest | ||
from dotenv import load_dotenv | ||
from faker import Faker | ||
|
||
from passageidentity import PassageError | ||
from passageidentity.openapi_client.models.app_info import AppInfo | ||
from passageidentity.openapi_client.models.magic_link import MagicLink | ||
from passageidentity.passage import Passage | ||
|
||
load_dotenv() | ||
|
@@ -19,50 +14,7 @@ | |
PASSAGE_AUTH_TOKEN = os.environ.get("PASSAGE_AUTH_TOKEN") or "" | ||
|
||
|
||
def test_valid_jwt() -> None: | ||
psg = Passage(PASSAGE_APP_ID, auth_strategy=Passage.HEADER_AUTH) | ||
user = psg.authenticateJWT(PASSAGE_AUTH_TOKEN) | ||
assert user == PASSAGE_USER_ID | ||
|
||
|
||
def test_invalid_jwt() -> None: | ||
psg = Passage(PASSAGE_APP_ID, auth_strategy=Passage.HEADER_AUTH) | ||
with pytest.raises(PassageError): | ||
psg.authenticateJWT("invalid_token") | ||
|
||
|
||
def test_validate_jwt() -> None: | ||
psg = Passage(PASSAGE_APP_ID, auth_strategy=Passage.HEADER_AUTH) | ||
user = psg.validateJwt(PASSAGE_AUTH_TOKEN) | ||
assert user == PASSAGE_USER_ID | ||
|
||
|
||
def test_get_app() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
app = cast(AppInfo, psg.getApp()) | ||
assert app.id == PASSAGE_APP_ID | ||
|
||
|
||
def test_create_magic_link() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
magic_link = cast( | ||
MagicLink, | ||
psg.createMagicLink( | ||
{ | ||
"email": "[email protected]", | ||
"channel": "email", | ||
"ttl": 12, | ||
}, # type: ignore[arg-type] | ||
), | ||
) | ||
assert magic_link.identifier == "[email protected]" | ||
assert magic_link.ttl == 12 | ||
|
||
|
||
def test_smart_link_valid() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
email = f.email() | ||
magic_link = cast(MagicLink, psg.createMagicLink({"email": email})) # type: ignore[arg-type] | ||
assert magic_link.identifier == email | ||
assert not magic_link.activated | ||
user = psg.auth.validate_jwt(PASSAGE_AUTH_TOKEN) | ||
assert user == PASSAGE_USER_ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import os | ||
from typing import cast | ||
|
||
import pytest | ||
from dotenv import load_dotenv | ||
from faker import Faker | ||
|
||
from passageidentity.errors import PassageError | ||
from passageidentity.openapi_client.models.passage_user import PassageUser | ||
from passageidentity.openapi_client.models.update_user_args import UpdateUserArgs | ||
from passageidentity.passage import Passage | ||
|
||
load_dotenv() | ||
|
@@ -19,151 +16,8 @@ | |
PASSAGE_AUTH_TOKEN = os.environ.get("PASSAGE_AUTH_TOKEN") or "" | ||
|
||
|
||
def test_get_by_identifier_valid_upper_case() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
email = f.email() | ||
new_user = cast(PassageUser, psg.createUser({"email": email})) # type: ignore[arg-type] | ||
assert new_user.email == email | ||
|
||
user_by_identifier = cast(PassageUser, psg.getUserByIdentifier(email.upper())) | ||
assert user_by_identifier.id == new_user.id | ||
|
||
user = cast(PassageUser, psg.user.get(new_user.id)) | ||
assert user.id == new_user.id | ||
|
||
assert user_by_identifier == user | ||
assert psg.user.delete(new_user.id) is None | ||
|
||
|
||
def test_get_by_identifier_user_not_exist() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
with pytest.raises(PassageError, match="User not found."): | ||
psg.user.get_by_identifier("[email protected]") | ||
|
||
|
||
def test_get_user_info_valid() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
user = cast(PassageUser, psg.getUser(PASSAGE_USER_ID)) | ||
assert user.id == PASSAGE_USER_ID | ||
|
||
|
||
def test_get_user_info_by_identifier_valid() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
email = f.email() | ||
new_user = cast(PassageUser, psg.createUser({"email": email})) # type: ignore[arg-type] | ||
assert new_user.email == email | ||
|
||
user_by_identifier = cast(PassageUser, psg.getUserByIdentifier(email)) | ||
assert user_by_identifier.id == new_user.id | ||
|
||
user = cast(PassageUser, psg.getUser(new_user.id)) | ||
assert user.id == new_user.id | ||
|
||
assert user_by_identifier == user | ||
assert psg.deleteUser(new_user.id) | ||
|
||
|
||
def test_get_user_info_by_identifier_phone_valid() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
phone = "+15005550030" | ||
new_user = cast(PassageUser, psg.createUser({"phone": phone})) # type: ignore[arg-type] | ||
assert new_user.phone == phone | ||
|
||
user_by_identifier = cast(PassageUser, psg.getUserByIdentifier(phone)) | ||
assert user_by_identifier.id == new_user.id | ||
|
||
user = cast(PassageUser, psg.getUser(new_user.id)) | ||
assert user.id == new_user.id | ||
|
||
assert user_by_identifier == user | ||
assert psg.deleteUser(new_user.id) | ||
|
||
|
||
def test_activate_user() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
user = cast(PassageUser, psg.activateUser(PASSAGE_USER_ID)) | ||
assert user.status == "active" | ||
|
||
|
||
def test_deactivate_user() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
user = cast(PassageUser, psg.getUser(PASSAGE_USER_ID)) | ||
user = cast(PassageUser, psg.deactivateUser(user.id)) | ||
assert user.status == "inactive" | ||
|
||
|
||
def test_list_user_devices() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
devices = cast(list, psg.listUserDevices(PASSAGE_USER_ID)) | ||
assert len(devices) == 2 | ||
|
||
|
||
def test_update_user_phone() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
phone = "+15005550021" | ||
new_user = cast(PassageUser, psg.createUser({"phone": phone})) # type: ignore[arg-type] | ||
|
||
phone = "+15005550022" | ||
user = cast(PassageUser, psg.updateUser(new_user.id, {"phone": phone})) # type: ignore[arg-type] | ||
assert user.phone == phone | ||
assert psg.deleteUser(new_user.id) | ||
|
||
|
||
def test_update_user_email() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
email = f.email() | ||
req = UpdateUserArgs(email=email) | ||
user = cast(PassageUser, psg.updateUser(PASSAGE_USER_ID, req)) | ||
assert user.email == email | ||
|
||
|
||
def test_update_user_with_metadata() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
email = f.email() | ||
user = cast(PassageUser, psg.updateUser(PASSAGE_USER_ID, {"email": email, "user_metadata": {"example1": "qwe"}})) # type: ignore[arg-type] | ||
assert user.email == email | ||
assert user.user_metadata["example1"] == "qwe" # type: ignore[index] | ||
|
||
user = cast(PassageUser, psg.updateUser(PASSAGE_USER_ID, {"email": email, "user_metadata": {"example1": "asd"}})) # type: ignore[arg-type] | ||
assert user.email == email | ||
assert user.user_metadata["example1"] == "asd" # type: ignore[index] | ||
|
||
|
||
def test_create_user_with_metadata() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
email = f.email() | ||
user = cast(PassageUser, psg.createUser({"email": email, "user_metadata": {"example1": "qwe"}})) # type: ignore[arg-type] | ||
assert user.email == email | ||
assert user.user_metadata["example1"] == "qwe" # type: ignore[index] | ||
assert psg.deleteUser(user.id) | ||
|
||
|
||
def test_create_and_delete_user() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
email = f.email() | ||
new_user = cast(PassageUser, psg.createUser({"email": email})) # type: ignore[arg-type] | ||
assert new_user.email == email | ||
assert psg.deleteUser(new_user.id) | ||
|
||
|
||
def test_sign_out() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
assert psg.signOut(PASSAGE_USER_ID) | ||
|
||
|
||
def test_revoke_user_refresh_tokens() -> None: | ||
psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) | ||
|
||
assert psg.revokeUserRefreshTokens(PASSAGE_USER_ID) |