3 -- Turn off echo and keep things quiet.
5 -- Format the output for nice TAP.
10 -- Revert all changes on failure.
11 \set ON_ERROR_ROLLBACK 1
12 \set ON_ERROR_STOP true
21 (SELECT TRUE AS verify_old_pw FROM actor.usr
22 WHERE id = 189 AND passwd = MD5('montyc1234')),
23 'Legacy password should match'
27 'SELECT actor.get_salt(189, ''main'')',
28 'get_salt() returns a new salt'
32 'SELECT * FROM actor.passwd WHERE usr = 189 AND passwd_type = ''main''',
33 'get_salt() should migrate the password'
37 (SELECT actor.verify_passwd(189, 'main',
38 MD5(actor.get_salt(189, 'main') || MD5('montyc1234')))),
39 'verify_passwd should verify migrated password'
44 SELECT actor.verify_passwd(189, 'main',
45 MD5(actor.get_salt(189, 'main') || MD5('BADPASSWORD'))))
47 'verify_passwd should fail with wrong password'
50 -- This code chunk mimics the application changing a user's password
52 DECLARE new_salt TEXT;
54 -- we have to capture the salt, because subsequent
55 -- calls will create a new one.
56 SELECT INTO new_salt actor.create_salt('main');
57 PERFORM actor.set_passwd(
58 189, 'main', MD5(new_salt || MD5('bobblehead')), new_salt);
62 (SELECT actor.verify_passwd(189, 'main',
63 MD5(actor.get_salt(189, 'main') || MD5('bobblehead')))),
64 'verify_passwd should verify new password'
67 -- Finish the tests and clean up.
68 SELECT * FROM finish();