Trying to get the Auth Types to work right.

Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
Cliff Hill
2024-01-29 16:09:27 -05:00
parent e64e500561
commit 77bc5fbfb1
4 changed files with 10 additions and 9 deletions

View File

@@ -229,7 +229,7 @@ def test_create_test_user_command(notify_db_session, notify_api):
# that user should be the one we added
user = User.query.filter_by(name="Fake Personson").first()
assert user.email_address == "somebody@fake.gov"
assert user.auth_type == "sms_auth"
assert user.auth_type == AuthType.SMS
assert user.state == "active"

View File

@@ -8,6 +8,7 @@ from app import encryption
from app.enums import (
AgreementStatus,
AgreementType,
AuthType,
NotificationStatus,
RecipientType,
TemplateType,
@@ -328,7 +329,7 @@ def test_user_can_use_webauthn_if_platform_admin(sample_user, is_platform_admin)
@pytest.mark.parametrize(
("auth_type", "can_use_webauthn"),
[("email_auth", False), ("sms_auth", False), ("webauthn_auth", True)],
[(AuthType.EMAIL, False), (AuthType.SMS, False), (AuthType.WEBAUTHN, True)],
)
def test_user_can_use_webauthn_if_they_login_with_it(
sample_user, auth_type, can_use_webauthn

View File

@@ -210,7 +210,7 @@ def test_cannot_create_user_with_sms_auth_and_no_mobile(
assert (
json_resp["message"]
== "Mobile number must be set if auth_type is set to sms_auth"
== "Mobile number must be set if auth_type is set to AuthType.SMS"
)
@@ -883,15 +883,15 @@ def test_activate_user_fails_if_already_active(admin_request, sample_user):
def test_update_user_auth_type(admin_request, sample_user):
assert sample_user.auth_type == "sms_auth"
assert sample_user.auth_type == AuthType.SMS
resp = admin_request.post(
"user.update_user_attribute",
user_id=sample_user.id,
_data={"auth_type": "email_auth"},
_data={"auth_type": AuthType.EMAIL},
)
assert resp["data"]["id"] == str(sample_user.id)
assert resp["data"]["auth_type"] == "email_auth"
assert resp["data"]["auth_type"] == AuthType.EMAIL
def test_can_set_email_auth_and_remove_mobile_at_same_time(admin_request, sample_user):
@@ -922,7 +922,7 @@ def test_cannot_remove_mobile_if_sms_auth(admin_request, sample_user):
assert (
json_resp["message"]
== "Mobile number must be set if auth_type is set to sms_auth"
== "Mobile number must be set if auth_type is set to AuthType.SMS"
)

View File

@@ -425,7 +425,7 @@ def test_reset_failed_login_count_returns_404_when_user_does_not_exist(client):
assert resp.status_code == 404
# we send sms_auth users and webauthn_auth users email code to validate their email access
# we send AuthType.SMS users and AuthType.WEBAUTHN users email code to validate their email access
@pytest.mark.parametrize("auth_type", AuthType)
@pytest.mark.parametrize(
"data, expected_auth_url",
@@ -514,7 +514,7 @@ def test_send_email_code_returns_404_for_bad_input_data(admin_request):
@freeze_time("2016-01-01T12:00:00")
# we send sms_auth and webauthn_auth users email code to validate their email access
# we send iAuthType.SMS and AuthType.WEBAUTHN users email code to validate their email access
@pytest.mark.parametrize("auth_type", AuthType)
def test_user_verify_email_code(admin_request, sample_user, auth_type):
sample_user.logged_in_at = datetime.utcnow() - timedelta(days=1)