Add Transparent Proxy and PROXY v2 support and help page
This commit is contained in:
@@ -43,6 +43,13 @@ class AuthTest(AppCase):
|
||||
self.assertEqual(self.client.get("/settings").status_code, 302)
|
||||
self.assertEqual(self.client.get("/api/graph").status_code, 401)
|
||||
|
||||
def test_help_page(self):
|
||||
self.assertEqual(self.client.get("/help").status_code, 302)
|
||||
self.login()
|
||||
r = self.client.get("/help")
|
||||
self.assertEqual(r.status_code, 200)
|
||||
self.assertIn(b"Transparent source spoofing", r.data)
|
||||
|
||||
def test_user_management_sysop_only(self):
|
||||
self.login()
|
||||
tok = self.token()
|
||||
|
||||
@@ -48,6 +48,16 @@ class ValidateTest(unittest.TestCase):
|
||||
n, _ = validate.graph({"nodes": [{"id": -3, "type": "public_sink", "port": 1, "iface": "x"}], "links": []}, {1})
|
||||
self.assertEqual(n[0]["iface"], "")
|
||||
|
||||
def test_origin(self):
|
||||
sink = {"id": -1, "type": "tunnel_sink", "port": 80, "iface": "tun0", "origin": "proxy_v2"}
|
||||
src = {"id": -2, "type": "client_source", "client_id": 1, "port": 80, "origin": "transparent"}
|
||||
nodes, _ = validate.graph({"nodes": [sink, src], "links": []}, {1})
|
||||
self.assertEqual(nodes[0]["origin"], "proxy_v2")
|
||||
self.assertEqual(nodes[1]["origin"], "") # only sinks carry an origin
|
||||
with self.assertRaises(validate.Invalid):
|
||||
validate.graph({"nodes": [dict(sink, origin="both")], "links": []}, {1})
|
||||
|
||||
|
||||
|
||||
class GraphApiTest(AppCase):
|
||||
def test_roundtrip_keeps_ids(self):
|
||||
@@ -61,7 +71,8 @@ class GraphApiTest(AppCase):
|
||||
"nodes": [
|
||||
{"id": -1, "type": "client_source", "client_id": cid, "host": "127.0.0.1", "port": 22, "proto": "tcp", "x": 0, "y": 0},
|
||||
{"id": -2, "type": "splitter", "x": 100, "y": 0},
|
||||
{"id": -3, "type": "public_sink", "host": "0.0.0.0", "port": 2200, "proto": "tcp", "x": 200, "y": 0},
|
||||
{"id": -3, "type": "public_sink", "host": "0.0.0.0", "port": 2200, "proto": "tcp",
|
||||
"origin": "transparent", "x": 200, "y": 0},
|
||||
],
|
||||
"links": [{"from": -1, "to": -2}, {"from": -2, "to": -3}],
|
||||
}
|
||||
@@ -73,6 +84,7 @@ class GraphApiTest(AppCase):
|
||||
g = self.client.get("/api/graph").get_json()
|
||||
self.assertEqual(len(g["nodes"]), 3)
|
||||
sink_id = ids["-3"]
|
||||
self.assertEqual(next(n for n in g["nodes"] if n["id"] == sink_id)["origin"], "transparent")
|
||||
# Saving again with real ids keeps them (stats are keyed by sink id).
|
||||
for n in payload["nodes"]:
|
||||
n["id"] = ids[str(n["id"])]
|
||||
|
||||
Reference in New Issue
Block a user