testmatrix 0.2.2__tar.gz → 0.2.4__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.4}/PKG-INFO +1 -1
- {testmatrix-0.2.2 → testmatrix-0.2.4}/src/testmatrix/__init__.py +1 -1
- {testmatrix-0.2.2 → testmatrix-0.2.4}/src/testmatrix/jwtauth.py +0 -1
- {testmatrix-0.2.2 → testmatrix-0.2.4}/src/testmatrix/matrixserver.py +61 -13
- {testmatrix-0.2.2 → testmatrix-0.2.4}/testmatrix.egg-info/PKG-INFO +1 -1
- {testmatrix-0.2.2 → testmatrix-0.2.4}/LICENSE +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.4}/README.md +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.4}/pyproject.toml +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.4}/setup.cfg +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.4}/src/testmatrix/utils.py +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.4}/test_matrix.py +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.4}/testmatrix.egg-info/SOURCES.txt +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.4}/testmatrix.egg-info/dependency_links.txt +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.4}/testmatrix.egg-info/entry_points.txt +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.4}/testmatrix.egg-info/requires.txt +0 -0
- {testmatrix-0.2.2 → testmatrix-0.2.4}/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:
|
|
@@ -195,7 +200,9 @@ class MatrixServer:
|
|
|
195
200
|
if self.diagnostics:
|
|
196
201
|
logging.error("𐄂 Client well known is no valid json")
|
|
197
202
|
else:
|
|
198
|
-
|
|
203
|
+
client_baseurl = wellknown_client["m.homeserver"]["base_url"]
|
|
204
|
+
# strip final dashes
|
|
205
|
+
self.client_baseurl = client_baseurl.rstrip("/")
|
|
199
206
|
if self.diagnostics:
|
|
200
207
|
logging.debug(" Client url: %s",
|
|
201
208
|
self.loganon(self.client_baseurl,
|
|
@@ -217,7 +224,9 @@ class MatrixServer:
|
|
|
217
224
|
# Retrieve array of livekit instances or None
|
|
218
225
|
livekit_json = wellknown_client.get("org.matrix.msc4143.rtc_foci",
|
|
219
226
|
None)
|
|
220
|
-
self.parse_livekit_json(livekit_json)
|
|
227
|
+
livekit_detected = self.parse_livekit_json(livekit_json)
|
|
228
|
+
if livekit_detected:
|
|
229
|
+
logging.debug(" Livekit detected via client .well-known (deprecated)")
|
|
221
230
|
return self.client_baseurl
|
|
222
231
|
|
|
223
232
|
def get_server_version(self) -> str:
|
|
@@ -343,6 +352,44 @@ class MatrixServer:
|
|
|
343
352
|
logging.debug("✔ Server oauth metadata endpoint exists")
|
|
344
353
|
return res
|
|
345
354
|
|
|
355
|
+
def test_rtc_endpoint_msc4195(self) -> bool:
|
|
356
|
+
"""returns true if unstable rtc/transports returns info"""
|
|
357
|
+
res:bool = False # result
|
|
358
|
+
if self.args is None or self.args.token is None:
|
|
359
|
+
logging.info(" RTC Transport endpoint skipped, no auth token")
|
|
360
|
+
return False
|
|
361
|
+
try:
|
|
362
|
+
# TODO: once stable, use /_matrix/client/v1/rtc/transports
|
|
363
|
+
url = f"{self.client_baseurl}/_matrix/client/unstable/org.matrix.msc4143/rtc/transports"
|
|
364
|
+
headers = {"Authorization": f"Bearer {self.args.token}"}
|
|
365
|
+
headers.update(req_headers)
|
|
366
|
+
r = requests.get(url, headers = headers)
|
|
367
|
+
r.raise_for_status() # raise e.g. on 404
|
|
368
|
+
rtc_transports = r.json()
|
|
369
|
+
res = True
|
|
370
|
+
except requests.exceptions.HTTPError as e:
|
|
371
|
+
if e.response.status_code == 404:
|
|
372
|
+
logging.info("𐄂 RTC Transport (unstable) returns (404)")
|
|
373
|
+
elif e.response.status_code == 401:
|
|
374
|
+
logging.warning("𐄂 RTC Transport discovery needs authentication (use a token) (401)")
|
|
375
|
+
else:
|
|
376
|
+
logging.error("𐄂 RTC transport endpoints returns error %s", str(e))
|
|
377
|
+
res = False
|
|
378
|
+
except requests.exceptions.JSONDecodeError as e:
|
|
379
|
+
if self.diagnostics:
|
|
380
|
+
logging.error("𐄂 RTC transport response is no valid json")
|
|
381
|
+
res = False
|
|
382
|
+
if res:
|
|
383
|
+
rtc_transports = rtc_transports.get("rtc_transports", None)
|
|
384
|
+
livekit_detected = self.parse_livekit_json(rtc_transports)
|
|
385
|
+
if livekit_detected:
|
|
386
|
+
logging.debug("✔ Livekit detected via RTC transport endpoint")
|
|
387
|
+
else:
|
|
388
|
+
logging.warn("𐄂 RTC transport endpoints exists but no livekit detected")
|
|
389
|
+
elif self.diagnostics:
|
|
390
|
+
logging.info("𐄂 RTC transport endpoint problem")
|
|
391
|
+
return res
|
|
392
|
+
|
|
346
393
|
|
|
347
394
|
def test_qrcode_login(self) -> bool:
|
|
348
395
|
"""Returns true if QRcode login is setup (msc4108)"""
|
|
@@ -538,6 +585,7 @@ class MatrixServer:
|
|
|
538
585
|
self.get_server_version()
|
|
539
586
|
self.test_client_endpoint()
|
|
540
587
|
self.test_oauth_metadata()
|
|
588
|
+
self.test_rtc_endpoint_msc4195()
|
|
541
589
|
if self.diagnostics:
|
|
542
590
|
self.test_qrcode_login()
|
|
543
591
|
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
|