mz-support-privileges.slt 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # Tests that assert the privileges that are assumed to be always granted to
  10. # the mz_support user.
  11. statement ok
  12. CREATE TABLE t (a INT)
  13. simple conn=mz_support,user=mz_support
  14. SET CLUSTER TO quickstart
  15. ----
  16. COMPLETE 0
  17. # The mz_support user cannot execute `SELECT ...` commands.
  18. simple conn=mz_support,user=mz_support
  19. SELECT * FROM t
  20. ----
  21. db error: ERROR: permission denied for TABLE "materialize.public.t"
  22. DETAIL: The 'mz_support' role needs SELECT privileges on TABLE "materialize.public.t"
  23. # The mz_support user cannot execute `INSERT ...` commands.
  24. simple conn=mz_support,user=mz_support
  25. INSERT INTO t VALUES (42)
  26. ----
  27. db error: ERROR: permission denied for TABLE "materialize.public.t"
  28. DETAIL: The 'mz_support' role needs INSERT privileges on TABLE "materialize.public.t"
  29. # The mz_support user cannot execute `UPDATE ...` commands.
  30. simple conn=mz_support,user=mz_support
  31. UPDATE t SET a = 5
  32. ----
  33. db error: ERROR: permission denied for TABLE "materialize.public.t"
  34. DETAIL: The 'mz_support' role needs UPDATE privileges on TABLE "materialize.public.t"
  35. # The mz_support user cannot execute `DELETE ...` commands.
  36. simple conn=mz_support,user=mz_support
  37. DELETE FROM t WHERE a IS NOT NULL
  38. ----
  39. db error: ERROR: permission denied for TABLE "materialize.public.t"
  40. DETAIL: The 'mz_support' role needs DELETE privileges on TABLE "materialize.public.t"
  41. # The mz_support user cannot execute create objects.
  42. simple conn=mz_support,user=mz_support
  43. CREATE VIEW vv AS SELECT 66
  44. ----
  45. db error: ERROR: permission denied for SCHEMA "materialize.public"
  46. DETAIL: The 'mz_support' role needs CREATE privileges on SCHEMA "materialize.public"
  47. # The mz_support user can SHOW public system vars.
  48. simple conn=mz_support,user=mz_support
  49. SHOW max_tables;
  50. ----
  51. 100
  52. COMPLETE 1
  53. # The mz_support user can SHOW internal system vars.
  54. simple conn=mz_support,user=mz_support
  55. SHOW log_filter;
  56. ----
  57. warn
  58. COMPLETE 1
  59. # The mz_support user cannot ALTER SYSTEM SET public system vars.
  60. simple conn=mz_support,user=mz_support
  61. ALTER SYSTEM SET max_tables = 1234;
  62. ----
  63. db error: ERROR: permission denied to alter system
  64. DETAIL: You must be the 'mz_system' role
  65. # The mz_support user cannot ALTER SYSTEM SET internal system vars.
  66. simple conn=mz_support,user=mz_support
  67. ALTER SYSTEM SET log_filter = 'error';
  68. ----
  69. db error: ERROR: permission denied to alter system
  70. DETAIL: You must be the 'mz_system' role
  71. # The mz_support user cannot ALTER SYSTEM RESET public system vars.
  72. simple conn=mz_support,user=mz_support
  73. ALTER SYSTEM RESET max_tables;
  74. ----
  75. db error: ERROR: permission denied to alter system
  76. DETAIL: You must be the 'mz_system' role
  77. # The mz_support user cannot ALTER SYSTEM RESET internal system vars.
  78. simple conn=mz_support,user=mz_support
  79. ALTER SYSTEM RESET log_filter;
  80. ----
  81. db error: ERROR: permission denied to alter system
  82. DETAIL: You must be the 'mz_system' role
  83. # The mz_support user cannot query the un-redacted statement log tables
  84. simple conn=mz_support,user=mz_support
  85. SELECT count(*) >= 0 FROM mz_internal.mz_statement_execution_history
  86. ----
  87. db error: ERROR: permission denied for SOURCE "mz_internal.mz_statement_execution_history"
  88. DETAIL: The 'mz_support' role needs SELECT privileges on SOURCE "mz_internal.mz_statement_execution_history"
  89. simple conn=mz_support,user=mz_support
  90. SELECT count(*) >= 0 FROM mz_internal.mz_sql_text
  91. ----
  92. db error: ERROR: permission denied for SOURCE "mz_internal.mz_sql_text"
  93. DETAIL: The 'mz_support' role needs SELECT privileges on SOURCE "mz_internal.mz_sql_text"
  94. # It _can_ query the bowdlerized tables
  95. simple conn=mz_support,user=mz_support
  96. SELECT count(*) >= 0 FROM mz_internal.mz_sql_text_redacted
  97. ----
  98. t
  99. COMPLETE 1
  100. simple conn=mz_support,user=mz_support
  101. SELECT count(*) >= 0 FROM mz_internal.mz_statement_execution_history_redacted
  102. ----
  103. t
  104. COMPLETE 1
  105. # Can use explain schema
  106. simple conn=mz_system,user=mz_system
  107. ALTER SYSTEM SET enable_connection_validation_syntax TO true;
  108. ----
  109. COMPLETE 0
  110. simple conn=mz_system,user=mz_system
  111. CREATE CONNECTION kafka_conn TO KAFKA (BROKER 'localhost:9092', SECURITY PROTOCOL PLAINTEXT) WITH (VALIDATE = false);
  112. ----
  113. COMPLETE 0
  114. simple conn=mz_system,user=mz_system
  115. CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (URL 'https://google.com') WITH (VALIDATE = false);
  116. ----
  117. COMPLETE 0
  118. simple multiline,conn=mz_support,user=mz_support
  119. EXPLAIN VALUE SCHEMA FOR CREATE SINK sink FROM t INTO KAFKA CONNECTION kafka_conn (TOPIC 'topic') KEY (a) NOT ENFORCED FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn ENVELOPE UPSERT;
  120. ----
  121. {
  122. "type": "record",
  123. "name": "envelope",
  124. "fields": [
  125. {
  126. "name": "a",
  127. "type": [
  128. "null",
  129. "int"
  130. ]
  131. }
  132. ]
  133. }
  134. EOF
  135. COMPLETE 1
  136. simple conn=mz_system,user=mz_system
  137. DROP CONNECTION kafka_conn;
  138. ----
  139. COMPLETE 0
  140. simple conn=mz_system,user=mz_system
  141. DROP CONNECTION csr_conn;
  142. ----
  143. COMPLETE 0