drop_user.slt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. # Copyright 2015 - 2019 The Cockroach Authors. All rights reserved.
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. #
  11. # This file is derived from the logic test suite in CockroachDB. The
  12. # original file was retrieved on June 10, 2019 from:
  13. #
  14. # https://github.com/cockroachdb/cockroach/blob/d2f7fbf5dd1fc1a099bbad790a2e1f7c60a66cc3/pkg/sql/logictest/testdata/logic_test/drop_user
  15. #
  16. # The original source code is subject to the terms of the Apache
  17. # 2.0 license, a copy of which can be found in the LICENSE file at the
  18. # root of this repository.
  19. # not supported yet
  20. halt
  21. mode cockroach
  22. statement ok
  23. CREATE USER user1
  24. query T colnames
  25. SHOW USERS
  26. ----
  27. user_name
  28. root
  29. testuser
  30. user1
  31. statement ok
  32. DROP USER user1
  33. query T colnames
  34. SHOW USERS
  35. ----
  36. user_name
  37. root
  38. testuser
  39. statement ok
  40. CREATE USER user1
  41. query T colnames
  42. SHOW USERS
  43. ----
  44. user_name
  45. root
  46. testuser
  47. user1
  48. statement ok
  49. DROP USER USEr1
  50. query T colnames
  51. SHOW USERS
  52. ----
  53. user_name
  54. root
  55. testuser
  56. statement error user user1 does not exist
  57. DROP USER user1
  58. statement error user user1 does not exist
  59. DROP USER usER1
  60. statement ok
  61. DROP USER IF EXISTS user1
  62. statement error username "node" reserved
  63. DROP USER node
  64. statement error pq: username "foo☂" invalid; usernames are case insensitive, must start with a letter or underscore, may contain letters, digits, dashes, or underscores, and must not exceed 63 characters
  65. DROP USER foo☂
  66. statement ok
  67. CREATE USER user1
  68. statement ok
  69. CREATE USER user2
  70. statement ok
  71. CREATE USER user3
  72. statement ok
  73. CREATE USER user4
  74. query T colnames
  75. SHOW USERS
  76. ----
  77. user_name
  78. root
  79. testuser
  80. user1
  81. user2
  82. user3
  83. user4
  84. statement ok
  85. DROP USER user1,user2
  86. query T colnames
  87. SHOW USERS
  88. ----
  89. user_name
  90. root
  91. testuser
  92. user3
  93. user4
  94. statement error user user1 does not exist
  95. DROP USER user1,user3
  96. query T colnames
  97. SHOW USERS
  98. ----
  99. user_name
  100. root
  101. testuser
  102. user3
  103. user4
  104. statement ok
  105. CREATE USER user1
  106. statement ok
  107. CREATE TABLE foo(x INT);
  108. GRANT SELECT ON foo TO user3;
  109. GRANT SELECT ON DATABASE test TO user1
  110. statement error cannot drop users or roles user1, user3: grants still exist on test, test.public.foo
  111. DROP USER IF EXISTS user1,user3
  112. statement error cannot drop users or roles user1, user3: grants still exist on test
  113. REVOKE SELECT ON foo FROM user3;
  114. DROP USER IF EXISTS user1,user3
  115. statement ok
  116. REVOKE SELECT ON DATABASE test FROM user1;
  117. DROP USER IF EXISTS user1,user3
  118. statement ok
  119. PREPARE du AS DROP USER $1;
  120. EXECUTE du('user4')
  121. query T colnames
  122. SHOW USERS
  123. ----
  124. user_name
  125. root
  126. testuser
  127. user testuser
  128. statement error pq: user testuser does not have DELETE privilege on relation users
  129. DROP USER user2
  130. user root
  131. statement error pq: cannot drop user or role root: grants still exist on .*
  132. DROP USER root
  133. statement error pq: cannot drop user or role admin: grants still exist on .*
  134. DROP USER admin