2023-07-21 23:59:12 +00:00
|
|
|
-- 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, camper, public;
|
|
|
|
|
|
|
|
select has_function('auth', 'encrypt_password', array []::name[]);
|
|
|
|
select function_lang_is('auth', 'encrypt_password', array []::name[], 'plpgsql');
|
|
|
|
select function_returns('auth', 'encrypt_password', array []::name[], 'trigger');
|
|
|
|
select isnt_definer('auth', 'encrypt_password', array []::name[]);
|
|
|
|
select volatility_is('auth', 'encrypt_password', array []::name[], 'volatile');
|
|
|
|
select function_privs_are('auth', 'encrypt_password', array []::name[], 'guest', array []::text[]);
|
|
|
|
select function_privs_are('auth', 'encrypt_password', array []::name[], 'employee', array []::text[]);
|
|
|
|
select function_privs_are('auth', 'encrypt_password', array []::name[], 'admin', array []::text[]);
|
|
|
|
select function_privs_are('auth', '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;
|
|
|
|
|
Move the user role down to company_user relation
I was starting to add the public page for campsite types, creating more
granular row-level security policies for select, insert, update, and
delete, because now the guest users needed to SELECT them and they have
no related company to filter the rows with. Suddenly, i realized that
the role was wrong in the user relation: a user can be an admin to one
company, and employee to another, and guess to yet another company;
the role should be in the company_user relation instead.
That means that to know the role to set to, the user alone is not enough
and have to know the company as well. Had to change all the
cookie-related function to accept also the company’s host name, as this
is the information that the Go application has.
2023-08-08 00:22:16 +00:00
|
|
|
insert into "user" (email, name, password)
|
|
|
|
values ('info@tandem.blog', 'Perita', 'test');
|
2023-07-21 23:59:12 +00:00
|
|
|
|
|
|
|
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;
|