Create a 'privileges' test fixture

This commit is contained in:
Alvaro Gutierrez Perez 2018-07-09 21:28:50 +02:00
parent 1704aa32ee
commit 7c3ec6b3c8
No known key found for this signature in database
GPG Key ID: 5186F8446CE87F52
6 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,30 @@
create extension pg_trgm;
create schema any_schema;
CREATE TYPE any_enum AS ENUM ('value1', 'value2');
CREATE TABLE any_table (
id serial primary key,
name text not null
);
create unique index on any_table(name);
create view any_view as select * from any_table;
create view any_other_view as select * from any_table;
create or replace function any_function(i integer, t text[])
returns TABLE(a text, c integer) as
$$
declare
BEGIN
select 'no', 1;
END;
$$
LANGUAGE PLPGSQL STABLE returns null on null input security definer;
grant select, insert on table any_table to postgres;

View File

@ -0,0 +1,3 @@
grant delete on table any_table to postgres;
revoke select on table any_table from postgres;

View File

@ -0,0 +1,28 @@
create extension pg_trgm;
create schema any_schema;
CREATE TYPE any_enum AS ENUM ('value1', 'value2');
CREATE TABLE any_table (
id serial primary key,
name text not null
);
create unique index on any_table(name);
create view any_view as select * from any_table;
create or replace function any_function(i integer, t text[])
returns TABLE(a text, c integer) as
$$
declare
BEGIN
select 'no', 1;
END;
$$
LANGUAGE PLPGSQL STABLE returns null on null input security definer;
grant update, insert on table any_table to postgres;

View File

@ -0,0 +1,5 @@
revoke select on table "public"."any_table" from postgres;
drop view if exists "public"."any_other_view" cascade;
grant update on table "public"."any_table" to postgres;

View File

@ -0,0 +1,5 @@
revoke delete on table "public"."any_table" from postgres;
drop view if exists "public"."any_other_view" cascade;
grant update on table "public"."any_table" to postgres;

View File

@ -42,6 +42,8 @@ def test_with_fixtures():
do_fixture_test(FIXTURE_NAME, schema='goodschema')
for FIXTURE_NAME in ['singleschema_ext']:
do_fixture_test(FIXTURE_NAME, create_extensions_only=True)
for FIXTURE_NAME in ['privileges']:
do_fixture_test(FIXTURE_NAME, with_privileges=True)
def do_fixture_test(fixture_name, schema=None, create_extensions_only=False, with_privileges=False):