forked from anermakov/arenadata_password_check
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
-- Load the extension to enable the tests | ||
LOAD 'arenadata_password_check'; | ||
-- Restrictive policy | ||
SET arenadata_password_check.minimum_length TO 8; | ||
SET arenadata_password_check.maximum_length TO 15; | ||
SET arenadata_password_check.special_chars TO '%$?@'; | ||
SET arenadata_password_check.restrict_lower TO true; | ||
SET arenadata_password_check.restrict_upper TO true; | ||
SET arenadata_password_check.restrict_numbers TO true; | ||
-- Check password policy in place | ||
-- Password too short | ||
CREATE ROLE regress_pwd_foo PASSWORD '01234'; | ||
ERROR: password is too short | ||
-- Password too long | ||
CREATE ROLE regress_pwd_foo PASSWORD '01234567890123456'; | ||
ERROR: password is too long | ||
-- Invalid characters | ||
CREATE ROLE regress_pwd_foo PASSWORD '```````````````'; | ||
ERROR: password contains invalid characters | ||
-- Three categories missing | ||
-- Lower-case, upper-case, special character missing | ||
CREATE ROLE regress_pwd_foo PASSWORD '012345678901234'; | ||
ERROR: Incorrect password format: lower-case character missing, upper-case character missing, special character missing (needs to be one listed in "%$?@") | ||
-- Number, upper-case, special character missing | ||
CREATE ROLE regress_pwd_foo PASSWORD 'abcdefghijklmno'; | ||
ERROR: Incorrect password format: upper-case character missing, number missing, special character missing (needs to be one listed in "%$?@") | ||
-- Number, lower-case, special character missing | ||
CREATE ROLE regress_pwd_foo PASSWORD 'ABCDEFGHIJKLMNO'; | ||
ERROR: Incorrect password format: lower-case character missing, number missing, special character missing (needs to be one listed in "%$?@") | ||
-- Number, lower-case, upper-case character missing | ||
CREATE ROLE regress_pwd_foo PASSWORD '%%%%%%%%%%%%%%%'; | ||
ERROR: Incorrect password format: lower-case character missing, upper-case character missing, number missing | ||
-- Two categories missing | ||
-- Number, special character missing | ||
CREATE ROLE regress_pwd_foo PASSWORD 'abcdefghijklmnA'; | ||
ERROR: Incorrect password format: number missing, special character missing (needs to be one listed in "%$?@") | ||
-- Upper-case character, special character missing | ||
CREATE ROLE regress_pwd_foo PASSWORD '01234567890123a'; | ||
ERROR: Incorrect password format: upper-case character missing, special character missing (needs to be one listed in "%$?@") | ||
-- Lower-case character, special character missing | ||
CREATE ROLE regress_pwd_foo PASSWORD '01234567890123A'; | ||
ERROR: Incorrect password format: lower-case character missing, special character missing (needs to be one listed in "%$?@") | ||
-- Number, upper case missing | ||
CREATE ROLE regress_pwd_foo PASSWORD 'abcdefghijklmn%'; | ||
ERROR: Incorrect password format: upper-case character missing, number missing | ||
-- Number, lower-case missing | ||
CREATE ROLE regress_pwd_foo PASSWORD 'ABCDEFGHIJKLMN%'; | ||
ERROR: Incorrect password format: lower-case character missing, number missing | ||
-- Upper-case, lower-case missing | ||
CREATE ROLE regress_pwd_foo PASSWORD '01234567890123%'; | ||
ERROR: Incorrect password format: lower-case character missing, upper-case character missing | ||
-- One category missing | ||
-- Special character missing | ||
CREATE ROLE regress_pwd_foo PASSWORD '0123456789012aA'; | ||
ERROR: Incorrect password format: special character missing (needs to be one listed in "%$?@") | ||
-- Upper-case missing | ||
CREATE ROLE regress_pwd_foo PASSWORD '0123456789012a%'; | ||
ERROR: Incorrect password format: upper-case character missing | ||
-- Lower-case missing | ||
CREATE ROLE regress_pwd_foo PASSWORD '0123456789012A%'; | ||
ERROR: Incorrect password format: lower-case character missing | ||
-- Number missing | ||
CREATE ROLE regress_pwd_foo PASSWORD 'ABCDEFGHIJKLMa%'; | ||
ERROR: Incorrect password format: number missing | ||
-- Valid password | ||
CREATE ROLE regress_pwd_foo PASSWORD '012345678901Aa%'; | ||
DROP ROLE regress_pwd_foo; | ||
-- Policy less restrictive | ||
SET arenadata_password_check.restrict_lower TO false; | ||
SET arenadata_password_check.restrict_upper TO false; | ||
SET arenadata_password_check.restrict_numbers TO false; | ||
SET arenadata_password_check.minimum_length TO 1; | ||
SET arenadata_password_check.maximum_length TO 100; | ||
-- Special character missing | ||
CREATE ROLE regress_pwd_foo PASSWORD '012345678901Aa'; | ||
ERROR: Incorrect password format: special character missing (needs to be one listed in "%$?@") | ||
-- Valid password | ||
CREATE ROLE regress_pwd_foo PASSWORD '@%'; | ||
DROP ROLE regress_pwd_foo; | ||
-- Even less restrictive policy | ||
SET arenadata_password_check.restrict_special TO false; | ||
-- Valid password | ||
CREATE ROLE regress_pwd_foo PASSWORD 'A'; | ||
DROP ROLE regress_pwd_foo; |