| 1 |
--echo # |
| 2 |
--echo # WL#12261 Control (enforce and disable) table encryption |
| 3 |
--echo # |
| 4 |
--source include/have_debug.inc |
| 5 |
|
| 6 |
--echo # Pre-define user u1, which is used in different tests below. |
| 7 |
CREATE USER u1@localhost; |
| 8 |
GRANT ALL ON db1.* TO u1@localhost; |
| 9 |
GRANT CREATE TABLESPACE, PROCESS, SYSTEM_VARIABLES_ADMIN ON *.* TO u1@localhost; |
| 10 |
SET GLOBAL debug= '+d,skip_table_encryption_admin_check_for_set'; |
| 11 |
connect (con1, localhost, u1); |
| 12 |
|
| 13 |
--echo # This test run CREATE/ALTER TABLESPACE in different configurations, |
| 14 |
--echo # |
| 15 |
--echo # - Setting table_encryption_privilege_check to true/false. |
| 16 |
--echo # - Setting default_table_encryption to true/false. |
| 17 |
--echo # - With and without ENCRYPTION clause. |
| 18 |
--echo # - With and without user holding TABLE_ENCRYPTION_ADMIN privilege. |
| 19 |
--echo # - Test INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 20 |
--echo # - Check for warnings generated. |
| 21 |
--echo # |
| 22 |
|
| 23 |
--let expected_error=0 |
| 24 |
--let caseno=0 |
| 25 |
|
| 26 |
--echo ````````````````````````````````````````````````````````` |
| 27 |
--echo # CREATE TABLESPACE with explicit ENCRYPTION clause |
| 28 |
--echo # table_encryption_privilege_check=false |
| 29 |
--let explicit_encryption_clause=false |
| 30 |
--let privilege_check=false |
| 31 |
|
| 32 |
--let global_database_encryption_default=false |
| 33 |
--source ./create_tablespace.inc |
| 34 |
--let global_database_encryption_default=true |
| 35 |
--source ./create_tablespace.inc |
| 36 |
|
| 37 |
--echo ````````````````````````````````````````````````````````` |
| 38 |
--echo # table_encryption_privilege_check=true |
| 39 |
--let privilege_check=true |
| 40 |
|
| 41 |
--let global_database_encryption_default=false |
| 42 |
--source ./create_tablespace.inc |
| 43 |
--let global_database_encryption_default=true |
| 44 |
--source ./create_tablespace.inc |
| 45 |
|
| 46 |
--echo ````````````````````````````````````````````````````````` |
| 47 |
--echo # CREATE TABLESPACE with explicit ENCRYPTION clause |
| 48 |
--echo # table_encryption_privilege_check=false |
| 49 |
--let explicit_encryption_clause=true |
| 50 |
--let privilege_check=false |
| 51 |
|
| 52 |
--let global_database_encryption_default=false |
| 53 |
--let tablespace_encryption='y' |
| 54 |
--source ./create_tablespace.inc |
| 55 |
--let tablespace_encryption='n' |
| 56 |
--source ./create_tablespace.inc |
| 57 |
--let global_database_encryption_default=true |
| 58 |
--let tablespace_encryption='y' |
| 59 |
--source ./create_tablespace.inc |
| 60 |
--let tablespace_encryption='n' |
| 61 |
--source ./create_tablespace.inc |
| 62 |
|
| 63 |
--echo ````````````````````````````````````````````````````````` |
| 64 |
--echo # table_encryption_privilege_check=true |
| 65 |
--let privilege_check=true |
| 66 |
|
| 67 |
--let global_database_encryption_default=false |
| 68 |
--let expected_error=ER_CANNOT_SET_TABLESPACE_ENCRYPTION |
| 69 |
--let tablespace_encryption='y' |
| 70 |
--source ./create_tablespace.inc |
| 71 |
--let expected_error=0 |
| 72 |
--let tablespace_encryption='n' |
| 73 |
--source ./create_tablespace.inc |
| 74 |
--let global_database_encryption_default=true |
| 75 |
--let tablespace_encryption='y' |
| 76 |
--source ./create_tablespace.inc |
| 77 |
--let expected_error=ER_CANNOT_SET_TABLESPACE_ENCRYPTION |
| 78 |
--let tablespace_encryption='n' |
| 79 |
--source ./create_tablespace.inc |
| 80 |
|
| 81 |
--echo ````````````````````````````````````````````````````````` |
| 82 |
--echo # Check for invalid ENCRYPTION clause value. |
| 83 |
--let privilege_check=false |
| 84 |
--let global_database_encryption_default=false |
| 85 |
--let expected_error=ER_INVALID_ENCRYPTION_OPTION |
| 86 |
--let tablespace_encryption='k' |
| 87 |
--source ./create_tablespace.inc |
| 88 |
|
| 89 |
--echo ````````````````````````````````````````````````````````` |
| 90 |
--echo # The test cases run ALTER TABLESPACE (with no tables) |
| 91 |
--echo # See test tablespace_with_tables.test. |
| 92 |
--let caseno=0 |
| 93 |
|
| 94 |
--echo ````````````````````````````````````````````````````````` |
| 95 |
--echo # Unencrypted TABLESPACE to Unencrypted TABLESPACE (Nop) |
| 96 |
--echo # |
| 97 |
--let global_database_encryption_default=false |
| 98 |
--let tablespace_encryption='n' |
| 99 |
--let alter_encryption='n' |
| 100 |
|
| 101 |
--let privilege_check=false |
| 102 |
--let expected_error=0 |
| 103 |
--source ./alter_empty_tablespace.inc |
| 104 |
|
| 105 |
--let privilege_check=true |
| 106 |
--let expected_error=0 |
| 107 |
--source ./alter_empty_tablespace.inc |
| 108 |
|
| 109 |
--echo ````````````````````````````````````````````````````````` |
| 110 |
--echo # Encrypted TABLESPACE to Encrypted TABLESPACE (Nop) |
| 111 |
--echo # |
| 112 |
--let global_database_encryption_default=true |
| 113 |
--let tablespace_encryption='y' |
| 114 |
--let alter_encryption='y' |
| 115 |
|
| 116 |
--let privilege_check=false |
| 117 |
--let expected_error=0 |
| 118 |
--source ./alter_empty_tablespace.inc |
| 119 |
|
| 120 |
--let privilege_check=true |
| 121 |
--let expected_error=0 |
| 122 |
--source ./alter_empty_tablespace.inc |
| 123 |
|
| 124 |
--echo ````````````````````````````````````````````````````````` |
| 125 |
--echo # Unencrypted TABLESPACE to encrypted TABLESPACE |
| 126 |
--echo # with database encryption default 'n' |
| 127 |
--echo # |
| 128 |
--let global_database_encryption_default=false |
| 129 |
--let tablespace_encryption='n' |
| 130 |
--let alter_encryption='y' |
| 131 |
|
| 132 |
--let privilege_check=false |
| 133 |
--let expected_error=0 |
| 134 |
--source ./alter_empty_tablespace.inc |
| 135 |
|
| 136 |
--let privilege_check=true |
| 137 |
--let expected_error=ER_CANNOT_SET_TABLESPACE_ENCRYPTION |
| 138 |
--source ./alter_empty_tablespace.inc |
| 139 |
|
| 140 |
--echo ````````````````````````````````````````````````````````` |
| 141 |
--echo # Unencrypted TABLESPACE to encrypted TABLESPACE |
| 142 |
--echo # with database encryption default 'y' |
| 143 |
--echo # |
| 144 |
--let global_database_encryption_default=true |
| 145 |
--let tablespace_encryption='n' |
| 146 |
--let alter_encryption='y' |
| 147 |
|
| 148 |
--let privilege_check=false |
| 149 |
--let expected_error=0 |
| 150 |
--source ./alter_empty_tablespace.inc |
| 151 |
|
| 152 |
--let privilege_check=true |
| 153 |
--let expected_error=0 |
| 154 |
--source ./alter_empty_tablespace.inc |
| 155 |
|
| 156 |
--echo ````````````````````````````````````````````````````````` |
| 157 |
--echo # Encrypted TABLESPACE to unencrypted TABLESPACE |
| 158 |
--echo # with database encryption default 'n' |
| 159 |
--echo # |
| 160 |
--let global_database_encryption_default=false |
| 161 |
--let tablespace_encryption='y' |
| 162 |
--let alter_encryption='n' |
| 163 |
|
| 164 |
--let privilege_check=false |
| 165 |
--let expected_error=0 |
| 166 |
--source ./alter_empty_tablespace.inc |
| 167 |
|
| 168 |
--let privilege_check=true |
| 169 |
--let expected_error=0 |
| 170 |
--source ./alter_empty_tablespace.inc |
| 171 |
|
| 172 |
--echo ````````````````````````````````````````````````````````` |
| 173 |
--echo # Encrypted TABLESPACE to unencrypted TABLESPACE |
| 174 |
--echo # with database encryption default 'y' |
| 175 |
--echo # |
| 176 |
--let global_database_encryption_default=true |
| 177 |
--let tablespace_encryption='y' |
| 178 |
--let alter_encryption='n' |
| 179 |
|
| 180 |
--let privilege_check=false |
| 181 |
--let expected_error=0 |
| 182 |
--source ./alter_empty_tablespace.inc |
| 183 |
|
| 184 |
--let privilege_check=true |
| 185 |
--let expected_error=ER_CANNOT_SET_TABLESPACE_ENCRYPTION |
| 186 |
--source ./alter_empty_tablespace.inc |
| 187 |
|
| 188 |
--echo ````````````````````````````````````````````````````````` |
| 189 |
--echo # Check for Invalid encryption option. |
| 190 |
--let privilege_check=false |
| 191 |
--let global_database_encryption_default=false |
| 192 |
--let expected_error=ER_INVALID_ENCRYPTION_OPTION |
| 193 |
--let alter_encryption='k' |
| 194 |
--source ./alter_empty_tablespace.inc |
| 195 |
|
| 196 |
--echo # Cleanup |
| 197 |
disconnect con1; |
| 198 |
connection default; |
| 199 |
DROP USER u1@localhost; |
| 200 |
SET GLOBAL debug= '-d,skip_table_encryption_admin_check_for_set'; |