52 lines
1.5 KiB
PL/PgSQL
52 lines
1.5 KiB
PL/PgSQL
-- Test find_user_role
|
|
set client_min_messages to warning;
|
|
create extension if not exists pgtap;
|
|
reset client_min_messages;
|
|
|
|
begin;
|
|
|
|
select plan(12);
|
|
|
|
set search_path to auth, numerus, public;
|
|
|
|
select has_function('find_user_role');
|
|
select function_lang_is('find_user_role', array ['email', 'text'], 'plpgsql');
|
|
select function_returns('find_user_role', array ['email', 'text'], 'name');
|
|
select isnt_definer('find_user_role', array ['email', 'text']);
|
|
select volatility_is('find_user_role', array ['email', 'text'], 'volatile');
|
|
select function_privs_are('find_user_role', array ['email', 'text'], 'guest', array []::text[]);
|
|
select function_privs_are('find_user_role', array ['email', 'text'], 'invoicer', array []::text[]);
|
|
select function_privs_are('find_user_role', array ['email', 'text'], 'admin', array []::text[]);
|
|
select function_privs_are('find_user_role', array ['email', 'text'], 'authenticator', array []::text[]);
|
|
|
|
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 is(
|
|
find_user_role('info@tandem.blog', 'test'),
|
|
'guest'::name,
|
|
'Should find the role with the correct email and password'
|
|
);
|
|
|
|
select is(
|
|
find_user_role('info@tandem.blog', 'mah password'),
|
|
NULL::name,
|
|
'Should not find any role with an invalid password'
|
|
);
|
|
|
|
select is(
|
|
find_user_role('nope@tandem.blog', 'test'),
|
|
NULL::name,
|
|
'Should not find any role with an invalid email'
|
|
);
|
|
|
|
|
|
select *
|
|
from finish();
|
|
|
|
rollback;
|