camper/test/encode_base64url.sql

49 lines
1.9 KiB
PL/PgSQL

-- Test encode_base64url
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(14);
set search_path to camper, public;
select has_function('camper', 'encode_base64url', array['bytea']);
select function_lang_is('camper', 'encode_base64url', array['bytea'], 'sql');
select function_returns('camper', 'encode_base64url', array['bytea'], 'text');
select isnt_definer('camper', 'encode_base64url', array['bytea']);
select volatility_is('camper', 'encode_base64url', array['bytea'], 'immutable');
select function_privs_are('camper', 'encode_base64url', array ['bytea'], 'guest', array['EXECUTE']);
select function_privs_are('camper', 'encode_base64url', array ['bytea'], 'employee', array['EXECUTE']);
select function_privs_are('camper', 'encode_base64url', array ['bytea'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'encode_base64url', array ['bytea'], 'authenticator', array[]::text[]);
select is(
encode_base64url(decode('sq7HjrUOBfKmC576ILgskD5srU870gJ7', 'base64')),
'sq7HjrUOBfKmC576ILgskD5srU870gJ7'
);
select is(
encode_base64url(decode('K+gWWTl+gKlkxEGDsuc0UunIQwoFLM0t', 'base64')),
'K-gWWTl-gKlkxEGDsuc0UunIQwoFLM0t'
);
select is(
encode_base64url(decode('cQGdqnb4V/nSKe8zTzyP/VaDGd2rAmzt', 'base64')),
'cQGdqnb4V_nSKe8zTzyP_VaDGd2rAmzt'
);
select is(
encode_base64url(decode('x59e+kbXSpgsmy31V5l2BtTuKv8/pVKg', 'base64')),
'x59e-kbXSpgsmy31V5l2BtTuKv8_pVKg'
);
select is(
encode_base64url(decode(E'yvmzOBJpRfBn2XodxH/1WOpbASfcH5KAMRbDNevBV5srR8Yj5wAiP6+Obv0NCpyrOUVeYZ8NqMe/\ntM28EoOY2g==', 'base64')),
'yvmzOBJpRfBn2XodxH_1WOpbASfcH5KAMRbDNevBV5srR8Yj5wAiP6-Obv0NCpyrOUVeYZ8NqMe_tM28EoOY2g==',
'Should not include newlines in the output'
);
select *
from finish();
rollback;