Skip to content

Commit 1169920

Browse files
committed
Add tests for libpq gssencmode and sslmode options
Test all combinations of gssencmode, sslmode, whether the server supports SSL and/or GSSAPI encryption, and whether they are accepted by pg_hba.conf. This is in preparation for refactoring that code in libpq, and for adding a new option for "direct SSL" connections, which adds another dimension to the logic. If we add even more options in the future, testing all combinations will become unwieldy and we'll need to rethink this, but for now an exhaustive test is nice. Author: Heikki Linnakangas, Matthias van de Meent Reviewed-by: Jacob Champion Discussion: https://www.postgresql.org/message-id/a3af4070-3556-461d-aec8-a8d794f94894@iki.fi
1 parent 9f89956 commit 1169920

File tree

6 files changed

+624
-1
lines changed

6 files changed

+624
-1
lines changed

.cirrus.tasks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020
MTEST_ARGS: --print-errorlogs --no-rebuild -C build
2121
PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests
2222
TEMP_CONFIG: ${CIRRUS_WORKING_DIR}/src/tools/ci/pg_ci_base.conf
23-
PG_TEST_EXTRA: kerberos ldap ssl load_balance
23+
PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance
2424

2525

2626
# What files to preserve in case tests fail

src/test/libpq_encryption/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile for src/test/libpq_encryption
4+
#
5+
# Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
6+
# Portions Copyright (c) 1994, Regents of the University of California
7+
#
8+
# src/test/libpq_encryption/Makefile
9+
#
10+
#-------------------------------------------------------------------------
11+
12+
subdir = src/test/libpq_encryption
13+
top_builddir = ../../..
14+
include $(top_builddir)/src/Makefile.global
15+
16+
export with_ssl with_gssapi with_krb_srvnam
17+
18+
check:
19+
$(prove_check)
20+
21+
installcheck:
22+
$(prove_installcheck)
23+
24+
clean distclean:
25+
rm -rf tmp_check

src/test/libpq_encryption/README

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
src/test/libpq_encryption/README
2+
3+
Tests for negotiating network encryption method
4+
===============================================
5+
6+
This directory contains a test suite for the libpq options to
7+
negotiate encryption with the server. This requires reconfiguring a
8+
test server, enabling/disabling SSL and GSSAPI, and is therefore kept
9+
separate and not run by default.
10+
11+
CAUTION: The test server run by this test is configured to listen for TCP
12+
connections on localhost. Any user on the same host is able to log in to the
13+
test server while the tests are running. Do not run this suite on a multi-user
14+
system where you don't trust all local users! Also, this test suite creates a
15+
KDC server that listens for TCP/IP connections on localhost without any real
16+
access control.
17+
18+
Running the tests
19+
=================
20+
21+
NOTE: You must have given the --enable-tap-tests argument to configure.
22+
23+
Run
24+
make check PG_TEST_EXTRA=libpq_encryption
25+
26+
You can use "make installcheck" if you previously did "make install".
27+
In that case, the code in the installation tree is tested. With
28+
"make check", a temporary installation tree is built from the current
29+
sources and then tested.
30+
31+
See src/test/perl/README for more info about running these tests.

src/test/libpq_encryption/meson.build

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2022-2024, PostgreSQL Global Development Group
2+
3+
tests += {
4+
'name': 'libpq_encryption',
5+
'sd': meson.current_source_dir(),
6+
'bd': meson.current_build_dir(),
7+
'tap': {
8+
'tests': [
9+
't/001_negotiate_encryption.pl',
10+
],
11+
'env': {
12+
'with_ssl': ssl_library,
13+
'OPENSSL': openssl.found() ? openssl.path() : '',
14+
'with_gssapi': gssapi.found() ? 'yes' : 'no',
15+
'with_krb_srvnam': 'postgres',
16+
},
17+
},
18+
}

0 commit comments

Comments
 (0)