testmatrix 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {testmatrix-0.2.2 → testmatrix-0.2.3}/PKG-INFO +1 -1
- {testmatrix-0.2.2 → testmatrix-0.2.3}/src/testmatrix/__init__.py +1 -1
- {testmatrix-0.2.2 → testmatrix-0.2.3}/src/testmatrix/jwtauth.py +0 -1
- {testmatrix-0.2.2 → testmatrix-0.2.3}/src/testmatrix/matrixserver.py +58 -12
- {testmatrix-0.2.2 → testmatrix-0.2.3}/testmatrix.egg-info/PKG-INFO +1 -1
- {testmatrix-0.2.2 → testmatrix-0.2.3}/LICENSE +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.3}/README.md +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.3}/pyproject.toml +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.3}/setup.cfg +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.3}/src/testmatrix/utils.py +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.3}/test_matrix.py +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.3}/testmatrix.egg-info/SOURCES.txt +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.3}/testmatrix.egg-info/dependency_links.txt +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.3}/testmatrix.egg-info/entry_points.txt +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.3}/testmatrix.egg-info/requires.txt +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.3}/testmatrix.egg-info/top_level.txt +0 -0
|
@@ -38,7 +38,6 @@ class JWTAuth:
|
|
|
38
38
|
s = f"𐄂 DNS Error resolving host {self.baseurl}"
|
|
39
39
|
logging.error(s)
|
|
40
40
|
else:
|
|
41
|
-
logging.debug(" JWTauth healtz url: %s", self.loganon(self.baseurl))
|
|
42
41
|
if r.status_code == 404:
|
|
43
42
|
logging.info(" jwtauth healthz endpoint does not exist at %s (404)",
|
|
44
43
|
self.loganon(url))
|
|
@@ -65,9 +65,12 @@ class MatrixServer:
|
|
|
65
65
|
|
|
66
66
|
def parse_livekit_json(self, livekit_json: Optional[list]) \
|
|
67
67
|
-> Optional[bool]:
|
|
68
|
-
"""Parses
|
|
68
|
+
"""Parses livekit json parts and initiates self.livekits
|
|
69
|
+
It works both with the client well-known and the
|
|
70
|
+
/_matrix/client/v1/rtc/transports endpoint.
|
|
69
71
|
|
|
70
|
-
Returns True (success), False (no Livekit) or None (Error)
|
|
72
|
+
Returns True (success), False (no Livekit) or None (Error)
|
|
73
|
+
"""
|
|
71
74
|
self.livekits = []
|
|
72
75
|
if livekit_json is None:
|
|
73
76
|
self.livekits = None
|
|
@@ -86,8 +89,6 @@ class MatrixServer:
|
|
|
86
89
|
continue
|
|
87
90
|
anon: bool = (self.args is not None) and self.args.anonymize
|
|
88
91
|
self.livekits.append(JWTAuth(livekit["livekit_service_url"], anon))
|
|
89
|
-
logging.debug(" Adding livekit service URL: %s",
|
|
90
|
-
livekit["livekit_service_url"])
|
|
91
92
|
return len(self.livekits) > 0
|
|
92
93
|
|
|
93
94
|
def get_server_baseurl(self) -> Optional[str]:
|
|
@@ -122,14 +123,18 @@ class MatrixServer:
|
|
|
122
123
|
logging.error("𐄂 Server well-known error %s", str(e))
|
|
123
124
|
except requests.exceptions.JSONDecodeError as e:
|
|
124
125
|
if self.diagnostics:
|
|
125
|
-
logging.error("𐄂 Server well
|
|
126
|
+
logging.error("𐄂 Server well-known is no valid json")
|
|
126
127
|
else:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
if not "m.server" in wellknown_server:
|
|
129
|
+
logging.warning("𐄂 Server well-known does not contain information about server!")
|
|
130
|
+
else:
|
|
131
|
+
self.federation_baseurl = \
|
|
132
|
+
"https://" + wellknown_server["m.server"]
|
|
133
|
+
if self.diagnostics:
|
|
134
|
+
logging.debug(" Federation url: %s",
|
|
135
|
+
self.loganon(self.federation_baseurl,
|
|
136
|
+
self.servername))
|
|
137
|
+
logging.info("✔ Server well-known exists")
|
|
133
138
|
|
|
134
139
|
# use default address in case of failed well-known
|
|
135
140
|
if not self.federation_baseurl:
|
|
@@ -217,7 +222,9 @@ class MatrixServer:
|
|
|
217
222
|
# Retrieve array of livekit instances or None
|
|
218
223
|
livekit_json = wellknown_client.get("org.matrix.msc4143.rtc_foci",
|
|
219
224
|
None)
|
|
220
|
-
self.parse_livekit_json(livekit_json)
|
|
225
|
+
livekit_detected = self.parse_livekit_json(livekit_json)
|
|
226
|
+
if livekit_detected:
|
|
227
|
+
logging.debug(" Livekit detected via client .well-known (deprecated)")
|
|
221
228
|
return self.client_baseurl
|
|
222
229
|
|
|
223
230
|
def get_server_version(self) -> str:
|
|
@@ -343,6 +350,44 @@ class MatrixServer:
|
|
|
343
350
|
logging.debug("✔ Server oauth metadata endpoint exists")
|
|
344
351
|
return res
|
|
345
352
|
|
|
353
|
+
def test_rtc_endpoint_msc4195(self) -> bool:
|
|
354
|
+
"""returns true if unstable rtc/transports returns info"""
|
|
355
|
+
res:bool = False # result
|
|
356
|
+
if self.args is None or self.args.token is None:
|
|
357
|
+
logging.info(" RTC Transport endpoint skipped, no auth token")
|
|
358
|
+
return False
|
|
359
|
+
try:
|
|
360
|
+
# TODO: once stable, use /_matrix/client/v1/rtc/transports
|
|
361
|
+
url = f"{self.client_baseurl}/_matrix/client/unstable/org.matrix.msc4143/rtc/transports"
|
|
362
|
+
headers = {"Authorization": f"Bearer {self.args.token}"}
|
|
363
|
+
headers.update(req_headers)
|
|
364
|
+
r = requests.get(url, headers = headers)
|
|
365
|
+
r.raise_for_status() # raise e.g. on 404
|
|
366
|
+
rtc_transports = r.json()
|
|
367
|
+
res = True
|
|
368
|
+
except requests.exceptions.HTTPError as e:
|
|
369
|
+
if e.response.status_code == 404:
|
|
370
|
+
logging.info("𐄂 RTC Transport (unstable) returns (404)")
|
|
371
|
+
elif e.response.status_code == 401:
|
|
372
|
+
logging.warning("𐄂 RTC Transport discovery needs authentication (use a token) (401)")
|
|
373
|
+
else:
|
|
374
|
+
logging.error("𐄂 RTC transport endpoints returns error %s", str(e))
|
|
375
|
+
res = False
|
|
376
|
+
except requests.exceptions.JSONDecodeError as e:
|
|
377
|
+
if self.diagnostics:
|
|
378
|
+
logging.error("𐄂 RTC transport response is no valid json")
|
|
379
|
+
res = False
|
|
380
|
+
if res:
|
|
381
|
+
rtc_transports = rtc_transports.get("rtc_transports", None)
|
|
382
|
+
livekit_detected = self.parse_livekit_json(rtc_transports)
|
|
383
|
+
if livekit_detected:
|
|
384
|
+
logging.debug("✔ Livekit detected via RTC transport endpoint")
|
|
385
|
+
else:
|
|
386
|
+
logging.warn("𐄂 RTC transport endpoints exists but no livekit detected")
|
|
387
|
+
elif self.diagnostics:
|
|
388
|
+
logging.info("𐄂 RTC transport endpoint problem")
|
|
389
|
+
return res
|
|
390
|
+
|
|
346
391
|
|
|
347
392
|
def test_qrcode_login(self) -> bool:
|
|
348
393
|
"""Returns true if QRcode login is setup (msc4108)"""
|
|
@@ -538,6 +583,7 @@ class MatrixServer:
|
|
|
538
583
|
self.get_server_version()
|
|
539
584
|
self.test_client_endpoint()
|
|
540
585
|
self.test_oauth_metadata()
|
|
586
|
+
self.test_rtc_endpoint_msc4195()
|
|
541
587
|
if self.diagnostics:
|
|
542
588
|
self.test_qrcode_login()
|
|
543
589
|
self.test_room_directory()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|