@@ -1067,43 +1067,43 @@ public void testHTableDDLDefense() throws Exception {
1067
1067
String sql = "alter table testHTableDefense$cf1 ADD CONSTRAINT cons1 CHECK(T < 0)" ;
1068
1068
System .out .println ("execute sql: " + sql );
1069
1069
conn .createStatement ().execute (sql );
1070
+ fail ();
1070
1071
} catch (SQLException e ) {
1071
- e .printStackTrace ();
1072
1072
Assert .assertEquals (1235 , e .getErrorCode ());
1073
- Assert .assertEquals ("user ddl with created_by attribute not supported" , e .getMessage ());
1073
+ Assert .assertEquals ("table kv_attribute with ' \" CreateBy \" : \" Admin \" ' not supported" , e .getMessage ());
1074
1074
}
1075
1075
1076
1076
// 5. alter table add index
1077
1077
try {
1078
1078
String sql = "alter table testHTableDefense$cf1 ADD INDEX idx_1(T)" ;
1079
1079
System .out .println ("execute sql: " + sql );
1080
1080
conn .createStatement ().execute (sql );
1081
+ fail ();
1081
1082
} catch (SQLException e ) {
1082
- e .printStackTrace ();
1083
1083
Assert .assertEquals (1235 , e .getErrorCode ());
1084
- Assert .assertEquals ("user ddl with created_by attribute not supported" , e .getMessage ());
1084
+ Assert .assertEquals ("table kv_attribute with ' \" CreateBy \" : \" Admin \" ' not supported" , e .getMessage ());
1085
1085
}
1086
1086
1087
1087
// 5. alter table add fk
1088
1088
try {
1089
1089
String sql = "alter table testHTableDefense$cf1 MODIFY COLUMN V LONGTEXT" ;
1090
1090
System .out .println ("execute sql: " + sql );
1091
1091
conn .createStatement ().execute (sql );
1092
+ fail ();
1092
1093
} catch (SQLException e ) {
1093
- e .printStackTrace ();
1094
1094
Assert .assertEquals (1235 , e .getErrorCode ());
1095
- Assert .assertEquals ("user ddl with created_by attribute not supported" , e .getMessage ());
1095
+ Assert .assertEquals ("table kv_attribute with ' \" CreateBy \" : \" Admin \" ' not supported" , e .getMessage ());
1096
1096
}
1097
1097
1098
1098
// 6. alter table modify column to lob
1099
1099
try {
1100
1100
String sql = "alter table testHTableDefense$cf1 ADD CONSTRAINT hbase_fk_1 FOREIGN KEY(K) REFERENCES testHTableDefense$cf2(K)" ;
1101
1101
System .out .println ("execute sql: " + sql );
1102
1102
conn .createStatement ().execute (sql );
1103
+ fail ();
1103
1104
} catch (SQLException e ) {
1104
- e .printStackTrace ();
1105
1105
Assert .assertEquals (1235 , e .getErrorCode ());
1106
- Assert .assertEquals ("user ddl with created_by attribute not supported" , e .getMessage ());
1106
+ Assert .assertEquals ("table kv_attribute with ' \" CreateBy \" : \" Admin \" ' not supported" , e .getMessage ());
1107
1107
}
1108
1108
1109
1109
// 7. create trigger
@@ -1113,67 +1113,67 @@ public void testHTableDDLDefense() throws Exception {
1113
1113
" BEGIN END" ;
1114
1114
System .out .println ("execute sql: " + sql );
1115
1115
conn .createStatement ().execute (sql );
1116
+ fail ();
1116
1117
} catch (SQLException e ) {
1117
- e .printStackTrace ();
1118
1118
Assert .assertEquals (1235 , e .getErrorCode ());
1119
- Assert .assertEquals ("user ddl with created_by attribute not supported" , e .getMessage ());
1119
+ Assert .assertEquals ("table kv_attribute with ' \" CreateBy \" : \" Admin \" ' not supported" , e .getMessage ());
1120
1120
}
1121
1121
1122
1122
// 8. create view
1123
1123
try {
1124
1124
String sql = " CREATE VIEW hbase_view_1 as select * from testHTableDefense$cf1" ;
1125
1125
System .out .println ("execute sql: " + sql );
1126
1126
conn .createStatement ().execute (sql );
1127
+ fail ();
1127
1128
} catch (SQLException e ) {
1128
- e .printStackTrace ();
1129
1129
Assert .assertEquals (1235 , e .getErrorCode ());
1130
- Assert .assertEquals ("user ddl with created_by attribute not supported" , e .getMessage ());
1130
+ Assert .assertEquals ("table kv_attribute with ' \" CreateBy \" : \" Admin \" ' not supported" , e .getMessage ());
1131
1131
}
1132
1132
1133
1133
// 9. alter view
1134
1134
try {
1135
1135
String sql = "ALTER VIEW hbase_view_1 as select * from testHTableDefense$cf1" ;
1136
1136
System .out .println ("execute sql: " + sql );
1137
1137
conn .createStatement ().execute (sql );
1138
+ fail ();
1138
1139
} catch (SQLException e ) {
1139
- e .printStackTrace ();
1140
1140
Assert .assertEquals (1235 , e .getErrorCode ());
1141
- Assert .assertEquals ("user ddl with created_by attribute not supported" , e .getMessage ());
1141
+ Assert .assertEquals ("table kv_attribute with ' \" CreateBy \" : \" Admin \" ' not supported" , e .getMessage ());
1142
1142
}
1143
1143
1144
1144
// 10. create index
1145
1145
try {
1146
1146
String sql = " CREATE INDEX testHTableDefense$cf1_idx_T on testHTableDefense$cf1(T)" ;
1147
1147
System .out .println ("execute sql: " + sql );
1148
1148
conn .createStatement ().execute (sql );
1149
+ fail ();
1149
1150
} catch (SQLException e ) {
1150
- e .printStackTrace ();
1151
1151
Assert .assertEquals (1235 , e .getErrorCode ());
1152
- Assert .assertEquals ("user ddl with created_by attribute not supported" , e .getMessage ());
1152
+ Assert .assertEquals ("table kv_attribute with ' \" CreateBy \" : \" Admin \" ' not supported" , e .getMessage ());
1153
1153
}
1154
1154
1155
1155
1156
1156
// 11. explicit create table and specify created_by:admin, should be prohibited
1157
1157
try {
1158
- String sql = "CREATE TABLE testHTableDefense$cf3(a int primary key) kv_attributes ='{\" Hbase\" : {\" CREATED_BY \" : \" ADMIN \" }}'" ;
1158
+ String sql = "CREATE TABLE testHTableDefense$cf3(a int primary key) kv_attributes ='{\" Hbase\" : {\" CreatedBy \" : \" Admin \" }}'" ;
1159
1159
System .out .println ("execute sql: " + sql );
1160
1160
conn .createStatement ().execute (sql );
1161
+ fail ();
1161
1162
} catch (SQLException e ) {
1162
- e .printStackTrace ();
1163
1163
Assert .assertEquals (1235 , e .getErrorCode ());
1164
- Assert .assertEquals ("user ddl with created_by attribute not supported" , e .getMessage ());
1164
+ Assert .assertEquals ("table kv_attribute with ' \" CreateBy \" : \" Admin \" ' not supported" , e .getMessage ());
1165
1165
}
1166
1166
1167
1167
// 12. alter table to created_by:admin, should be prohibited
1168
1168
try {
1169
1169
String sql1 = "CREATE TABLE testHTableDefense$cf3(a int primary key)" ;
1170
1170
System .out .println ("execute sql: " + sql1 );
1171
1171
conn .createStatement ().execute (sql1 );
1172
- String sql2 = "alter table testHTableDefense$cf3 kv_attributes ='{\" Hbase\" : {\" CREATED_BY \" : \" ADMIN \" }}'" ;
1172
+ String sql2 = "alter table testHTableDefense$cf3 kv_attributes ='{\" Hbase\" : {\" CreatedBy \" : \" Admin \" }}'" ;
1173
1173
System .out .println ("execute sql: " + sql2 );
1174
1174
conn .createStatement ().execute (sql2 );
1175
+ fail ();
1175
1176
} catch (SQLException e ) {
1176
- e .printStackTrace ();
1177
1177
Assert .assertEquals (1235 , e .getErrorCode ());
1178
1178
Assert .assertEquals ("alter table kv attributes to created by admin not supported" , e .getMessage ());
1179
1179
// clean table
@@ -1191,8 +1191,8 @@ public void testHTableDDLDefense() throws Exception {
1191
1191
System .out .println ("execute sql: " + sql2 );
1192
1192
conn .createStatement ().execute (sql2 );
1193
1193
admin .disableTable (TableName .valueOf ("testHTableDefense2" ));
1194
+ fail ();
1194
1195
} catch (Exception e ) {
1195
- e .printStackTrace ();
1196
1196
Assert .assertEquals (-4007 , ((ObTableException )e .getCause ()).getErrorCode ());
1197
1197
1198
1198
}
@@ -1206,8 +1206,8 @@ public void testHTableDDLDefense() throws Exception {
1206
1206
System .out .println ("execute sql: " + sql2 );
1207
1207
conn .createStatement ().execute (sql2 );
1208
1208
admin .deleteTable (TableName .valueOf ("testHTableDefense2" ));
1209
+ fail ();
1209
1210
} catch (Exception e ) {
1210
- e .printStackTrace ();
1211
1211
Assert .assertEquals (-4007 , ((ObTableException )e .getCause ()).getErrorCode ());
1212
1212
}
1213
1213
0 commit comments