Re: Proposal: Save user's original authenticated identity for logging - Mailing list pgsql-hackers

From Jacob Champion
Subject Re: Proposal: Save user's original authenticated identity for logging
Date
Msg-id 8c08c6402051b5348d599c0e07bbd83f8614fa16.camel@vmware.com
Whole thread Raw
In response to Re: Proposal: Save user's original authenticated identity for logging  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
On Fri, 2021-04-02 at 13:45 +0900, Michael Paquier wrote:
> Attached is what I have come up with as the first building piece,
> which is basically a combination of 0001 and 0002, except that I
> modified things so as the number of arguments remains minimal for all
> the routines.  This avoids the manipulation of the list of parameters
> passed down to PostgresNode::psql. The arguments for the optional
> query, the expected stdout and stderr are part of the parameter set
> (0001 was not doing that).

I made a few changes, highlighted in the since-v18 diff:

> +        # The result is assumed to match "true", or "t", here.
> +        $node->connect_ok($connstr, $test_name, sql => $query,
> +                  expected_stdout => qr/t/);

I've anchored this as qr/^t$/ so we don't accidentally match a stray
"t" in some larger string.

> -    is($res, 0, $test_name);
> -    like($stdoutres, $expected, $test_name);
> -    is($stderrres, "", $test_name);
> +    my ($stdoutres, $stderrres);
> +
> +    $node->connect_ok($connstr, $test_name, $query, $expected);

$query and $expected need to be given as named parameters. We also lost
the stderr check from the previous version of the test, so I added
expected_stderr to connect_ok().

> @@ -446,14 +446,14 @@ TODO:
>      # correct client cert in encrypted PEM with empty password
>      $node->connect_fails(
>          "$common_connstr user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client-encrypted-pem_tmp.key
sslpassword=''",
> -        qr!\Qprivate key file "ssl/client-encrypted-pem_tmp.key": processing error\E!,
> +        expected_stderr => qr!\Qprivate key file "ssl/client-encrypted-pem_tmp.key": processing error\E!,
>          "certificate authorization fails with correct client cert and empty password in encrypted PEM format"
>      );

These tests don't run yet inside the TODO block, but I've put the
expected_stderr parameter at the end of the list for them.

> For the main patch, this will need to be
> extended with two more parameters in each routine: log_like and
> log_unlike to match for the log patterns, handled as arrays of
> regexes.  That's what 0003 is basically doing already.

Rebased on top of your patch as v19, attached. (v17 disappeared into
the ether somewhere, I think. :D)

Now that it's easy to add log_like to existing tests, I fleshed out the
LDAP tests with a few more cases. They don't add code coverage, but
they pin the desired behavior for a few more types of LDAP auth.

--Jacob

Attachment

pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: invalid data in file backup_label problem on windows
Next
From: Zhihong Yu
Date:
Subject: Re: Parallel Full Hash Join