campingmontagut/test/marshal_payment.sql
jordi fita mas b2ee4dfea3 Add marshal_payment and unmarshal_booking functions
The idea is that we will marshal the payment, send it to the campsite’s
instance by email, and then unmarshal it as a booking, that way we can
have a one way replication from the internal to the public instance with
a way back to send the payments.

For testing purposes, i just create the booking in the same instance.

Had to change the booking relation’s permissions to allow insert from
a guest, much like for payments, because the notification from Redsys
comes as a guest connection.  I need this even with all the
marshal/unmarshal shenanigans because not everyone will have an internal
instance, thus need to allow bookings from guest connections.
2024-04-29 20:59:22 +02:00

28 lines
1.1 KiB
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Test marshal_payment
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(9);
set search_path to camper, public;
select has_function('camper', 'marshal_payment', array['integer']);
select function_lang_is('camper', 'marshal_payment', array['integer'], 'sql');
select function_returns('camper', 'marshal_payment', array['integer'], 'jsonb');
select isnt_definer('camper', 'marshal_payment', array['integer']);
select volatility_is('camper', 'marshal_payment', array['integer'], 'volatile');
select function_privs_are('camper', 'marshal_payment', array ['integer'], 'guest', array['EXECUTE']);
select function_privs_are('camper', 'marshal_payment', array ['integer'], 'employee', array['EXECUTE']);
select function_privs_are('camper', 'marshal_payment', array ['integer'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'marshal_payment', array ['integer'], 'authenticator', array[]::text[]);
-- The functions output is tested in unmarshal_bookings test suite
select *
from finish();
rollback;