1# Test SCRAM authentication and TLS channel binding types 2 3use strict; 4use warnings; 5use PostgresNode; 6use TestLib; 7use Test::More; 8 9use File::Copy; 10 11use FindBin; 12use lib $FindBin::RealBin; 13 14use SSLServer; 15 16if ($ENV{with_openssl} ne 'yes') 17{ 18 plan skip_all => 'SSL not supported by this build'; 19} 20 21my $number_of_tests = 1; 22 23# This is the hostname used to connect to the server. 24my $SERVERHOSTADDR = '127.0.0.1'; 25 26# Allocation of base connection string shared among multiple tests. 27my $common_connstr; 28 29# Set up the server. 30 31note "setting up data directory"; 32my $node = get_new_node('master'); 33$node->init; 34 35# PGHOST is enforced here to set up the node, subsequent connections 36# will use a dedicated connection string. 37$ENV{PGHOST} = $node->host; 38$ENV{PGPORT} = $node->port; 39$node->start; 40 41# Configure server for SSL connections, with password handling. 42configure_test_server_for_ssl($node, $SERVERHOSTADDR, "scram-sha-256", 43 "pass", "scram-sha-256"); 44switch_server_cert($node, 'server-cn-only'); 45$ENV{PGPASSWORD} = "pass"; 46$common_connstr = 47 "user=ssltestuser dbname=trustdb sslmode=require hostaddr=$SERVERHOSTADDR"; 48 49# Default settings 50test_connect_ok($common_connstr, '', 51 "Basic SCRAM authentication with SSL"); 52 53done_testing($number_of_tests); 54