testmatrix 0.0.9__tar.gz → 0.1.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testmatrix
3
- Version: 0.0.9
3
+ Version: 0.1.0
4
4
  Summary: A matrix server sanity tester
5
5
  Author-email: Sebastian Spaeth <Sebastian@SSpaeth.de>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -17,7 +17,7 @@ License-File: LICENSE
17
17
  Requires-Dist: requests
18
18
  Dynamic: license-file
19
19
 
20
- # testmatrix
20
+ # testmatrix [![PyPI version](https://badge.fury.io/py/testmatrix.svg)](https://badge.fury.io/py/testmatrix) ![Matrix](https://img.shields.io/matrix/testmatrix:sspaeth.de?server_fqdn=chat.sspaeth.de&fetchMode=summary&link=https://matrix.to/#/#testmatrix:sspaeth.de)
21
21
 
22
22
  A matrix server sanity tester. Relased under the GNU AGPLv3+.
23
23
 
@@ -1,4 +1,4 @@
1
- # testmatrix
1
+ # testmatrix [![PyPI version](https://badge.fury.io/py/testmatrix.svg)](https://badge.fury.io/py/testmatrix) ![Matrix](https://img.shields.io/matrix/testmatrix:sspaeth.de?server_fqdn=chat.sspaeth.de&fetchMode=summary&link=https://matrix.to/#/#testmatrix:sspaeth.de)
2
2
 
3
3
  A matrix server sanity tester. Relased under the GNU AGPLv3+.
4
4
 
@@ -5,7 +5,7 @@
5
5
  from .matrixserver import MatrixServer
6
6
  from .jwtauth import JWTAuth
7
7
 
8
- __version__ = "0.0.9"
8
+ __version__ = "0.1.0"
9
9
  __all__ = ["MatrixServer", "JWTAuth"]
10
10
 
11
11
  # User Agent and possibly other required headers that we need for all requests
@@ -37,7 +37,7 @@ class MatrixServer:
37
37
  about results of our sanity checks.
38
38
  """
39
39
  self.args = args
40
- self.servername: str = servername
40
+ self.servername: str = servername.lower()
41
41
  self.federation_baseurl: str = ""
42
42
  self.client_baseurl: str = ""
43
43
  # result of client/versions as dict
@@ -147,16 +147,31 @@ class MatrixServer:
147
147
  self.client_baseurl = ""
148
148
  try:
149
149
  url = f"https://{self.servername}/.well-known/matrix/client"
150
+ # The .well-known file could sit behind redirects, and we need to
151
+ # manually check the CORS headers for each redirect step. Standard
152
+ # requests does not do this, so we need to do that manually. Sigh.
153
+ # TODO: a candidate for factoring out.
150
154
  r = requests.get(url, headers = req_headers)
151
- r.raise_for_status() # raise e.g. on 404
155
+ r.raise_for_status() # raise on status 400-600
152
156
  if self.diagnostics:
157
+ i = 0
158
+ for redirect in r.history:
159
+ i += 1
160
+ if not "Access-Control-Allow-Origin" in redirect.headers:
161
+ logging.error("𐄂 Client well-known redirect #{i} has no CORS header")
162
+ elif redirect.headers["Access-Control-Allow-Origin"] != "*":
163
+ logging.error("𐄂 Client well-known redirect #{i} has no proper CORS header: '%s'",
164
+ redirect.headers["Access-Control-Allow-Origin"])
165
+ else:
166
+ logging.info("✔ Client well-known redirect #{i} has proper CORS header")
153
167
  if not "Access-Control-Allow-Origin" in r.headers:
154
168
  logging.error("𐄂 Client well-known has no CORS header")
155
169
  elif r.headers["Access-Control-Allow-Origin"] != "*":
156
170
  logging.error("𐄂 Client well-known has no proper CORS header: '%s'",
157
171
  r.headers["Access-Control-Allow-Origin"])
158
172
  else:
159
- logging.info("✔ Client well-known exists and has proper CORS header")
173
+ logging.info("✔ Client well-known has proper CORS header")
174
+
160
175
  wellknown_client = r.json()
161
176
  except requests.exceptions.ConnectionError as e:
162
177
  if ("[Errno 11001] getaddrinfo failed" in str(e) or # Windows
@@ -251,7 +266,7 @@ class MatrixServer:
251
266
  logging.error("𐄂 Server keys response is no valid json")
252
267
  return False
253
268
 
254
- server_key_name = server_keys.get("server_name", None)
269
+ server_key_name = server_keys.get("server_name", "").lower()
255
270
  if self.servername != server_key_name:
256
271
  if self.diagnostics:
257
272
  logging.error("𐄂 Configured server name mismatch! "\
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testmatrix
3
- Version: 0.0.9
3
+ Version: 0.1.0
4
4
  Summary: A matrix server sanity tester
5
5
  Author-email: Sebastian Spaeth <Sebastian@SSpaeth.de>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -17,7 +17,7 @@ License-File: LICENSE
17
17
  Requires-Dist: requests
18
18
  Dynamic: license-file
19
19
 
20
- # testmatrix
20
+ # testmatrix [![PyPI version](https://badge.fury.io/py/testmatrix.svg)](https://badge.fury.io/py/testmatrix) ![Matrix](https://img.shields.io/matrix/testmatrix:sspaeth.de?server_fqdn=chat.sspaeth.de&fetchMode=summary&link=https://matrix.to/#/#testmatrix:sspaeth.de)
21
21
 
22
22
  A matrix server sanity tester. Relased under the GNU AGPLv3+.
23
23
 
File without changes
File without changes
File without changes
File without changes