Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapter: Prevent login to mz_system externally #14093

Merged
merged 14 commits into from
Aug 15, 2022
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
jkosh44 committed Aug 12, 2022
commit d05f40f0025deb514a5f5e012c038c4527202f97
24 changes: 13 additions & 11 deletions test/testdrive/roles.td
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $ set-sql-timeout duration=1s
# Verify initial roles.
> SELECT id, name FROM mz_roles
s1 mz_system
u1 materialize
<RID> materialize

# Verify that invalid options are rejected.
! CREATE ROLE foo
Expand All @@ -24,41 +24,43 @@ contains:conflicting or redundant options
! CREATE ROLE foo LOGIN NOLOGIN SUPERUSER
contains:conflicting or redundant options

$ set-regex match=u\d{1,2} replacement=<RID>

# Create roles using both syntaxes and verify their existence.
> CREATE ROLE rj LOGIN SUPERUSER
> CREATE USER fms SUPERUSER
> SELECT id, name FROM mz_roles
s1 mz_system
u1 materialize
u2 rj
u3 fms
<RID> materialize
<RID> rj
<RID> fms

# Dropping multiple roles should not have any effect if one of the role names
# is bad...
! DROP ROLE rj, fms, bad
contains:unknown role 'bad'
> SELECT id, name FROM mz_roles
s1 mz_system
u1 materialize
u2 rj
u3 fms
<RID> materialize
<RID> rj
<RID> fms

# ...unless IF EXISTS is specified.
> DROP ROLE IF EXISTS rj, fms, bad
> SELECT id, name FROM mz_roles
s1 mz_system
u1 materialize
<RID> materialize

# Verify that the single name version of DROP ROLE works too.
> CREATE ROLE nlb LOGIN SUPERUSER
> SELECT id, name FROM mz_roles
s1 mz_system
u1 materialize
u4 nlb
<RID> materialize
<RID> nlb
> DROP ROLE nlb
> SELECT id, name FROM mz_roles
s1 mz_system
u1 materialize
<RID> materialize
> DROP ROLE IF EXISTS nlb

# No dropping the current role.
Expand Down