Skip to content

Commit a2ecd7e

Browse files
committed
feat: adds a different case in tests
1 parent 08a31a3 commit a2ecd7e

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

cluster/local/postgresdb_functions.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ create_grantable_objects() {
4545
TARGE_SCHEMA='public'
4646
request="
4747
CREATE TABLE \"$TARGE_SCHEMA\".test_table(col1 INT NULL);
48-
CREATE SEQUENCE \"$TARGE_SCHEMA\".test_sequence START WITH 1000 INCREMENT BY 1;
48+
CREATE SEQUENCE \"$TARGE_SCHEMA\".test_sequence_1 START WITH 1000 INCREMENT BY 1;
49+
CREATE SEQUENCE \"$TARGE_SCHEMA\".test_sequence_2 START WITH 1000 INCREMENT BY 1;
4950
CREATE PROCEDURE \"$TARGE_SCHEMA\".test_procedure(arg TEXT) LANGUAGE plpgsql AS \$\$ BEGIN END; \$\$;
5051
CREATE TABLE \"$TARGE_SCHEMA\".test_table_column(test_column INT NULL);
5152
CREATE FOREIGN DATA WRAPPER test_foreign_data_wrapper;
@@ -67,7 +68,8 @@ delete_grantable_objects() {
6768
DROP FOREIGN DATA WRAPPER test_foreign_data_wrapper;
6869
DROP TABLE \"$TARGE_SCHEMA\".test_table_column;
6970
DROP PROCEDURE \"$TARGE_SCHEMA\".test_procedure(TEXT);
70-
DROP SEQUENCE \"$TARGE_SCHEMA\".test_sequence;
71+
DROP SEQUENCE \"$TARGE_SCHEMA\".test_sequence_1;
72+
DROP SEQUENCE \"$TARGE_SCHEMA\".test_sequence_2;
7173
DROP TABLE \"$TARGE_SCHEMA\".test_table;
7274
"
7375
drop_objects=$(PGPASSWORD="${postgres_root_pw}" psql -h localhost -p 5432 -U postgres -d "$TARGET_DB" -wtAc "$request")
@@ -230,12 +232,15 @@ check_table_privileges(){
230232
check_sequence_privileges(){
231233
target_db="db1"
232234
schema="public"
233-
sequence="test_sequence"
234235
role='no-grants-role'
235236
expected_privileges='SELECT|f,UPDATE|f,USAGE|f'
236237

238+
sequence="test_sequence_1"
237239
request="select acl.privilege_type, acl.is_grantable from pg_class c inner join pg_namespace n on c.relnamespace = n.oid, aclexplode(c.relacl) as acl inner join pg_roles s on acl.grantee = s.oid where c.relkind = 'S' and n.nspname = '$schema' and s.rolname='$role' and c.relname = '$sequence'"
240+
check_privileges $target_db "sequence $schema.$sequence" $role $expected_privileges "$request"
238241

242+
sequence="test_sequence_2"
243+
request="select acl.privilege_type, acl.is_grantable from pg_class c inner join pg_namespace n on c.relnamespace = n.oid, aclexplode(c.relacl) as acl inner join pg_roles s on acl.grantee = s.oid where c.relkind = 'S' and n.nspname = '$schema' and s.rolname='$role' and c.relname = '$sequence'"
239244
check_privileges $target_db "sequence $schema.$sequence" $role $expected_privileges "$request"
240245
}
241246

examples/postgresql/grant.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ spec:
114114
schemaRef:
115115
name: public
116116
sequences:
117-
- test_sequence
117+
- test_sequence_1
118+
- test_sequence_2
118119
---
119120
apiVersion: postgresql.sql.crossplane.io/v1alpha1
120121
kind: Grant

0 commit comments

Comments
 (0)