role_create.slt 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. # Loosely based on https://github.com/postgres/postgres/blob/master/src/test/regress/expected/create_role.out
  10. # We have replaced role attributes with system privileges so we had to make a lot of changes to
  11. # this test file to reflect that.
  12. mode cockroach
  13. reset-server
  14. simple conn=mz_system,user=mz_system
  15. ALTER SYSTEM SET enable_rbac_checks TO true;
  16. ----
  17. COMPLETE 0
  18. simple conn=mz_system,user=mz_system
  19. CREATE ROLE regress_role_admin;
  20. ----
  21. COMPLETE 0
  22. simple conn=mz_system,user=mz_system
  23. GRANT CREATEDB, CREATECLUSTER, CREATEROLE ON SYSTEM TO regress_role_admin;
  24. ----
  25. COMPLETE 0
  26. simple conn=mz_system,user=mz_system
  27. CREATE DATABASE regression
  28. ----
  29. COMPLETE 0
  30. simple conn=mz_system,user=mz_system
  31. GRANT CREATE ON DATABASE regression TO regress_role_admin;
  32. ----
  33. COMPLETE 0
  34. simple conn=mz_system,user=mz_system
  35. GRANT CREATE ON DATABASE regression TO regress_role_admin WITH GRANT OPTION;
  36. ----
  37. db error: ERROR: Expected end of statement, found WITH
  38. simple conn=mz_system,user=mz_system
  39. CREATE ROLE regress_role_limited_admin;
  40. ----
  41. COMPLETE 0
  42. simple conn=mz_system,user=mz_system
  43. GRANT CREATEROLE ON SYSTEM TO regress_role_limited_admin;
  44. ----
  45. COMPLETE 0
  46. simple conn=mz_system,user=mz_system
  47. CREATE ROLE regress_role_normal;
  48. ----
  49. COMPLETE 0
  50. simple conn=regress_role_limited_admin,user=regress_role_limited_admin
  51. CREATE ROLE regress_nosuch_superuser SUPERUSER;
  52. ----
  53. db error: ERROR: permission denied to create superuser role
  54. DETAIL: You must be a superuser to create superuser role
  55. simple conn=regress_role_limited_admin,user=regress_role_limited_admin
  56. CREATE ROLE regress_nosuch_createdb CREATEDB;
  57. ----
  58. db error: ERROR: CREATEDB attribute is not supported, for more information consult the documentation at https://materialize.com/docs/sql/create-role/#details
  59. DETAIL: Use system privileges instead.
  60. simple conn=regress_role_limited_admin,user=regress_role_limited_admin
  61. CREATE ROLE regress_nosuch_createcluster CREATECLUSTER;
  62. ----
  63. db error: ERROR: CREATECLUSTER attribute is not supported, for more information consult the documentation at https://materialize.com/docs/sql/create-role/#details
  64. DETAIL: Use system privileges instead.
  65. simple conn=regress_role_limited_admin,user=regress_role_limited_admin
  66. CREATE ROLE regress_role_limited;
  67. ----
  68. COMPLETE 0
  69. simple conn=regress_role_limited_admin,user=regress_role_limited_admin
  70. ALTER ROLE regress_role_limited CREATEDB;
  71. ----
  72. db error: ERROR: CREATEDB attribute is not supported, for more information consult the documentation at https://materialize.com/docs/sql/create-role/#details
  73. DETAIL: Use system privileges instead.
  74. simple conn=regress_role_limited_admin,user=regress_role_limited_admin
  75. ALTER ROLE regress_role_limited CREATECLUSTER;
  76. ----
  77. db error: ERROR: CREATECLUSTER attribute is not supported, for more information consult the documentation at https://materialize.com/docs/sql/create-role/#details
  78. DETAIL: Use system privileges instead.
  79. simple conn=regress_role_admin,user=regress_role_admin
  80. CREATE ROLE regress_createdb;
  81. ----
  82. COMPLETE 0
  83. simple conn=mz_system,user=mz_system
  84. GRANT CREATEDB ON SYSTEM TO regress_createdb;
  85. ----
  86. COMPLETE 0
  87. simple conn=regress_role_admin,user=regress_role_admin
  88. ALTER ROLE regress_createdb NOCREATEDB;
  89. ----
  90. db error: ERROR: CREATEDB attribute is not supported, for more information consult the documentation at https://materialize.com/docs/sql/create-role/#details
  91. DETAIL: Use system privileges instead.
  92. simple conn=regress_role_admin,user=regress_role_admin
  93. ALTER ROLE regress_createdb CREATEDB;
  94. ----
  95. db error: ERROR: CREATEDB attribute is not supported, for more information consult the documentation at https://materialize.com/docs/sql/create-role/#details
  96. DETAIL: Use system privileges instead.
  97. simple conn=regress_role_admin,user=regress_role_admin
  98. CREATE ROLE regress_createcluster;
  99. ----
  100. COMPLETE 0
  101. simple conn=mz_system,user=mz_system
  102. GRANT CREATECLUSTER ON SYSTEM TO regress_createcluster;
  103. ----
  104. COMPLETE 0
  105. simple conn=regress_role_admin,user=regress_role_admin
  106. ALTER ROLE regress_createcluster NOCREATECLUSTER;
  107. ----
  108. db error: ERROR: CREATECLUSTER attribute is not supported, for more information consult the documentation at https://materialize.com/docs/sql/create-role/#details
  109. DETAIL: Use system privileges instead.
  110. simple conn=regress_role_admin,user=regress_role_admin
  111. ALTER ROLE regress_createcluster CREATECLUSTER;
  112. ----
  113. db error: ERROR: CREATECLUSTER attribute is not supported, for more information consult the documentation at https://materialize.com/docs/sql/create-role/#details
  114. DETAIL: Use system privileges instead.
  115. simple conn=regress_role_admin,user=regress_role_admin
  116. ALTER ROLE regress_createdb SUPERUSER;
  117. ----
  118. db error: ERROR: permission denied to alter superuser role
  119. DETAIL: You must be a superuser to alter superuser role
  120. simple conn=regress_role_admin,user=regress_role_admin
  121. ALTER ROLE regress_createdb NOSUPERUSER;
  122. ----
  123. db error: ERROR: SUPERUSER, PASSWORD, and LOGIN attributes is not supported in this environment. For more information consult the documentation at https://materialize.com/docs/sql/create-role/#details
  124. simple conn=regress_role_admin,user=regress_role_admin
  125. CREATE ROLE regress_createrole;
  126. ----
  127. COMPLETE 0
  128. simple conn=mz_system,user=mz_system
  129. GRANT CREATEROLE ON SYSTEM TO regress_createrole;
  130. ----
  131. COMPLETE 0
  132. simple conn=regress_role_admin,user=regress_role_admin
  133. CREATE ROLE regress_connection_limit CONNECTION LIMIT 5;
  134. ----
  135. db error: ERROR: Expected end of statement, found CONNECTION
  136. # You might think to yourself "why is creating a role with PASSWORD NULL
  137. # allowed? Especially when self hosted auth isn't enabled?"
  138. # The answer is unsatisfying: it's a legacy behavior from Postgres.
  139. # Creating a role with a null password is the same as not specifying a password at all.
  140. # So, uh, sure...
  141. simple conn=regress_role_admin,user=regress_role_admin
  142. CREATE ROLE regress_password_null PASSWORD NULL;
  143. ----
  144. COMPLETE 0
  145. simple conn=regress_role_admin,user=regress_role_admin
  146. CREATE ROLE regress_noiseword SYSID 12345;
  147. ----
  148. db error: ERROR: Expected end of statement, found identifier "sysid"
  149. simple conn=regress_role_admin,user=regress_role_admin
  150. CREATE ROLE regress_noiseword USER x;
  151. ----
  152. db error: ERROR: Expected end of statement, found USER
  153. simple conn=regress_role_admin,user=regress_role_admin
  154. CREATE ROLE regress_noiseword ADMIN x
  155. ----
  156. db error: ERROR: Expected end of statement, found identifier "admin"
  157. simple conn=regress_role_admin,user=regress_role_admin
  158. CREATE ROLE regress_noiseword ROLE x
  159. ----
  160. db error: ERROR: Expected end of statement, found ROLE
  161. simple conn=regress_role_admin,user=regress_role_admin
  162. CREATE ROLE regress_noiseword IN GROUP x
  163. ----
  164. db error: ERROR: Expected end of statement, found IN
  165. simple conn=regress_role_admin,user=regress_role_admin
  166. CREATE ROLE regress_noiseword IN ROLE x;
  167. ----
  168. db error: ERROR: Expected end of statement, found IN
  169. simple conn=regress_role_admin,user=regress_role_admin
  170. CREATE ROLE regress_noiseword VALID UNTIL '2024';
  171. ----
  172. db error: ERROR: Expected end of statement, found identifier "valid"
  173. simple conn=regress_role_admin,user=regress_role_admin
  174. CREATE ROLE regress_noiseword ENCRYPTED PASSWORD NULL;
  175. ----
  176. db error: ERROR: Expected end of statement, found identifier "encrypted"
  177. simple conn=regress_role_admin,user=regress_role_admin
  178. CREATE ROLE regress_noiseword BYPASSRLS;
  179. ----
  180. db error: ERROR: Expected end of statement, found identifier "bypassrls"
  181. simple conn=regress_role_admin,user=regress_role_admin
  182. CREATE ROLE regress_noiseword NOBYPASSRLS;
  183. ----
  184. db error: ERROR: Expected end of statement, found identifier "nobypassrls"
  185. simple conn=regress_role_admin,user=regress_role_admin
  186. CREATE ROLE regress_noiseword REPLICATION;
  187. ----
  188. db error: ERROR: Expected end of statement, found REPLICATION
  189. simple conn=regress_role_admin,user=regress_role_admin
  190. CREATE ROLE regress_noiseword NOREPLICATION;
  191. ----
  192. db error: ERROR: Expected end of statement, found identifier "noreplication"
  193. simple conn=regress_role_admin,user=regress_role_admin
  194. CREATE ROLE regress_noiseword LOGIN;
  195. ----
  196. db error: ERROR: SUPERUSER, PASSWORD, and LOGIN attributes is not supported in this environment. For more information consult the documentation at https://materialize.com/docs/sql/create-role/#details
  197. simple conn=regress_role_admin,user=regress_role_admin
  198. CREATE ROLE regress_noiseword NOLOGIN;
  199. ----
  200. db error: ERROR: SUPERUSER, PASSWORD, and LOGIN attributes is not supported in this environment. For more information consult the documentation at https://materialize.com/docs/sql/create-role/#details
  201. simple conn=mz_system,user=mz_system
  202. ALTER SYSTEM SET enable_password_auth = true
  203. ----
  204. COMPLETE 0
  205. simple conn=regress_role_admin,user=regress_role_admin
  206. CREATE ROLE password_role WITH PASSWORD 'password';
  207. ----
  208. COMPLETE 0
  209. simple conn=regress_role_admin,user=regress_role_admin
  210. CREATE ROLE login_password_role WITH LOGIN PASSWORD 'password';
  211. ----
  212. COMPLETE 0
  213. simple conn=regress_role_admin,user=regress_role_admin
  214. ALTER ROLE password_role WITH PASSWORD 'new_password';
  215. ----
  216. db error: ERROR: permission denied to alter password of role
  217. DETAIL: You must be a superuser to alter password of role
  218. simple conn=regress_role_admin,user=regress_role_admin
  219. ALTER ROLE regress_role_admin WITH PASSWORD 'new_password';
  220. ----
  221. COMPLETE 0
  222. simple conn=regress_role_admin,user=regress_role_admin
  223. ALTER ROLE password_role WITH PASSWORD NULL;
  224. ----
  225. COMPLETE 0
  226. simple conn=regress_role_admin,user=regress_role_admin
  227. ALTER ROLE password_role WITH PASSWORD 123;
  228. ----
  229. db error: ERROR: Expected literal string, found number "123"
  230. simple conn=regress_role_admin,user=regress_role_admin
  231. CREATE ROLE superuser_login_password_role WITH SUPERUSER LOGIN PASSWORD 'password';
  232. ----
  233. db error: ERROR: permission denied to create superuser role
  234. DETAIL: You must be a superuser to create superuser role
  235. simple conn=regress_role_admin,user=regress_role_admin
  236. ALTER ROLE password_role WITH SUPERUSER;
  237. ----
  238. db error: ERROR: permission denied to alter superuser role
  239. DETAIL: You must be a superuser to alter superuser role
  240. simple conn=regress_role_admin,user=regress_role_admin
  241. DROP ROLE password_role;
  242. ----
  243. COMPLETE 0