mirror of
https://github.com/remnawave/python-sdk.git
synced 2026-05-13 12:16:42 +00:00
- Implemented `fetch_users_ips` and `get_fetch_users_ips_result` in `IpControlController`. - Added `get_recap` endpoint in `SystemController`. - Introduced new models for user IP fetching and recap statistics in `models/ip_control.py` and `models/system.py`. - Updated existing models and enums to accommodate new features. - Added tests for new endpoints and model validations.
131 lines
3.8 KiB
Python
131 lines
3.8 KiB
Python
"""Tests for enum completeness against the OpenAPI spec."""
|
|
import pytest
|
|
|
|
from remnawave.enums import (
|
|
ALPN,
|
|
ClientType,
|
|
Fingerprint,
|
|
OAuth2Provider,
|
|
SecurityLayer,
|
|
TemplateType,
|
|
TrafficLimitStrategy,
|
|
UserStatus,
|
|
ResponseRuleConditionOperator,
|
|
ResponseRuleOperator,
|
|
ResponseRuleVersion,
|
|
ResponseType,
|
|
SubscriptionType,
|
|
TTorrentBlockerEvents,
|
|
)
|
|
|
|
|
|
class TestOAuth2Provider:
|
|
def test_has_telegram(self):
|
|
assert OAuth2Provider.TELEGRAM == "telegram"
|
|
|
|
def test_has_generic(self):
|
|
assert OAuth2Provider.GENERIC == "generic"
|
|
|
|
def test_has_github(self):
|
|
assert OAuth2Provider.GITHUB == "github"
|
|
|
|
def test_has_pocketid(self):
|
|
assert OAuth2Provider.POCKETID == "pocketid"
|
|
|
|
def test_has_yandex(self):
|
|
assert OAuth2Provider.YANDEX == "yandex"
|
|
|
|
def test_has_keycloak(self):
|
|
assert OAuth2Provider.KEYCLOAK == "keycloak"
|
|
|
|
def test_all_values(self):
|
|
expected = {"telegram", "github", "pocketid", "yandex", "keycloak", "generic"}
|
|
actual = {v.value for v in OAuth2Provider}
|
|
assert actual == expected
|
|
|
|
|
|
class TestTemplateType:
|
|
def test_has_xray_base64(self):
|
|
assert TemplateType.XRAY_BASE64 == "XRAY_BASE64"
|
|
|
|
def test_has_xray_json(self):
|
|
assert TemplateType.XRAY_JSON == "XRAY_JSON"
|
|
|
|
def test_all_api_values(self):
|
|
api_values = {"XRAY_JSON", "XRAY_BASE64", "MIHOMO", "STASH", "CLASH", "SINGBOX"}
|
|
actual = {v.value for v in TemplateType}
|
|
assert api_values.issubset(actual)
|
|
|
|
|
|
class TestTrafficLimitStrategy:
|
|
def test_has_month_rolling(self):
|
|
assert TrafficLimitStrategy.MONTH_ROLLING == "MONTH_ROLLING"
|
|
|
|
def test_all_api_values(self):
|
|
api_values = {"NO_RESET", "DAY", "WEEK", "MONTH", "MONTH_ROLLING"}
|
|
actual = {v.value for v in TrafficLimitStrategy}
|
|
assert api_values == actual
|
|
|
|
|
|
class TestUserStatus:
|
|
def test_all_values(self):
|
|
expected = {"ACTIVE", "DISABLED", "LIMITED", "EXPIRED"}
|
|
actual = {v.value for v in UserStatus}
|
|
assert actual == expected
|
|
|
|
|
|
class TestClientType:
|
|
def test_api_values_present(self):
|
|
api_values = {"stash", "singbox", "mihomo", "json", "v2ray-json", "clash"}
|
|
actual = {v.value for v in ClientType}
|
|
assert api_values.issubset(actual)
|
|
|
|
|
|
class TestSecurityLayer:
|
|
def test_all_values(self):
|
|
expected = {"DEFAULT", "TLS", "NONE"}
|
|
actual = {v.value for v in SecurityLayer}
|
|
assert actual == expected
|
|
|
|
|
|
class TestFingerprint:
|
|
def test_all_api_values(self):
|
|
api_values = {"chrome", "firefox", "safari", "ios", "android", "edge", "qq", "random", "randomized"}
|
|
actual = {v.value for v in Fingerprint}
|
|
assert api_values == actual
|
|
|
|
|
|
class TestALPN:
|
|
def test_has_h3(self):
|
|
assert "h3" in {v.value for v in ALPN}
|
|
|
|
def test_has_h2(self):
|
|
assert "h2" in {v.value for v in ALPN}
|
|
|
|
|
|
class TestResponseRuleOperator:
|
|
def test_all_values(self):
|
|
expected = {"AND", "OR"}
|
|
actual = {v.value for v in ResponseRuleOperator}
|
|
assert actual == expected
|
|
|
|
|
|
class TestResponseRuleConditionOperator:
|
|
def test_all_values(self):
|
|
expected = {
|
|
"EQUALS", "NOT_EQUALS", "CONTAINS", "NOT_CONTAINS",
|
|
"STARTS_WITH", "NOT_STARTS_WITH", "ENDS_WITH", "NOT_ENDS_WITH",
|
|
"REGEX", "NOT_REGEX",
|
|
}
|
|
actual = {v.value for v in ResponseRuleConditionOperator}
|
|
assert actual == expected
|
|
|
|
|
|
class TestResponseType:
|
|
def test_all_values(self):
|
|
expected = {
|
|
"XRAY_JSON", "XRAY_BASE64", "MIHOMO", "STASH", "CLASH", "SINGBOX",
|
|
"BROWSER", "BLOCK", "STATUS_CODE_404", "STATUS_CODE_451", "SOCKET_DROP",
|
|
}
|
|
actual = {v.value for v in ResponseType}
|
|
assert actual == expected
|