@@ -373,6 +373,79 @@ public void testEmptyStringRejection()
373373 assertInvalidMessage ("Cannot set security label to empty string" , buildSecurityLabelStatement (ObjectType .FIELD , fieldRef , "" ));
374374 }
375375
376+ @ Test
377+ public void testCommentAndSecurityLabelNotAllowedInCreateKeyspace ()
378+ {
379+ // Test that comment property is rejected in CREATE KEYSPACE WITH clause
380+ String createKsWithComment = "CREATE KEYSPACE ks_test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND comment = 'test comment'" ;
381+ assertInvalidMessage ("Unknown property 'comment'" , createKsWithComment );
382+
383+ // Test that security_label property is rejected in CREATE KEYSPACE WITH clause
384+ String createKsWithLabel = "CREATE KEYSPACE ks_test2 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND security_label = 'TEST_LABEL'" ;
385+ assertInvalidMessage ("Unknown property 'security_label'" , createKsWithLabel );
386+ }
387+
388+ @ Test
389+ public void testCommentAndSecurityLabelNotAllowedInAlterKeyspace ()
390+ {
391+ createKeyspaceWithName ("ks_alter_test" );
392+
393+ // Test that comment property is rejected in ALTER KEYSPACE WITH clause
394+ String alterKsWithComment = "ALTER KEYSPACE ks_alter_test WITH comment = 'test comment'" ;
395+ assertInvalidMessage ("Unknown property 'comment'" , alterKsWithComment );
396+
397+ // Test that security_label property is rejected in ALTER KEYSPACE WITH clause
398+ String alterKsWithLabel = "ALTER KEYSPACE ks_alter_test WITH security_label = 'TEST_LABEL'" ;
399+ assertInvalidMessage ("Unknown property 'security_label'" , alterKsWithLabel );
400+ }
401+
402+ @ Test
403+ public void testSecurityLabelNotAllowedInCreateTable ()
404+ {
405+ createKeyspaceWithName ("ks_table_test" );
406+
407+ // Test that security_label property is rejected in CREATE TABLE WITH clause
408+ String createTableWithLabel = "CREATE TABLE ks_table_test.t1 (id int PRIMARY KEY, name text) WITH security_label = 'TEST_LABEL'" ;
409+ assertInvalidMessage ("Unknown property 'security_label'" , createTableWithLabel );
410+
411+ // Verify that comment IS allowed in CREATE TABLE for backward compatibility
412+ String createTableWithComment = "CREATE TABLE ks_table_test.t2 (id int PRIMARY KEY, name text) WITH comment = 'test comment'" ;
413+ execute (createTableWithComment );
414+ assertComment (ObjectType .TABLE , "ks_table_test" , "ks_table_test.t2" , "test comment" );
415+ }
416+
417+ @ Test
418+ public void testSecurityLabelNotAllowedInAlterTable ()
419+ {
420+ createKeyspaceWithName ("ks_alter_table_test" );
421+ createTableWithName ("ks_alter_table_test" , "t1" );
422+
423+ // Test that security_label property is rejected in ALTER TABLE WITH clause
424+ String alterTableWithLabel = "ALTER TABLE ks_alter_table_test.t1 WITH security_label = 'TEST_LABEL'" ;
425+ assertInvalidMessage ("Unknown property 'security_label'" , alterTableWithLabel );
426+
427+ // Verify that comment IS allowed in ALTER TABLE for backward compatibility
428+ String alterTableWithComment = "ALTER TABLE ks_alter_table_test.t1 WITH comment = 'test comment'" ;
429+ execute (alterTableWithComment );
430+ assertComment (ObjectType .TABLE , "ks_alter_table_test" , "ks_alter_table_test.t1" , "test comment" );
431+ }
432+
433+ @ Test
434+ public void testSecurityLabelNotAllowedInCreateTableLike ()
435+ {
436+ createKeyspaceWithName ("ks_like_test" );
437+ createTableWithName ("ks_like_test" , "source_table" );
438+
439+ // Test that security_label property is rejected in CREATE TABLE ... LIKE ... WITH clause
440+ String createTableLikeWithLabel = "CREATE TABLE ks_like_test.target_table LIKE ks_like_test.source_table WITH security_label = 'TEST_LABEL'" ;
441+ assertInvalidMessage ("Unknown property 'security_label'" , createTableLikeWithLabel );
442+
443+ // Verify that comment IS allowed in CREATE TABLE ... LIKE for backward compatibility
444+ String createTableLikeWithComment = "CREATE TABLE ks_like_test.target_table2 LIKE ks_like_test.source_table WITH comment = 'test comment'" ;
445+ execute (createTableLikeWithComment );
446+ assertComment (ObjectType .TABLE , "ks_like_test" , "ks_like_test.target_table2" , "test comment" );
447+ }
448+
376449 // Helper methods for setting comments and security labels
377450 private void setComment (ObjectType type , String objectName , String comment )
378451 {
0 commit comments