| 1 |
|
| 2 |
# Copyright (c) 2021-2025, PostgreSQL Global Development Group |
| 3 |
|
| 4 |
# Tests targeting SSPI on Windows. |
| 5 |
|
| 6 |
use strict; |
| 7 |
use warnings FATAL => 'all'; |
| 8 |
use PostgreSQL::Test::Cluster; |
| 9 |
use PostgreSQL::Test::Utils; |
| 10 |
use Test::More; |
| 11 |
|
| 12 |
if (!$windows_os || $use_unix_sockets) |
| 13 |
{ |
| 14 |
plan skip_all => |
| 15 |
"SSPI tests require Windows (without PG_TEST_USE_UNIX_SOCKETS)"; |
| 16 |
} |
| 17 |
|
| 18 |
# Initialize primary node |
| 19 |
my $node = PostgreSQL::Test::Cluster->new('primary'); |
| 20 |
$node->init; |
| 21 |
$node->append_conf('postgresql.conf', "log_connections = authentication\n"); |
| 22 |
$node->start; |
| 23 |
|
| 24 |
my $huge_pages_status = |
| 25 |
$node->safe_psql('postgres', q(SHOW huge_pages_status;)); |
| 26 |
isnt($huge_pages_status, 'unknown', "check huge_pages_status"); |
| 27 |
|
| 28 |
# SSPI is set up by default. Make sure it interacts correctly with |
| 29 |
# require_auth. |
| 30 |
$node->connect_ok("require_auth=sspi", |
| 31 |
"SSPI authentication required, works with SSPI auth"); |
| 32 |
$node->connect_fails( |
| 33 |
"require_auth=!sspi", |
| 34 |
"SSPI authentication forbidden, fails with SSPI auth", |
| 35 |
expected_stderr => |
| 36 |
qr/authentication method requirement "!sspi" failed: server requested SSPI authentication/ |
| 37 |
); |
| 38 |
$node->connect_fails( |
| 39 |
"require_auth=scram-sha-256", |
| 40 |
"SCRAM authentication required, fails with SSPI auth", |
| 41 |
expected_stderr => |
| 42 |
qr/authentication method requirement "scram-sha-256" failed: server requested SSPI authentication/ |
| 43 |
); |
| 44 |
|
| 45 |
done_testing(); |