numerus/test/encrypt_password.sql

41 lines
1.3 KiB
PL/PgSQL

-- Test encrypt_password
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(11);
set search_path to auth, numerus, public;
select has_function('encrypt_password');
select function_lang_is('encrypt_password', array []::name[], 'plpgsql');
select function_returns('encrypt_password', array []::name[], 'trigger');
select isnt_definer('encrypt_password', array []::name[]);
select volatility_is('encrypt_password', array []::name[], 'volatile');
select function_privs_are('encrypt_password', array []::name[], 'guest', array []::text[]);
select function_privs_are('encrypt_password', array []::name[], 'invoicer', array []::text[]);
select function_privs_are('encrypt_password', array []::name[], 'admin', array []::text[]);
select function_privs_are('encrypt_password', array []::name[], 'authenticator', array []::text[]);
select trigger_is('user', 'encrypt_password', 'encrypt_password');
set client_min_messages to warning;
truncate "user" cascade;
reset client_min_messages;
insert into "user" (email, name, password, role)
values ('info@tandem.blog', 'Perita', 'test', 'guest');
select row_eq(
$$ select email from "user" where password = crypt('test', password) $$,
row ('info@tandem.blog'::email),
'Should find the new user using its encrypted password'
);
select *
from finish();
rollback;