Skip to content

Commit 8d9d584

Browse files
committed
oauth: Use IPv4-only issuer in oauth_validator tests
The test authorization server implemented in oauth_server.py does not listen on IPv6. Most of the time, libcurl happily falls back to IPv4 after failing its initial connection, but on NetBSD, something is consistently showing up on the unreserved IPv6 port and causing a test failure. Rather than deal with dual-stack details across all test platforms, change the issuer to enforce the use of IPv4 only. (This elicits more punishing timeout behavior from libcurl, so it's a useful change from the testing perspective as well.) Author: Jacob Champion <jacob.champion@enterprisedb.com> Reported-by: Thomas Munro <thomas.munro@gmail.com> Discussion: https://postgr.es/m/CAOYmi%2Bn4EDOOUL27_OqYT2-F2rS6S%2B3mK-ppWb2Ec92UEoUbYA%40mail.gmail.com
1 parent 28317de commit 8d9d584

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/test/modules/oauth_validator/t/001_server.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ END
6868
}
6969

7070
my $port = $webserver->port();
71-
my $issuer = "http://localhost:$port";
71+
my $issuer = "http://127.0.0.1:$port";
7272

7373
unlink($node->data_dir . '/pg_hba.conf');
7474
$node->append_conf(

src/test/modules/oauth_validator/t/OAuth/Server.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ OAuth::Server - runs a mock OAuth authorization server for testing
1515
$server->run;
1616
1717
my $port = $server->port;
18-
my $issuer = "http://localhost:$port";
18+
my $issuer = "http://127.0.0.1:$port";
1919
2020
# test against $issuer...
2121
@@ -28,7 +28,7 @@ daemon implemented in t/oauth_server.py. (Python has a fairly usable HTTP server
2828
in its standard library, so the implementation was ported from Perl.)
2929
3030
This authorization server does not use TLS (it implements a nonstandard, unsafe
31-
issuer at "http://localhost:<port>"), so libpq in particular will need to set
31+
issuer at "http://127.0.0.1:<port>"), so libpq in particular will need to set
3232
PGOAUTHDEBUG=UNSAFE to be able to talk to it.
3333
3434
=cut

src/test/modules/oauth_validator/t/oauth_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def _send_json(self, js: JsonObject) -> None:
251251
def config(self) -> JsonObject:
252252
port = self.server.socket.getsockname()[1]
253253

254-
issuer = f"http://localhost:{port}"
254+
issuer = f"http://127.0.0.1:{port}"
255255
if self._alt_issuer:
256256
issuer += "/alternate"
257257
elif self._parameterized:

0 commit comments

Comments
 (0)