Skip to content

Commit 0c17061

Browse files
committed
Fix test for password reuse
1 parent eec5e2a commit 0c17061

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

test/expected/06_reuse_interval.out

+13-9
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,25 @@ CREATE USER credtest WITH PASSWORD 'AJ8YuRe=6O0';
1919
SET credcheck.password_reuse_history = 1;
2020
SET credcheck.password_reuse_interval = 365;
2121
SELECT rolename, password_hash FROM pg_password_history WHERE rolename = 'credtest' ORDER BY password_date ;
22-
rolename | password_hash
23-
----------+---------------
24-
(0 rows)
22+
rolename | password_hash
23+
----------+------------------------------------------------------------------
24+
credtest | 79320cea69ba581d5e17255c02ae08060f412f79a7c14d0e24ffca51fc03ec74
25+
(1 row)
2526

2627
-- Add a new password in the history and set its age to 100 days
2728
ALTER USER credtest PASSWORD 'J8YuRe=6O';
2829
SELECT pg_password_history_timestamp('credtest', now()::timestamp - '100 days'::interval);
2930
pg_password_history_timestamp
3031
-------------------------------
31-
1
32+
2
3233
(1 row)
3334

3435
SELECT rolename, password_hash FROM pg_password_history WHERE rolename = 'credtest' ORDER BY password_date ;
3536
rolename | password_hash
3637
----------+------------------------------------------------------------------
3738
credtest | e61e58c22aa6bf31a92b385932f7d0e4dbaba24fa3fdb2982510d6c72a961335
38-
(1 row)
39+
credtest | 79320cea69ba581d5e17255c02ae08060f412f79a7c14d0e24ffca51fc03ec74
40+
(2 rows)
3941

4042
-- fail, the password is in the history for less than 1 year
4143
ALTER USER credtest PASSWORD 'J8YuRe=6O';
@@ -44,16 +46,18 @@ SELECT rolename, password_hash FROM pg_password_history WHERE rolename = 'credte
4446
rolename | password_hash
4547
----------+------------------------------------------------------------------
4648
credtest | e61e58c22aa6bf31a92b385932f7d0e4dbaba24fa3fdb2982510d6c72a961335
47-
(1 row)
49+
credtest | 79320cea69ba581d5e17255c02ae08060f412f79a7c14d0e24ffca51fc03ec74
50+
(2 rows)
4851

4952
-- success, but the old password must be kept in the history (interval not reached)
50-
ALTER USER credtest PASSWORD 'AJ8YuRe=6O0';
53+
ALTER USER credtest PASSWORD 'AJ8YuRe=6O1';
5154
SELECT rolename, password_hash FROM pg_password_history WHERE rolename = 'credtest' ORDER BY password_date ;
5255
rolename | password_hash
5356
----------+------------------------------------------------------------------
5457
credtest | e61e58c22aa6bf31a92b385932f7d0e4dbaba24fa3fdb2982510d6c72a961335
5558
credtest | 79320cea69ba581d5e17255c02ae08060f412f79a7c14d0e24ffca51fc03ec74
56-
(2 rows)
59+
credtest | a4a99db0eae794af3fdfeb6094da5cbd591b81cb7df6c82cdecc100a3b9ffe55
60+
(3 rows)
5761

5862
-- fail, the password is still present in the history
5963
ALTER USER credtest PASSWORD 'J8YuRe=6O';
@@ -62,7 +66,7 @@ ERROR: Cannot use this credential following the password reuse policy
6266
SELECT pg_password_history_timestamp('credtest', now()::timestamp - '380 days'::interval);
6367
pg_password_history_timestamp
6468
-------------------------------
65-
2
69+
3
6670
(1 row)
6771

6872
-- success, the old password present in the history has expired

test/sql/06_reuse_interval.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ SELECT rolename, password_hash FROM pg_password_history WHERE rolename = 'credte
1919
ALTER USER credtest PASSWORD 'J8YuRe=6O';
2020
SELECT rolename, password_hash FROM pg_password_history WHERE rolename = 'credtest' ORDER BY password_date ;
2121
-- success, but the old password must be kept in the history (interval not reached)
22-
ALTER USER credtest PASSWORD 'AJ8YuRe=6O0';
22+
ALTER USER credtest PASSWORD 'AJ8YuRe=6O1';
2323
SELECT rolename, password_hash FROM pg_password_history WHERE rolename = 'credtest' ORDER BY password_date ;
2424
-- fail, the password is still present in the history
2525
ALTER USER credtest PASSWORD 'J8YuRe=6O';

0 commit comments

Comments
 (0)