Skip to content

Commit 0af687f

Browse files
author
TheSnoozer
committed
since the verification for allowed characters in the evaluateOnCommit has been moved to the core module, also move the relevant test
1 parent 57782e5 commit 0af687f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/test/java/pl/project13/core/GitCommitIdPluginIntegrationTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@
3737
import java.nio.file.Path;
3838
import java.text.SimpleDateFormat;
3939
import java.util.*;
40+
import java.util.regex.Pattern;
4041

4142
import static java.util.Arrays.asList;
4243
import static org.assertj.core.api.Assertions.assertThat;
4344
import static org.assertj.core.api.Assertions.entry;
45+
import static org.junit.Assert.assertFalse;
46+
import static org.junit.Assert.assertTrue;
4447

4548
@RunWith(JUnitParamsRunner.class)
4649
public class GitCommitIdPluginIntegrationTest {
@@ -1505,6 +1508,21 @@ public void shouldGeneratePropertiesWithMultiplePrefixesAndReactorProject(boolea
15051508
}
15061509
}
15071510

1511+
@Test
1512+
public void verifyAllowedCharactersForEvaluateOnCommit() {
1513+
Pattern p = GitCommitIdPlugin.allowedCharactersForEvaluateOnCommit;
1514+
assertTrue(p.matcher("5957e419d").matches());
1515+
assertTrue(p.matcher("my_tag").matches());
1516+
assertTrue(p.matcher("my-tag").matches());
1517+
assertTrue(p.matcher("my.tag").matches());
1518+
assertTrue(p.matcher("HEAD^1").matches());
1519+
assertTrue(p.matcher("feature/branch").matches());
1520+
1521+
assertFalse(p.matcher("; CODE INJECTION").matches());
1522+
assertFalse(p.matcher("|exit").matches());
1523+
assertFalse(p.matcher("&&cat /etc/passwd").matches());
1524+
}
1525+
15081526
private GitDescribeConfig createGitDescribeConfig(boolean forceLongFormat, int abbrev) {
15091527
GitDescribeConfig gitDescribeConfig = new GitDescribeConfig();
15101528
gitDescribeConfig.setTags(true);

0 commit comments

Comments
 (0)