summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/t/002_api.pl
diff options
context:
space:
mode:
authorDaniel Gustafsson2022-03-29 12:02:45 +0000
committerDaniel Gustafsson2022-03-29 12:02:45 +0000
commitebc8b7d4416d8e0dfb7c05132ef6182fd3daf885 (patch)
tree04d15606691eb1773d9b7915fb66998ce5d6ce07 /src/interfaces/libpq/t/002_api.pl
parent8cd7627c7b19c5a1bb235e7ad91b53856b101e65 (diff)
Enable SSL library detection via PQsslAttribute()
Currently, libpq client code must have a connection handle before it can query the "library" SSL attribute. This poses problems if the client needs to know what SSL library is in use before constructing a connection string. Allow PQsslAttribute(NULL, "library") to return the library in use -- currently, just "OpenSSL" or NULL. The new behavior is announced with the LIBPQ_HAS_SSL_LIBRARY_DETECTION feature macro, allowing clients to differentiate between a libpq that was compiled without SSL support and a libpq that's just too old to tell. Author: Jacob Champion <[email protected]> Reviewed-by: Robert Haas <[email protected]> Reviewed-by: Daniel Gustafsson <[email protected]> Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/interfaces/libpq/t/002_api.pl')
-rw-r--r--src/interfaces/libpq/t/002_api.pl20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/interfaces/libpq/t/002_api.pl b/src/interfaces/libpq/t/002_api.pl
new file mode 100644
index 00000000000..7c6c5788a0c
--- /dev/null
+++ b/src/interfaces/libpq/t/002_api.pl
@@ -0,0 +1,20 @@
+# Copyright (c) 2022, PostgreSQL Global Development Group
+use strict;
+use warnings;
+
+use PostgreSQL::Test::Utils;
+use Test::More;
+
+# Test PQsslAttribute(NULL, "library")
+my ($out, $err) = run_command(['testclient', '--ssl']);
+
+if ($ENV{with_ssl} eq 'openssl')
+{
+ is($out, 'OpenSSL', 'PQsslAttribute(NULL, "library") returns "OpenSSL"');
+}
+else
+{
+ is($err, 'SSL is not enabled', 'PQsslAttribute(NULL, "library") returns NULL');
+}
+
+done_testing();