mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
libpq: Error message improvement
This commit is contained in:
parent
489b5409e4
commit
c91f356083
@ -909,7 +909,7 @@ check_expected_areq(AuthRequest areq, PGconn *conn)
|
|||||||
if (!reason)
|
if (!reason)
|
||||||
reason = auth_method_description(areq);
|
reason = auth_method_description(areq);
|
||||||
|
|
||||||
libpq_append_conn_error(conn, "auth method \"%s\" requirement failed: %s",
|
libpq_append_conn_error(conn, "authentication method requirement \"%s\" failed: %s",
|
||||||
conn->require_auth, reason);
|
conn->require_auth, reason);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -168,37 +168,37 @@ $node->connect_fails(
|
|||||||
"user=scram_role require_auth=gss",
|
"user=scram_role require_auth=gss",
|
||||||
"GSS authentication required, fails with trust auth",
|
"GSS authentication required, fails with trust auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "gss" requirement failed: server did not complete authentication/
|
qr/authentication method requirement "gss" failed: server did not complete authentication/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=scram_role require_auth=sspi",
|
"user=scram_role require_auth=sspi",
|
||||||
"SSPI authentication required, fails with trust auth",
|
"SSPI authentication required, fails with trust auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "sspi" requirement failed: server did not complete authentication/
|
qr/authentication method requirement "sspi" failed: server did not complete authentication/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=scram_role require_auth=password",
|
"user=scram_role require_auth=password",
|
||||||
"password authentication required, fails with trust auth",
|
"password authentication required, fails with trust auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "password" requirement failed: server did not complete authentication/
|
qr/authentication method requirement "password" failed: server did not complete authentication/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=scram_role require_auth=md5",
|
"user=scram_role require_auth=md5",
|
||||||
"MD5 authentication required, fails with trust auth",
|
"MD5 authentication required, fails with trust auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "md5" requirement failed: server did not complete authentication/
|
qr/authentication method requirement "md5" failed: server did not complete authentication/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=scram_role require_auth=scram-sha-256",
|
"user=scram_role require_auth=scram-sha-256",
|
||||||
"SCRAM authentication required, fails with trust auth",
|
"SCRAM authentication required, fails with trust auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "scram-sha-256" requirement failed: server did not complete authentication/
|
qr/authentication method requirement "scram-sha-256" failed: server did not complete authentication/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=scram_role require_auth=password,scram-sha-256",
|
"user=scram_role require_auth=password,scram-sha-256",
|
||||||
"password and SCRAM authentication required, fails with trust auth",
|
"password and SCRAM authentication required, fails with trust auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "password,scram-sha-256" requirement failed: server did not complete authentication/
|
qr/authentication method requirement "password,scram-sha-256" failed: server did not complete authentication/
|
||||||
);
|
);
|
||||||
|
|
||||||
# These negative patterns of require_auth should succeed.
|
# These negative patterns of require_auth should succeed.
|
||||||
@ -289,19 +289,19 @@ $node->connect_fails(
|
|||||||
"user=scram_role require_auth=md5",
|
"user=scram_role require_auth=md5",
|
||||||
"md5 authentication required, fails with password auth",
|
"md5 authentication required, fails with password auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "md5" requirement failed: server requested a cleartext password/
|
qr/authentication method requirement "md5" failed: server requested a cleartext password/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=scram_role require_auth=scram-sha-256",
|
"user=scram_role require_auth=scram-sha-256",
|
||||||
"SCRAM authentication required, fails with password auth",
|
"SCRAM authentication required, fails with password auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "scram-sha-256" requirement failed: server requested a cleartext password/
|
qr/authentication method requirement "scram-sha-256" failed: server requested a cleartext password/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=scram_role require_auth=none",
|
"user=scram_role require_auth=none",
|
||||||
"all authentication forbidden, fails with password auth",
|
"all authentication forbidden, fails with password auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "none" requirement failed: server requested a cleartext password/
|
qr/authentication method requirement "none" failed: server requested a cleartext password/
|
||||||
);
|
);
|
||||||
|
|
||||||
# Disallowing password authentication fails, even if requested by server.
|
# Disallowing password authentication fails, even if requested by server.
|
||||||
@ -313,7 +313,7 @@ $node->connect_fails(
|
|||||||
"user=scram_role require_auth=!password,!md5,!scram-sha-256",
|
"user=scram_role require_auth=!password,!md5,!scram-sha-256",
|
||||||
"multiple authentication types forbidden, fails with password auth",
|
"multiple authentication types forbidden, fails with password auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/ method "!password,!md5,!scram-sha-256" requirement failed: server requested a cleartext password/
|
qr/ method requirement "!password,!md5,!scram-sha-256" failed: server requested a cleartext password/
|
||||||
);
|
);
|
||||||
|
|
||||||
# For "scram-sha-256" method, user "scram_role" should be able to connect.
|
# For "scram-sha-256" method, user "scram_role" should be able to connect.
|
||||||
@ -352,19 +352,19 @@ $node->connect_fails(
|
|||||||
"user=scram_role require_auth=password",
|
"user=scram_role require_auth=password",
|
||||||
"password authentication required, fails with SCRAM auth",
|
"password authentication required, fails with SCRAM auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "password" requirement failed: server requested SASL authentication/
|
qr/authentication method requirement "password" failed: server requested SASL authentication/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=scram_role require_auth=md5",
|
"user=scram_role require_auth=md5",
|
||||||
"md5 authentication required, fails with SCRAM auth",
|
"md5 authentication required, fails with SCRAM auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "md5" requirement failed: server requested SASL authentication/
|
qr/authentication method requirement "md5" failed: server requested SASL authentication/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=scram_role require_auth=none",
|
"user=scram_role require_auth=none",
|
||||||
"all authentication forbidden, fails with SCRAM auth",
|
"all authentication forbidden, fails with SCRAM auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "none" requirement failed: server requested SASL authentication/
|
qr/authentication method requirement "none" failed: server requested SASL authentication/
|
||||||
);
|
);
|
||||||
|
|
||||||
# Authentication fails if SCRAM authentication is forbidden.
|
# Authentication fails if SCRAM authentication is forbidden.
|
||||||
@ -407,19 +407,19 @@ $node->connect_fails(
|
|||||||
"user=md5_role require_auth=password",
|
"user=md5_role require_auth=password",
|
||||||
"password authentication required, fails with MD5 auth",
|
"password authentication required, fails with MD5 auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "password" requirement failed: server requested a hashed password/
|
qr/authentication method requirement "password" failed: server requested a hashed password/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=md5_role require_auth=scram-sha-256",
|
"user=md5_role require_auth=scram-sha-256",
|
||||||
"SCRAM authentication required, fails with MD5 auth",
|
"SCRAM authentication required, fails with MD5 auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "scram-sha-256" requirement failed: server requested a hashed password/
|
qr/authentication method requirement "scram-sha-256" failed: server requested a hashed password/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=md5_role require_auth=none",
|
"user=md5_role require_auth=none",
|
||||||
"all authentication types forbidden, fails with MD5 auth",
|
"all authentication types forbidden, fails with MD5 auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "none" requirement failed: server requested a hashed password/
|
qr/authentication method requirement "none" failed: server requested a hashed password/
|
||||||
);
|
);
|
||||||
|
|
||||||
# Authentication fails if MD5 is forbidden.
|
# Authentication fails if MD5 is forbidden.
|
||||||
@ -427,13 +427,13 @@ $node->connect_fails(
|
|||||||
"user=md5_role require_auth=!md5",
|
"user=md5_role require_auth=!md5",
|
||||||
"password authentication forbidden, fails with MD5 auth",
|
"password authentication forbidden, fails with MD5 auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "!md5" requirement failed: server requested a hashed password/
|
qr/authentication method requirement "!md5" failed: server requested a hashed password/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"user=md5_role require_auth=!password,!md5,!scram-sha-256",
|
"user=md5_role require_auth=!password,!md5,!scram-sha-256",
|
||||||
"multiple authentication types forbidden, fails with MD5 auth",
|
"multiple authentication types forbidden, fails with MD5 auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "!password,!md5,!scram-sha-256" requirement failed: server requested a hashed password/
|
qr/authentication method requirement "!password,!md5,!scram-sha-256" failed: server requested a hashed password/
|
||||||
);
|
);
|
||||||
|
|
||||||
# Test SYSTEM_USER <> NULL with parallel workers.
|
# Test SYSTEM_USER <> NULL with parallel workers.
|
||||||
|
@ -29,13 +29,13 @@ $node->connect_fails(
|
|||||||
"require_auth=!sspi",
|
"require_auth=!sspi",
|
||||||
"SSPI authentication forbidden, fails with SSPI auth",
|
"SSPI authentication forbidden, fails with SSPI auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "!sspi" requirement failed: server requested SSPI authentication/
|
qr/authentication method requirement "!sspi" failed: server requested SSPI authentication/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
"require_auth=scram-sha-256",
|
"require_auth=scram-sha-256",
|
||||||
"SCRAM authentication required, fails with SSPI auth",
|
"SCRAM authentication required, fails with SSPI auth",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "scram-sha-256" requirement failed: server requested SSPI authentication/
|
qr/authentication method requirement "scram-sha-256" failed: server requested SSPI authentication/
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing();
|
done_testing();
|
||||||
|
@ -425,14 +425,14 @@ $node->connect_fails(
|
|||||||
. " user=test1 host=$host hostaddr=$hostaddr gssencmode=disable require_auth=sspi",
|
. " user=test1 host=$host hostaddr=$hostaddr gssencmode=disable require_auth=sspi",
|
||||||
"SSPI authentication requested, fails with non-encrypted GSS",
|
"SSPI authentication requested, fails with non-encrypted GSS",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "sspi" requirement failed: server requested GSSAPI authentication/
|
qr/authentication method requirement "sspi" failed: server requested GSSAPI authentication/
|
||||||
);
|
);
|
||||||
$node->connect_fails(
|
$node->connect_fails(
|
||||||
$node->connstr('postgres')
|
$node->connstr('postgres')
|
||||||
. " user=test1 host=$host hostaddr=$hostaddr gssencmode=require require_auth=sspi",
|
. " user=test1 host=$host hostaddr=$hostaddr gssencmode=require require_auth=sspi",
|
||||||
"SSPI authentication requested, fails with encrypted GSS",
|
"SSPI authentication requested, fails with encrypted GSS",
|
||||||
expected_stderr =>
|
expected_stderr =>
|
||||||
qr/auth method "sspi" requirement failed: server did not complete authentication/
|
qr/authentication method requirement "sspi" failed: server did not complete authentication/
|
||||||
);
|
);
|
||||||
|
|
||||||
# Test that SYSTEM_USER works.
|
# Test that SYSTEM_USER works.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user