File: test_wireguard.py

package info (click to toggle)
python-proton-vpn-api-core 4.16.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,312 kB
  • sloc: python: 11,057; makefile: 9
file content (21 lines) | stat: -rw-r--r-- 668 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os

import pytest
from proton.vpn.backend.networkmanager.protocol.wireguard.wireguard import FWMARK_ENV_VAR, get_fwmark_from_env_var


def test_get_fwmark_from_env_var_returns_env_var_value_if_available_and_valid():
    os.environ[FWMARK_ENV_VAR] = "51821"
    assert get_fwmark_from_env_var() == 51821


@pytest.mark.parametrize(
        "env_var_value", [
            "51820",  # too small
            str(2**32),  # too big
            "#!!?"  # invalid int,
        ]
)
def test_get_fwmark_from_env_var_returns_None_if_env_var_contains_invalid_value(env_var_value):
    os.environ[FWMARK_ENV_VAR] = env_var_value
    assert get_fwmark_from_env_var() is None