Skip to content

Commit 21747a8

Browse files
committed
fixed tests
1 parent b6fa31a commit 21747a8

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/java/org/apache/cassandra/db/ColumnFamilyStore.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,9 @@ private void validateSnapshotName(String snapshotName)
19061906
// which is what blocks traversal attempts such as "../../mysnapshot"
19071907
if (!Pattern.compile("[a-zA-Z0-9_.+-]+").matcher(snapshotName).matches())
19081908
{
1909-
throw new IllegalArgumentException("Snapshot name contains illegal characters: " + snapshotName);
1909+
throw new IllegalArgumentException("Snapshot name contains illegal characters: " + snapshotName + ". " +
1910+
"Allowed characters must match the pattern: [a-zA-Z0-9_.+-]+" +
1911+
" with a maximum of length of " + FILENAME_LENGTH + " characters.");
19101912
}
19111913
}
19121914

test/unit/org/apache/cassandra/db/SnapshotTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,24 @@ public void testSnapshotNameValidation()
9696
// The shell-significant S3 "safe" characters (! * ' ( )) are deliberately NOT allowed.
9797
assertThatThrownBy(() -> cfs.snapshot("important!"))
9898
.isInstanceOf(IllegalArgumentException.class)
99-
.hasMessage("Snapshot name contains illegal characters: important!");
99+
.hasMessageContaining("Snapshot name contains illegal characters: important!");
100100
assertThatThrownBy(() -> cfs.snapshot("backup*"))
101101
.isInstanceOf(IllegalArgumentException.class)
102-
.hasMessage("Snapshot name contains illegal characters: backup*");
102+
.hasMessageContaining("Snapshot name contains illegal characters: backup*");
103103
assertThatThrownBy(() -> cfs.snapshot("o'snap"))
104104
.isInstanceOf(IllegalArgumentException.class)
105-
.hasMessage("Snapshot name contains illegal characters: o'snap");
105+
.hasMessageContaining("Snapshot name contains illegal characters: o'snap");
106106
assertThatThrownBy(() -> cfs.snapshot("snap(1)"))
107107
.isInstanceOf(IllegalArgumentException.class)
108-
.hasMessage("Snapshot name contains illegal characters: snap(1)");
108+
.hasMessageContaining("Snapshot name contains illegal characters: snap(1)");
109109

110110
// Other characters outside the allowed set must still be rejected.
111111
assertThatThrownBy(() -> cfs.snapshot("a tag"))
112112
.isInstanceOf(IllegalArgumentException.class)
113-
.hasMessage("Snapshot name contains illegal characters: a tag");
113+
.hasMessageContaining("Snapshot name contains illegal characters: a tag");
114114
assertThatThrownBy(() -> cfs.snapshot("a:tag"))
115115
.isInstanceOf(IllegalArgumentException.class)
116-
.hasMessage("Snapshot name contains illegal characters: a:tag");
116+
.hasMessageContaining("Snapshot name contains illegal characters: a:tag");
117117

118118
// "." and ".." pass the charset check but resolve to the snapshots/ dir itself
119119
// and its parent (the live table dir) respectively, so they must be rejected as reserved.

0 commit comments

Comments
 (0)