-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SECURITY-3226][SECURITY-3239][SECURITY-3244]
- Loading branch information
1 parent
02ae0a4
commit a261229
Showing
5 changed files
with
114 additions
and
1 deletion.
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
42 changes: 42 additions & 0 deletions
42
src/test/java/com/sonyericsson/jenkins/plugins/bfa/IndicationAnnotatorTest.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,42 @@ | ||
package com.sonyericsson.jenkins.plugins.bfa; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import com.sonyericsson.jenkins.plugins.bfa.model.FailureCause; | ||
import com.sonyericsson.jenkins.plugins.bfa.model.FoundFailureCause; | ||
import com.sonyericsson.jenkins.plugins.bfa.model.indication.FoundIndication; | ||
import hudson.MarkupText; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.Issue; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Tests for the IndicationAnnotator. | ||
* | ||
* @author Tomas Westling <tomas.westling@axis.com> | ||
*/ | ||
public class IndicationAnnotatorTest { | ||
|
||
private static final String EXPECTED_ANNOTATED_TEXT = "tilt" onmouseover=alert(1) foo="bar"; | ||
|
||
/** | ||
* Tests that html is escaped correctly when annotating text. | ||
*/ | ||
@Issue("SECURITY-3244") | ||
@Test | ||
public void testAnnotate() { | ||
MarkupText text = new MarkupText("matchingString"); | ||
FoundIndication fi = new FoundIndication( | ||
"pattern", "matchingFile", "matchingString"); | ||
List<FoundIndication> fis = new ArrayList<>(); | ||
fis.add(fi); | ||
FoundFailureCause ffc = new FoundFailureCause( | ||
new FailureCause("tilt\" onmouseover=alert(1) foo=\"bar", "description"), fis); | ||
List<FoundFailureCause> foundFailureCauses = new ArrayList<>(); | ||
foundFailureCauses.add(ffc); | ||
IndicationAnnotator ia = new IndicationAnnotator(foundFailureCauses); | ||
ia.annotate(null, text); | ||
assertTrue(text.toString(false).indexOf(EXPECTED_ANNOTATED_TEXT) != -1); | ||
} | ||
} |