fix topology of cards

This commit is contained in:
Udo
2026-12-02 12:43:23 +05:00
parent b3babe73bd
commit c3b33217e4
19 changed files with 1177 additions and 1845 deletions
+8 -21
View File
@@ -5,9 +5,9 @@ import pytest
from app import create_app
from app.config import Settings
from app.remnawave import RemnawaveError
from .fixtures import make_hosts, make_nodes, make_profile
from .fixtures import make_hosts, make_nodes, make_profiles
KEY = "aaaaaaaa-0000-0000-0000-000000000001"
KEY = "network-v2"
class FakeClient:
@@ -19,9 +19,7 @@ class FakeClient:
self.calls += 1
if self.fail:
raise RemnawaveError("панель недоступна", "upstream_unreachable")
other = {"uuid": "bbbbbbbb-0000-0000-0000-000000000002", "name": "Default",
"config": {"inbounds": [], "outbounds": [], "routing": {"rules": []}}, "inbounds": []}
return {"profiles": [other, make_profile()], "hosts": make_hosts(), "nodes": make_nodes()}
return {"profiles": make_profiles(), "hosts": make_hosts(), "nodes": make_nodes()}
def make_settings(tmp_path, **kw):
@@ -37,29 +35,18 @@ def client_and_fake(tmp_path):
return app.test_client(), fake
def test_graph_default_profile_is_the_one_with_vless_route(client_and_fake):
def test_graph_endpoint_returns_whole_network(client_and_fake):
c, _ = client_and_fake
r = c.get("/api/graph")
assert r.status_code == 200
body = r.get_json()
assert body["profile"]["name"] == "BridgeOverNetbird"
assert body["graph"]["warnings"]
g = body["graph"]
assert {n["type"] for n in g["nodes"]} == {"host", "node", "balancer", "outbound"}
assert g["warnings"] and g["paths"]
assert body["positionsKey"] == KEY
assert "SECRET" not in r.get_data(as_text=True)
def test_profile_by_name_and_unknown(client_and_fake):
c, _ = client_and_fake
assert c.get("/api/graph?profile=default").get_json()["profile"]["name"] == "Default"
r = c.get("/api/graph?profile=nope")
assert r.status_code == 404 and r.get_json()["error"] == "profile_not_found"
def test_profiles_list(client_and_fake):
c, _ = client_and_fake
names = [p["name"] for p in c.get("/api/profiles").get_json()["profiles"]]
assert names == ["Default", "BridgeOverNetbird"]
def test_cache_and_refresh_throttle(client_and_fake):
c, fake = client_and_fake
c.get("/api/graph"); c.get("/api/graph"); c.get("/api/profiles")