owners.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  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. from textwrap import dedent
  10. from materialize.checks.actions import Testdrive
  11. from materialize.checks.checks import Check
  12. class Owners(Check):
  13. def _create_objects(self, role: str, i: int, expensive: bool = False) -> str:
  14. s = dedent(
  15. f"""
  16. $ postgres-execute connection=postgres://mz_system@${{testdrive.materialize-internal-sql-addr}}
  17. GRANT CREATE ON DATABASE materialize TO {role}
  18. GRANT CREATE ON SCHEMA materialize.public TO {role}
  19. GRANT CREATE ON CLUSTER {self._default_cluster()} TO {role}
  20. GRANT CREATEDB ON SYSTEM TO {role}
  21. $ postgres-execute connection=postgres://{role}@${{testdrive.materialize-sql-addr}}
  22. CREATE DATABASE owner_db{i}
  23. CREATE SCHEMA owner_schema{i}
  24. CREATE CONNECTION owner_kafka_conn{i} FOR KAFKA {self._kafka_broker()}
  25. CREATE CONNECTION owner_csr_conn{i} FOR CONFLUENT SCHEMA REGISTRY URL '${{testdrive.schema-registry-url}}'
  26. CREATE TYPE owner_type{i} AS LIST (ELEMENT TYPE = text)
  27. CREATE TABLE owner_t{i} (c1 int, c2 owner_type{i})
  28. CREATE INDEX owner_i{i} ON owner_t{i} (c2)
  29. CREATE VIEW owner_v{i} AS SELECT * FROM owner_t{i}
  30. CREATE MATERIALIZED VIEW owner_mv{i} AS SELECT * FROM owner_t{i}
  31. CREATE SECRET owner_secret{i} AS 'MY_SECRET'
  32. """
  33. )
  34. if expensive:
  35. s += dedent(
  36. f"""
  37. $ postgres-execute connection=postgres://{role}@${{testdrive.materialize-sql-addr}}
  38. CREATE SOURCE owner_source{i} FROM LOAD GENERATOR COUNTER
  39. $ postgres-execute connection=postgres://{role}@${{testdrive.materialize-sql-addr}}
  40. CREATE SINK owner_sink{i} FROM owner_mv{i} INTO KAFKA CONNECTION owner_kafka_conn{i} (TOPIC 'sink-sink-owner{i}') FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION owner_csr_conn{i} ENVELOPE DEBEZIUM
  41. CREATE CLUSTER owner_cluster{i} REPLICAS (owner_cluster_r{i} (SIZE '4'))
  42. """
  43. )
  44. return s
  45. def _alter_object_owners(self, i: int, expensive: bool = False) -> str:
  46. s = dedent(
  47. f"""
  48. $ postgres-execute connection=postgres://mz_system@${{testdrive.materialize-internal-sql-addr}}
  49. ALTER DATABASE owner_db{i} OWNER TO other_owner
  50. ALTER SCHEMA owner_schema{i} OWNER TO other_owner
  51. ALTER CONNECTION owner_kafka_conn{i} OWNER TO other_owner
  52. ALTER CONNECTION owner_csr_conn{i} OWNER TO other_owner
  53. ALTER TYPE owner_type{i} OWNER TO other_owner
  54. ALTER TABLE owner_t{i} OWNER TO other_owner
  55. ALTER INDEX owner_i{i} OWNER TO other_owner
  56. ALTER VIEW owner_v{i} OWNER TO other_owner
  57. ALTER MATERIALIZED VIEW owner_mv{i} OWNER TO other_owner
  58. ALTER SECRET owner_secret{i} OWNER TO other_owner
  59. """
  60. )
  61. if expensive:
  62. s += dedent(
  63. f"""
  64. ALTER SOURCE owner_source{i} OWNER TO other_owner
  65. ALTER SINK owner_sink{i} OWNER TO other_owner
  66. ALTER CLUSTER owner_cluster{i} OWNER TO other_owner
  67. """
  68. )
  69. return s
  70. def _drop_objects(
  71. self, role: str, i: int, expensive: bool = False, success: bool = True
  72. ) -> str:
  73. cmds = []
  74. # Drop the sink first so we can drop the materialized view without CASCADE.
  75. if expensive:
  76. cmds += [
  77. f"DROP SOURCE owner_source{i}",
  78. f"DROP SINK owner_sink{i}",
  79. f"DROP CLUSTER owner_cluster{i}",
  80. ]
  81. cmds += [
  82. f"DROP SECRET owner_secret{i}",
  83. f"DROP MATERIALIZED VIEW owner_mv{i}",
  84. f"DROP VIEW owner_v{i}",
  85. f"DROP INDEX owner_i{i}",
  86. f"DROP TABLE owner_t{i}",
  87. f"DROP TYPE owner_type{i}",
  88. f"DROP CONNECTION owner_csr_conn{i}",
  89. f"DROP CONNECTION owner_kafka_conn{i}",
  90. f"DROP SCHEMA owner_schema{i}",
  91. f"DROP DATABASE owner_db{i}",
  92. ]
  93. if success:
  94. return (
  95. f"$ postgres-execute connection=postgres://{role}@${{testdrive.materialize-sql-addr}}\n"
  96. + "\n".join(cmds)
  97. + "\n"
  98. )
  99. if role != "materialize":
  100. raise ValueError(
  101. "Can't check for failures with user other than materialize"
  102. )
  103. return "\n".join(
  104. [f"! {cmd} CASCADE\ncontains: must be owner of\n" for cmd in cmds]
  105. )
  106. def initialize(self) -> Testdrive:
  107. return Testdrive(
  108. dedent(
  109. """
  110. > SET SESSION enable_session_rbac_checks TO true
  111. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}
  112. GRANT CREATEROLE ON SYSTEM TO materialize
  113. > CREATE ROLE owner_role_01
  114. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}
  115. GRANT CREATEDB, CREATECLUSTER ON SYSTEM TO owner_role_01
  116. > CREATE ROLE other_owner
  117. """
  118. )
  119. + self._create_objects("owner_role_01", 1, expensive=True)
  120. + self._create_objects("owner_role_01", 2, expensive=True)
  121. + self._alter_object_owners(2, expensive=True)
  122. )
  123. def manipulate(self) -> list[Testdrive]:
  124. return [
  125. Testdrive(s)
  126. for s in [
  127. dedent(
  128. """
  129. > SET SESSION enable_session_rbac_checks TO true
  130. """
  131. )
  132. + self._create_objects("owner_role_01", 3)
  133. + self._create_objects("owner_role_01", 4)
  134. + self._alter_object_owners(4)
  135. + dedent(
  136. """
  137. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}
  138. GRANT CREATEROLE ON SYSTEM TO materialize
  139. > CREATE ROLE owner_role_02
  140. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}
  141. GRANT CREATEDB, CREATECLUSTER ON SYSTEM TO owner_role_02
  142. """
  143. ),
  144. self._create_objects("owner_role_01", 5)
  145. + self._create_objects("owner_role_01", 6)
  146. + self._alter_object_owners(6)
  147. + self._create_objects("owner_role_02", 7)
  148. + self._create_objects("owner_role_02", 8)
  149. + self._alter_object_owners(8)
  150. + dedent(
  151. """
  152. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}
  153. GRANT CREATEROLE ON SYSTEM TO materialize
  154. > CREATE ROLE owner_role_03
  155. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}
  156. GRANT CREATEDB, CREATECLUSTER ON SYSTEM TO owner_role_03
  157. """
  158. ),
  159. ]
  160. ]
  161. def validate(self) -> Testdrive:
  162. return Testdrive(
  163. dedent(
  164. """
  165. > SET SESSION enable_session_rbac_checks TO true
  166. """
  167. )
  168. +
  169. # materialize role is not allowed to drop the objects since it is
  170. # not the owner, verify this:
  171. self._drop_objects("materialize", 1, success=False, expensive=True)
  172. + self._drop_objects("materialize", 2, success=False, expensive=True)
  173. + self._drop_objects("materialize", 3, success=False)
  174. + self._drop_objects("materialize", 4, success=False)
  175. + self._drop_objects("materialize", 5, success=False)
  176. + self._drop_objects("materialize", 6, success=False)
  177. + self._drop_objects("materialize", 7, success=False)
  178. + self._drop_objects("materialize", 8, success=False)
  179. + self._create_objects("owner_role_01", 9)
  180. + self._create_objects("owner_role_02", 10)
  181. + self._create_objects("owner_role_03", 11)
  182. + dedent(
  183. """
  184. $ psql-execute command="\\l owner_db*"
  185. \\ List of databases
  186. Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges
  187. ------------+---------------+----------+-----------------+---------+-------+------------+-----------+-------------------
  188. owner_db1 | owner_role_01 | UTF8 | libc | C | C | | |
  189. owner_db10 | owner_role_02 | UTF8 | libc | C | C | | |
  190. owner_db11 | owner_role_03 | UTF8 | libc | C | C | | |
  191. owner_db2 | other_owner | UTF8 | libc | C | C | | |
  192. owner_db3 | owner_role_01 | UTF8 | libc | C | C | | |
  193. owner_db4 | other_owner | UTF8 | libc | C | C | | |
  194. owner_db5 | owner_role_01 | UTF8 | libc | C | C | | |
  195. owner_db6 | other_owner | UTF8 | libc | C | C | | |
  196. owner_db7 | owner_role_02 | UTF8 | libc | C | C | | |
  197. owner_db8 | other_owner | UTF8 | libc | C | C | | |
  198. owner_db9 | owner_role_01 | UTF8 | libc | C | C | | |
  199. $ psql-execute command="\\dn owner_schema*"
  200. \\ List of schemas
  201. Name | Owner
  202. ----------------+---------------
  203. owner_schema1 | owner_role_01
  204. owner_schema10 | owner_role_02
  205. owner_schema11 | owner_role_03
  206. owner_schema2 | other_owner
  207. owner_schema3 | owner_role_01
  208. owner_schema4 | other_owner
  209. owner_schema5 | owner_role_01
  210. owner_schema6 | other_owner
  211. owner_schema7 | owner_role_02
  212. owner_schema8 | other_owner
  213. owner_schema9 | owner_role_01
  214. $ psql-execute command="\\dt owner_t*"
  215. \\ List of relations
  216. Schema | Name | Type | Owner
  217. --------+-----------+-------+---------------
  218. public | owner_t1 | table | owner_role_01
  219. public | owner_t10 | table | owner_role_02
  220. public | owner_t11 | table | owner_role_03
  221. public | owner_t2 | table | other_owner
  222. public | owner_t3 | table | owner_role_01
  223. public | owner_t4 | table | other_owner
  224. public | owner_t5 | table | owner_role_01
  225. public | owner_t6 | table | other_owner
  226. public | owner_t7 | table | owner_role_02
  227. public | owner_t8 | table | other_owner
  228. public | owner_t9 | table | owner_role_01
  229. $ psql-execute command="\\di owner_i*"
  230. \\ List of relations
  231. Schema | Name | Type | Owner | Table
  232. --------+-----------+-------+---------------+-----------
  233. public | owner_i1 | index | owner_role_01 | owner_t1
  234. public | owner_i10 | index | owner_role_02 | owner_t10
  235. public | owner_i11 | index | owner_role_03 | owner_t11
  236. public | owner_i2 | index | other_owner | owner_t2
  237. public | owner_i3 | index | owner_role_01 | owner_t3
  238. public | owner_i4 | index | other_owner | owner_t4
  239. public | owner_i5 | index | owner_role_01 | owner_t5
  240. public | owner_i6 | index | other_owner | owner_t6
  241. public | owner_i7 | index | owner_role_02 | owner_t7
  242. public | owner_i8 | index | other_owner | owner_t8
  243. public | owner_i9 | index | owner_role_01 | owner_t9
  244. $ psql-execute command="\\dv owner_v*"
  245. \\ List of relations
  246. Schema | Name | Type | Owner
  247. --------+-----------+------+---------------
  248. public | owner_v1 | view | owner_role_01
  249. public | owner_v10 | view | owner_role_02
  250. public | owner_v11 | view | owner_role_03
  251. public | owner_v2 | view | other_owner
  252. public | owner_v3 | view | owner_role_01
  253. public | owner_v4 | view | other_owner
  254. public | owner_v5 | view | owner_role_01
  255. public | owner_v6 | view | other_owner
  256. public | owner_v7 | view | owner_role_02
  257. public | owner_v8 | view | other_owner
  258. public | owner_v9 | view | owner_role_01
  259. $ psql-execute command="\\dmv owner_mv*"
  260. \\ List of relations
  261. Schema | Name | Type | Owner
  262. --------+------------+-------------------+---------------
  263. public | owner_mv1 | materialized view | owner_role_01
  264. public | owner_mv10 | materialized view | owner_role_02
  265. public | owner_mv11 | materialized view | owner_role_03
  266. public | owner_mv2 | materialized view | other_owner
  267. public | owner_mv3 | materialized view | owner_role_01
  268. public | owner_mv4 | materialized view | other_owner
  269. public | owner_mv5 | materialized view | owner_role_01
  270. public | owner_mv6 | materialized view | other_owner
  271. public | owner_mv7 | materialized view | owner_role_02
  272. public | owner_mv8 | materialized view | other_owner
  273. public | owner_mv9 | materialized view | owner_role_01
  274. > SELECT mz_types.name, mz_roles.name FROM mz_types JOIN mz_roles ON mz_types.owner_id = mz_roles.id WHERE mz_types.name LIKE 'owner_type%'
  275. owner_type1 owner_role_01
  276. owner_type10 owner_role_02
  277. owner_type11 owner_role_03
  278. owner_type2 other_owner
  279. owner_type3 owner_role_01
  280. owner_type4 other_owner
  281. owner_type5 owner_role_01
  282. owner_type6 other_owner
  283. owner_type7 owner_role_02
  284. owner_type8 other_owner
  285. owner_type9 owner_role_01
  286. > SELECT mz_secrets.name, mz_roles.name FROM mz_secrets JOIN mz_roles ON mz_secrets.owner_id = mz_roles.id WHERE mz_secrets.name LIKE 'owner_secret%'
  287. owner_secret1 owner_role_01
  288. owner_secret10 owner_role_02
  289. owner_secret11 owner_role_03
  290. owner_secret2 other_owner
  291. owner_secret3 owner_role_01
  292. owner_secret4 other_owner
  293. owner_secret5 owner_role_01
  294. owner_secret6 other_owner
  295. owner_secret7 owner_role_02
  296. owner_secret8 other_owner
  297. owner_secret9 owner_role_01
  298. > SELECT mz_sources.name, mz_roles.name FROM mz_sources JOIN mz_roles ON mz_sources.owner_id = mz_roles.id WHERE mz_sources.name LIKE 'owner_source%' AND type = 'load-generator'
  299. owner_source1 owner_role_01
  300. owner_source2 other_owner
  301. > SELECT mz_sinks.name, mz_roles.name FROM mz_sinks JOIN mz_roles ON mz_sinks.owner_id = mz_roles.id WHERE mz_sinks.name LIKE 'owner_sink%'
  302. owner_sink1 owner_role_01
  303. owner_sink2 other_owner
  304. > SELECT mz_clusters.name, mz_roles.name FROM mz_clusters JOIN mz_roles ON mz_clusters.owner_id = mz_roles.id WHERE mz_clusters.name LIKE 'owner_cluster%'
  305. owner_cluster1 owner_role_01
  306. owner_cluster2 other_owner
  307. > SELECT mz_cluster_replicas.name, mz_roles.name FROM mz_cluster_replicas JOIN mz_roles ON mz_cluster_replicas.owner_id = mz_roles.id WHERE mz_cluster_replicas.name LIKE 'owner_cluster_r%'
  308. owner_cluster_r1 owner_role_01
  309. owner_cluster_r2 other_owner
  310. > SELECT mz_connections.name, mz_roles.name FROM mz_connections JOIN mz_roles ON mz_connections.owner_id = mz_roles.id WHERE mz_connections.name LIKE 'owner_%'
  311. owner_csr_conn1 owner_role_01
  312. owner_csr_conn10 owner_role_02
  313. owner_csr_conn11 owner_role_03
  314. owner_csr_conn2 other_owner
  315. owner_csr_conn3 owner_role_01
  316. owner_csr_conn4 other_owner
  317. owner_csr_conn5 owner_role_01
  318. owner_csr_conn6 other_owner
  319. owner_csr_conn7 owner_role_02
  320. owner_csr_conn8 other_owner
  321. owner_csr_conn9 owner_role_01
  322. owner_kafka_conn1 owner_role_01
  323. owner_kafka_conn10 owner_role_02
  324. owner_kafka_conn11 owner_role_03
  325. owner_kafka_conn2 other_owner
  326. owner_kafka_conn3 owner_role_01
  327. owner_kafka_conn4 other_owner
  328. owner_kafka_conn5 owner_role_01
  329. owner_kafka_conn6 other_owner
  330. owner_kafka_conn7 owner_role_02
  331. owner_kafka_conn8 other_owner
  332. owner_kafka_conn9 owner_role_01
  333. > SELECT name, unnest(privileges)::text FROM mz_databases WHERE name LIKE 'owner_db%'
  334. owner_db1 owner_role_01=UC/owner_role_01
  335. owner_db10 owner_role_02=UC/owner_role_02
  336. owner_db11 owner_role_03=UC/owner_role_03
  337. owner_db2 other_owner=UC/other_owner
  338. owner_db3 owner_role_01=UC/owner_role_01
  339. owner_db4 other_owner=UC/other_owner
  340. owner_db5 owner_role_01=UC/owner_role_01
  341. owner_db6 other_owner=UC/other_owner
  342. owner_db7 owner_role_02=UC/owner_role_02
  343. owner_db8 other_owner=UC/other_owner
  344. owner_db9 owner_role_01=UC/owner_role_01
  345. owner_db1 mz_support=U/owner_role_01
  346. owner_db10 mz_support=U/owner_role_02
  347. owner_db11 mz_support=U/owner_role_03
  348. owner_db2 mz_support=U/other_owner
  349. owner_db3 mz_support=U/owner_role_01
  350. owner_db4 mz_support=U/other_owner
  351. owner_db5 mz_support=U/owner_role_01
  352. owner_db6 mz_support=U/other_owner
  353. owner_db7 mz_support=U/owner_role_02
  354. owner_db8 mz_support=U/other_owner
  355. owner_db9 mz_support=U/owner_role_01
  356. > SELECT name, unnest(privileges)::text FROM mz_schemas WHERE name LIKE 'owner_schema%'
  357. owner_schema1 owner_role_01=UC/owner_role_01
  358. owner_schema10 owner_role_02=UC/owner_role_02
  359. owner_schema11 owner_role_03=UC/owner_role_03
  360. owner_schema2 other_owner=UC/other_owner
  361. owner_schema3 owner_role_01=UC/owner_role_01
  362. owner_schema4 other_owner=UC/other_owner
  363. owner_schema5 owner_role_01=UC/owner_role_01
  364. owner_schema6 other_owner=UC/other_owner
  365. owner_schema7 owner_role_02=UC/owner_role_02
  366. owner_schema8 other_owner=UC/other_owner
  367. owner_schema9 owner_role_01=UC/owner_role_01
  368. owner_schema1 mz_support=U/owner_role_01
  369. owner_schema10 mz_support=U/owner_role_02
  370. owner_schema11 mz_support=U/owner_role_03
  371. owner_schema2 mz_support=U/other_owner
  372. owner_schema3 mz_support=U/owner_role_01
  373. owner_schema4 mz_support=U/other_owner
  374. owner_schema5 mz_support=U/owner_role_01
  375. owner_schema6 mz_support=U/other_owner
  376. owner_schema7 mz_support=U/owner_role_02
  377. owner_schema8 mz_support=U/other_owner
  378. owner_schema9 mz_support=U/owner_role_01
  379. > SELECT name, unnest(privileges)::text FROM mz_tables WHERE name LIKE 'owner_t%'
  380. owner_t1 owner_role_01=arwd/owner_role_01
  381. owner_t10 owner_role_02=arwd/owner_role_02
  382. owner_t11 owner_role_03=arwd/owner_role_03
  383. owner_t2 other_owner=arwd/other_owner
  384. owner_t3 owner_role_01=arwd/owner_role_01
  385. owner_t4 other_owner=arwd/other_owner
  386. owner_t5 owner_role_01=arwd/owner_role_01
  387. owner_t6 other_owner=arwd/other_owner
  388. owner_t7 owner_role_02=arwd/owner_role_02
  389. owner_t8 other_owner=arwd/other_owner
  390. owner_t9 owner_role_01=arwd/owner_role_01
  391. > SELECT name, unnest(privileges)::text FROM mz_views WHERE name LIKE 'owner_v%'
  392. owner_v1 owner_role_01=r/owner_role_01
  393. owner_v10 owner_role_02=r/owner_role_02
  394. owner_v11 owner_role_03=r/owner_role_03
  395. owner_v2 other_owner=r/other_owner
  396. owner_v3 owner_role_01=r/owner_role_01
  397. owner_v4 other_owner=r/other_owner
  398. owner_v5 owner_role_01=r/owner_role_01
  399. owner_v6 other_owner=r/other_owner
  400. owner_v7 owner_role_02=r/owner_role_02
  401. owner_v8 other_owner=r/other_owner
  402. owner_v9 owner_role_01=r/owner_role_01
  403. > SELECT name, unnest(privileges)::text FROM mz_materialized_views WHERE name LIKE 'owner_mv%'
  404. owner_mv1 owner_role_01=r/owner_role_01
  405. owner_mv10 owner_role_02=r/owner_role_02
  406. owner_mv11 owner_role_03=r/owner_role_03
  407. owner_mv2 other_owner=r/other_owner
  408. owner_mv3 owner_role_01=r/owner_role_01
  409. owner_mv4 other_owner=r/other_owner
  410. owner_mv5 owner_role_01=r/owner_role_01
  411. owner_mv6 other_owner=r/other_owner
  412. owner_mv7 owner_role_02=r/owner_role_02
  413. owner_mv8 other_owner=r/other_owner
  414. owner_mv9 owner_role_01=r/owner_role_01
  415. > SELECT name, unnest(privileges)::text FROM mz_types WHERE name LIKE 'owner_type%'
  416. owner_type1 =U/owner_role_01
  417. owner_type1 owner_role_01=U/owner_role_01
  418. owner_type10 =U/owner_role_02
  419. owner_type10 owner_role_02=U/owner_role_02
  420. owner_type11 =U/owner_role_03
  421. owner_type11 owner_role_03=U/owner_role_03
  422. owner_type2 =U/other_owner
  423. owner_type2 other_owner=U/other_owner
  424. owner_type3 =U/owner_role_01
  425. owner_type3 owner_role_01=U/owner_role_01
  426. owner_type4 =U/other_owner
  427. owner_type4 other_owner=U/other_owner
  428. owner_type5 =U/owner_role_01
  429. owner_type5 owner_role_01=U/owner_role_01
  430. owner_type6 =U/other_owner
  431. owner_type6 other_owner=U/other_owner
  432. owner_type7 =U/owner_role_02
  433. owner_type7 owner_role_02=U/owner_role_02
  434. owner_type8 =U/other_owner
  435. owner_type8 other_owner=U/other_owner
  436. owner_type9 =U/owner_role_01
  437. owner_type9 owner_role_01=U/owner_role_01
  438. > SELECT name, unnest(privileges)::text FROM mz_secrets WHERE name LIKE 'owner_secret%'
  439. owner_secret1 owner_role_01=U/owner_role_01
  440. owner_secret10 owner_role_02=U/owner_role_02
  441. owner_secret11 owner_role_03=U/owner_role_03
  442. owner_secret2 other_owner=U/other_owner
  443. owner_secret3 owner_role_01=U/owner_role_01
  444. owner_secret4 other_owner=U/other_owner
  445. owner_secret5 owner_role_01=U/owner_role_01
  446. owner_secret6 other_owner=U/other_owner
  447. owner_secret7 owner_role_02=U/owner_role_02
  448. owner_secret8 other_owner=U/other_owner
  449. owner_secret9 owner_role_01=U/owner_role_01
  450. > SELECT name, unnest(privileges)::text FROM mz_sources WHERE name LIKE 'owner_source%' AND type = 'load-generator'
  451. owner_source1 owner_role_01=r/owner_role_01
  452. owner_source2 other_owner=r/other_owner
  453. ! SELECT name, unnest(privileges)::text FROM mz_sinks WHERE name LIKE 'owner_sink%'
  454. contains: column "privileges" does not exist
  455. > SELECT name, unnest(privileges)::text FROM mz_clusters WHERE name LIKE 'owner_cluster%'
  456. owner_cluster1 mz_support=U/owner_role_01
  457. owner_cluster1 owner_role_01=UC/owner_role_01
  458. owner_cluster2 mz_support=U/other_owner
  459. owner_cluster2 other_owner=UC/other_owner
  460. > SELECT name, unnest(privileges)::text FROM mz_connections WHERE name LIKE 'owner_%'
  461. owner_csr_conn1 owner_role_01=U/owner_role_01
  462. owner_csr_conn10 owner_role_02=U/owner_role_02
  463. owner_csr_conn11 owner_role_03=U/owner_role_03
  464. owner_csr_conn2 other_owner=U/other_owner
  465. owner_csr_conn3 owner_role_01=U/owner_role_01
  466. owner_csr_conn4 other_owner=U/other_owner
  467. owner_csr_conn5 owner_role_01=U/owner_role_01
  468. owner_csr_conn6 other_owner=U/other_owner
  469. owner_csr_conn7 owner_role_02=U/owner_role_02
  470. owner_csr_conn8 other_owner=U/other_owner
  471. owner_csr_conn9 owner_role_01=U/owner_role_01
  472. owner_kafka_conn1 owner_role_01=U/owner_role_01
  473. owner_kafka_conn10 owner_role_02=U/owner_role_02
  474. owner_kafka_conn11 owner_role_03=U/owner_role_03
  475. owner_kafka_conn2 other_owner=U/other_owner
  476. owner_kafka_conn3 owner_role_01=U/owner_role_01
  477. owner_kafka_conn4 other_owner=U/other_owner
  478. owner_kafka_conn5 owner_role_01=U/owner_role_01
  479. owner_kafka_conn6 other_owner=U/other_owner
  480. owner_kafka_conn7 owner_role_02=U/owner_role_02
  481. owner_kafka_conn8 other_owner=U/other_owner
  482. owner_kafka_conn9 owner_role_01=U/owner_role_01
  483. """
  484. )
  485. + self._drop_objects("owner_role_01", 9)
  486. + self._drop_objects("owner_role_02", 10)
  487. + self._drop_objects("owner_role_03", 11)
  488. )