Skip to content

Commit

Permalink
add revoke
Browse files Browse the repository at this point in the history
  • Loading branch information
massimosiani committed Aug 16, 2023
1 parent 2005f5a commit 1f5877f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/core/shared/src/main/scala/data/Completion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ object Completion {
case object SetConstraints extends Completion
case object Explain extends Completion
case object Grant extends Completion
case object Revoke extends Completion
// more ...

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ object CommandComplete {
case "SET CONSTRAINTS" => apply(Completion.SetConstraints)
case "EXPLAIN" => apply(Completion.Explain)
case "GRANT" => apply(Completion.Grant)
case "REVOKE" => apply(Completion.Revoke)
// more .. fill in as we hit them

case s => apply(Completion.Unknown(s))
Expand Down
11 changes: 10 additions & 1 deletion modules/tests/shared/src/test/scala/CommandTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ class CommandTest extends SkunkTest {
TO skunk_role
""".command

val revoke: Command[Void] =
sql"""
REVOKE ALL PRIVILEGES
ON ALL TABLES IN SCHEMA public
FROM skunk_role
""".command

sessionTest("create table, create index, drop index, alter table and drop table") { s =>
for {
c <- s.execute(createTable)
Expand Down Expand Up @@ -535,11 +542,13 @@ class CommandTest extends SkunkTest {
.as("ok")
}

sessionTest("grant") { s =>
sessionTest("grant, revoke") { s =>
for{
_ <- s.execute(createRole)
c <- s.execute(grant)
_ <- assert("completion", c == Completion.Grant)
c <- s.execute(revoke)
_ <- assert("completion", c == Completion.Revoke)
_ <- s.execute(dropRole)
_ <- s.assertHealthy
} yield "ok"
Expand Down

0 comments on commit 1f5877f

Please sign in to comment.