Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions proton/vpn/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ def supports_fido2(self) -> bool:
This only returns True if both conditions are met and if the user
is currently authenticating a session that requires 2FA.
"""
lib_available = self.is_fido2_lib_available
supports_fido2 = self._session_holder.session.supports_fido2
session = self._session_holder.session
lib_available = session.fido2_lib_available
supports_fido2 = session.supports_fido2
return bool(lib_available and supports_fido2)

async def generate_2fa_fido2_assertion(
Expand Down
47 changes: 47 additions & 0 deletions tests/python/core/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Copyright (c) 2026 Proton AG

This file is part of Proton VPN.

Proton VPN is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
"""
from types import SimpleNamespace

import pytest

from proton.vpn.core.api import ProtonVPNAPI


@pytest.mark.parametrize(
"library_available,registered_key,expected",
[
(False, False, False),
(False, True, False),
(True, False, False),
(True, True, True),
],
)
def test_supports_fido2_uses_current_session_capabilities(
monkeypatch, library_available, registered_key, expected
):
api = object.__new__(ProtonVPNAPI)
api._session_holder = SimpleNamespace(
session=SimpleNamespace(
fido2_lib_available=library_available,
supports_fido2=registered_key,
)
)

def fail_if_deprecated_property_is_used(_api):
pytest.fail("supports_fido2 called the deprecated capability property")

monkeypatch.setattr(
ProtonVPNAPI,
"is_fido2_lib_available",
property(fail_if_deprecated_property_is_used),
)

assert api.supports_fido2 is expected