-
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1527 from steve-community/1526-validate-chargebox…
…id-for-ws-connections validate chargeBoxId for WS connections (#1526)
- Loading branch information
Showing
13 changed files
with
230 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
src/test/java/de/rwth/idsg/steve/web/validation/ChargeBoxIdValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
/* | ||
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve | ||
* Copyright (C) 2013-2024 SteVe Community Team | ||
* All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package de.rwth.idsg.steve.web.validation; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* @author Sevket Goekay <sevketgokay@gmail.com> | ||
* @since 01.08.2024 | ||
*/ | ||
public class ChargeBoxIdValidatorTest { | ||
|
||
ChargeBoxIdValidator validator = new ChargeBoxIdValidator(); | ||
|
||
@Test | ||
public void testNull() { | ||
Assertions.assertFalse(validator.isValid(null)); | ||
} | ||
|
||
@Test | ||
public void testEmpty() { | ||
Assertions.assertFalse(validator.isValid("")); | ||
} | ||
|
||
@Test | ||
public void testSpace() { | ||
Assertions.assertFalse(validator.isValid(" ")); | ||
} | ||
|
||
@Test | ||
public void testAllLowercaseLetters() { | ||
Assertions.assertTrue(validator.isValid("test")); | ||
} | ||
|
||
@Test | ||
public void testAllUppercaseLetters() { | ||
Assertions.assertTrue(validator.isValid("TEST")); | ||
} | ||
|
||
@Test | ||
public void testMixedCaseLetters() { | ||
Assertions.assertTrue(validator.isValid("TesT")); | ||
Assertions.assertTrue(validator.isValid("tEst")); | ||
} | ||
|
||
@Test | ||
public void testLettersAndNumbers() { | ||
Assertions.assertTrue(validator.isValid("test12")); | ||
Assertions.assertTrue(validator.isValid("89test")); | ||
Assertions.assertTrue(validator.isValid("te9s0t")); | ||
} | ||
|
||
@Test | ||
public void testDot() { | ||
Assertions.assertTrue(validator.isValid(".test")); | ||
Assertions.assertTrue(validator.isValid("test.")); | ||
Assertions.assertTrue(validator.isValid("te..st")); | ||
} | ||
|
||
@Test | ||
public void testDash() { | ||
Assertions.assertTrue(validator.isValid("-test")); | ||
Assertions.assertTrue(validator.isValid("test-")); | ||
Assertions.assertTrue(validator.isValid("te--st")); | ||
} | ||
|
||
@Test | ||
public void testUnderscore() { | ||
Assertions.assertTrue(validator.isValid("_test")); | ||
Assertions.assertTrue(validator.isValid("test_")); | ||
Assertions.assertTrue(validator.isValid("te__st")); | ||
} | ||
|
||
@Test | ||
public void testColon() { | ||
Assertions.assertTrue(validator.isValid(":test")); | ||
Assertions.assertTrue(validator.isValid("test:")); | ||
Assertions.assertTrue(validator.isValid("te::st")); | ||
Assertions.assertTrue(validator.isValid("VID:00XXXXXXXXXX")); | ||
} | ||
|
||
@Test | ||
public void testPoundSign() { | ||
Assertions.assertTrue(validator.isValid("#test")); | ||
Assertions.assertTrue(validator.isValid("test#")); | ||
Assertions.assertTrue(validator.isValid("te##st")); | ||
Assertions.assertTrue(validator.isValid("#FreeCharging")); | ||
} | ||
|
||
@Test | ||
public void testCombined() { | ||
Assertions.assertTrue(validator.isValid("1t.E-S_:t20#")); | ||
} | ||
|
||
@Test | ||
public void testSpaceAtBeginning() { | ||
Assertions.assertFalse(validator.isValid(" test")); | ||
} | ||
|
||
@Test | ||
public void testSpaceAtEnd() { | ||
Assertions.assertFalse(validator.isValid("test ")); | ||
} | ||
|
||
@Test | ||
public void testSpaceInMiddle() { | ||
Assertions.assertTrue(validator.isValid("test1 test2")); | ||
} | ||
|
||
@Test | ||
public void testOpeningParenthesis() { | ||
Assertions.assertFalse(validator.isValid("te(st")); | ||
} | ||
|
||
@Test | ||
public void testClosingParenthesis() { | ||
Assertions.assertFalse(validator.isValid("te)st")); | ||
} | ||
|
||
@Test | ||
public void testBiggerSymbol() { | ||
Assertions.assertFalse(validator.isValid("te>st")); | ||
} | ||
|
||
@Test | ||
public void testSmallerSymbol() { | ||
Assertions.assertFalse(validator.isValid("te<st")); | ||
} | ||
|
||
@Test | ||
public void testSlash() { | ||
Assertions.assertFalse(validator.isValid("te/st")); | ||
} | ||
|
||
@Test | ||
public void testEquals() { | ||
Assertions.assertFalse(validator.isValid("te=st")); | ||
} | ||
|
||
@Test | ||
public void testSpecialCharAsExample() { | ||
Assertions.assertTrue(validator.isValid("ÂtestÂ")); | ||
} | ||
} |