Skip to content

Commit 2afc7b0

Browse files
committed
privileges and views
1 parent a5f3a3f commit 2afc7b0

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/bwc/test_rolling_upgrade.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import unittest
22
from crate.client import connect
3+
from crate.client.exceptions import ProgrammingError
4+
35
from crate.qa.tests import NodeProvider, insert_data, wait_for_active_shards, UpgradePath
46

57
ROLLING_UPGRADES_V4 = (
@@ -103,6 +105,7 @@ def _test_rolling_upgrade(self, path, nodes):
103105
) CLUSTERED INTO {shards} SHARDS
104106
WITH (number_of_replicas={replicas})
105107
''')
108+
c.execute("deny dql on table doc.t1 to arthur")
106109
c.execute("CREATE VIEW doc.v1 AS SELECT type, title, value FROM doc.t1")
107110
insert_data(conn, 'doc', 't1', 1000)
108111

@@ -150,6 +153,11 @@ def _test_rolling_upgrade(self, path, nodes):
150153
c = custom_user_conn.cursor()
151154
wait_for_active_shards(c, expected_active_shards)
152155
c.execute("SELECT 1")
156+
# has no privilege
157+
with self.assertRaisesRegex(ProgrammingError, "RelationUnknown.*"):
158+
c.execute("EXPLAIN SELECT * FROM doc.t1")
159+
# has privilege
160+
c.execute("EXPLAIN SELECT * FROM doc.v1")
153161

154162
cluster[idx] = new_node
155163
with connect(new_node.http_url, error_trace=True) as conn:
@@ -160,7 +168,10 @@ def _test_rolling_upgrade(self, path, nodes):
160168
self.assertEqual(c.fetchall(), [["arthur"], ["crate"]])
161169

162170
c.execute("select * from sys.privileges")
163-
self.assertEqual(c.fetchall(), [["CLUSTER", "arthur", "crate", None, "GRANT", "DQL"]])
171+
self.assertEqual(
172+
c.fetchall(),
173+
[['TABLE', 'arthur', 'crate', 'doc.t1', 'DENY', 'DQL'],
174+
['CLUSTER', 'arthur', 'crate', None, 'GRANT', 'DQL']])
164175

165176
c.execute('''
166177
SELECT type, AVG(value)
@@ -239,3 +250,14 @@ def _test_rolling_upgrade(self, path, nodes):
239250
''')
240251
res = c.fetchone()
241252
self.assertEqual(res[0], nodes + 1)
253+
254+
# Ensure Arthur can be dropped and re-added
255+
c.execute("drop user arthur")
256+
c.execute("select * from sys.privileges")
257+
self.assertEqual(c.fetchall(), [])
258+
259+
# Ensure view 'v' can be dropped and re-added
260+
c.execute("DROP VIEW doc.v1")
261+
c.execute("CREATE VIEW doc.v1 AS SELECT 11")
262+
c.execute("SELECT * FROM doc.v1")
263+
self.assertEqual(c.fetchall(), [[11]])

0 commit comments

Comments
 (0)