Changeset: 1fcacf33ea8b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1fcacf33ea8b
Added Files:
clients/mapilib/Tests/systemcertificates.py
Modified Files:
clients/mapilib/Tests/All
clients/mapilib/Tests/tlssecurity.py
Branch: monetdburl
Log Message:
Test connections using the system certificates
diffs (53 lines):
diff --git a/clients/mapilib/Tests/All b/clients/mapilib/Tests/All
--- a/clients/mapilib/Tests/All
+++ b/clients/mapilib/Tests/All
@@ -1,2 +1,3 @@
murltest
HAVE_OPENSSL?tlssecurity
+HAVE_OPENSSL?systemcertificates
diff --git a/clients/mapilib/Tests/systemcertificates.py
b/clients/mapilib/Tests/systemcertificates.py
new file mode 100755
--- /dev/null
+++ b/clients/mapilib/Tests/systemcertificates.py
@@ -0,0 +1,29 @@
+
+
+import subprocess
+import sys
+
+# Test that certificates from the system trust store are used when no explicit
+# certificate is given.
+#
+# # If all goes well, this will give a protocol error (MAPI != HTTP),
+# not a TLS error
+
+# Ideally we'd use www.monetdb.org but, but at the time of writing
www.monetdb.org
+# only returns an error after a 20 second time out.
+#
+# python.org on the other hand uses a CDN which kicks us out instantly.
+HOST = 'python.org'
+
+# Run mclient
+cmd = ['mclient', '-d', f"monetdbs://{HOST}:443/demo"]
+proc = subprocess.run(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+assert proc.returncode == 2, f"mclient is supposed to exit with status 2, not
{proc.returncode}"
+
+# We expect the server to send something like 'HTTP/1.1 400 Bad Request'
+# libmapi will interpret the first two bytes as a block header.
+#
+# In ASCII, 'H' + 256 * 'T' is 21576.
+if b'21576' not in proc.stderr:
+ print(f"Expected mclient to print an error message containing the number
21576, got:\n{proc.stderr}\n", file=sys.stderr)
+ exit(1)
diff --git a/clients/mapilib/Tests/tlssecurity.py
b/clients/mapilib/Tests/tlssecurity.py
--- a/clients/mapilib/Tests/tlssecurity.py
+++ b/clients/mapilib/Tests/tlssecurity.py
@@ -60,7 +60,7 @@ def attempt(portname: str, expected_erro
logging.debug(f"{cmd=}")
proc = subprocess.run(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
logging.debug(f"mclient exited with code {proc.returncode},
err={proc.stderr}")
- assert proc.returncode == 2 and "mclient is not expected to succeed"
+ assert proc.returncode == 2, f"mclient is supposed to exit with status 2,
not {proc.returncode}"
output = str(proc.stderr, 'utf-8').rstrip()
actual_error = None if 'Sorry, this is not' in output else output
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]