mirror of
https://github.com/postgres/postgres.git
synced 2026-03-23 10:55:21 -04:00
This module includes two functions:
- test_saslprep(), that performs pg_saslprep on a bytea.
- test_saslprep_ranges(), able to check for all valid ranges of UTF-8
codepoints pg_saslprep() handles each one of them.
This provides a detailed coverage of our implementation of SASLprep()
used for SCRAM, with:
- ASCII characters.
- Incomplete UTF-8 sequences, for 390b3cbbb2 (later backpatched).
- A more advanced check for all the valid UTF-8 ranges of codepoints, to
check for cases where these generate an empty password, based on an
original suggestion from Heikki Linnakangas. This part consumes
resources and time, so it is implemented as a TAP test under a
new PG_TEST_EXTRA value.
A different patch is still under discussion to tweak our internal
SASLprep() implementation, and this module can be used to track any
changes in behavior.
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://postgr.es/m/aaEJ-El2seZHeFcG@paquier.xyz
19 lines
477 B
SQL
19 lines
477 B
SQL
-- Tests for SASLprep
|
|
|
|
CREATE EXTENSION test_saslprep;
|
|
|
|
-- Incomplete UTF-8 sequence.
|
|
SELECT test_saslprep('\xef');
|
|
|
|
-- Range of ASCII characters.
|
|
SELECT
|
|
CASE
|
|
WHEN a = 0 THEN '<NUL>'
|
|
WHEN a < 32 THEN '<CTL_' || a::text || '>'
|
|
WHEN a = 127 THEN '<DEL>'
|
|
ELSE chr(a) END AS dat,
|
|
set_byte('\x00'::bytea, 0, a) AS byt,
|
|
test_saslprep(set_byte('\x00'::bytea, 0, a)) AS saslprep
|
|
FROM generate_series(0,127) AS a;
|
|
|
|
DROP EXTENSION test_saslprep;
|