mirror of
https://github.com/djrobstep/migra.git
synced 2024-09-11 13:56:05 +03:00
Create a 'privileges' test fixture
This commit is contained in:
parent
1704aa32ee
commit
7c3ec6b3c8
30
tests/FIXTURES/privileges/a.sql
Normal file
30
tests/FIXTURES/privileges/a.sql
Normal 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;
|
3
tests/FIXTURES/privileges/additions.sql
Normal file
3
tests/FIXTURES/privileges/additions.sql
Normal file
@ -0,0 +1,3 @@
|
||||
grant delete on table any_table to postgres;
|
||||
|
||||
revoke select on table any_table from postgres;
|
28
tests/FIXTURES/privileges/b.sql
Normal file
28
tests/FIXTURES/privileges/b.sql
Normal 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;
|
5
tests/FIXTURES/privileges/expected.sql
Normal file
5
tests/FIXTURES/privileges/expected.sql
Normal 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;
|
5
tests/FIXTURES/privileges/expected2.sql
Normal file
5
tests/FIXTURES/privileges/expected2.sql
Normal 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;
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user