File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
api/src/main/java/io/github/_4drian3d/chatregulator/api/checks
plugin/src/test/java/io/github/_4drian3d/chatregulator/modules/checks Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public final class FloodCheck implements Check {
2323 .maximumSize (3 )
2424 .initialCapacity (1 )
2525 .build (length -> Pattern .compile (
26- "(\\ w )\\ 1{" +length +",}" ,
26+ "(. )\\ 1{" +length +",}" ,
2727 Pattern .CASE_INSENSITIVE | Pattern .UNICODE_CASE )
2828 );
2929 private final Pattern pattern ;
Original file line number Diff line number Diff line change @@ -58,4 +58,33 @@ void testTest(String original, String expected) {
5858
5959 assertEquals (expected , result .replaced ());
6060 }
61+
62+ @ ParameterizedTest
63+ @ CsvSource ({
64+ "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" ,
65+ " ҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉ ҉"
66+ })
67+ void illegalCharsFloodTest (String str ) {
68+ final FloodCheck check = FloodCheck .builder ()
69+ .controlType (ControlType .BLOCK )
70+ .limit (3 )
71+ .build ();
72+ final CheckResult result = check .check (TestsUtils .dummyPlayer (), str );
73+ assertTrue (result .isDenied ());
74+ }
75+
76+ @ ParameterizedTest
77+ @ CsvSource ({
78+ "pls no" ,
79+ "plsnoplsnoplsnoplsnoplsnoplsnoplsnoplsnoplsno" ,
80+ "yeahnosequemásponeraquiparaquenolodetecte"
81+ })
82+ void shouldNotDetectTest (String string ) {
83+ final FloodCheck check = FloodCheck .builder ()
84+ .controlType (ControlType .BLOCK )
85+ .limit (3 )
86+ .build ();
87+ final CheckResult result = check .check (TestsUtils .dummyPlayer (), string );
88+ assertTrue (result .isAllowed ());
89+ }
6190}
You can’t perform that action at this time.
0 commit comments