-
Notifications
You must be signed in to change notification settings - Fork 92
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 #78 from nahsra/1.6.2
1.6.2
- Loading branch information
Showing
9 changed files
with
397 additions
and
22 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
63 changes: 63 additions & 0 deletions
63
src/test/java/org/owasp/validator/html/test/AntiSamyMalformedPolicyTest.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,63 @@ | ||
package org.owasp.validator.html.test; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
import java.io.InputStream; | ||
|
||
import org.junit.Test; | ||
import org.owasp.validator.html.Policy; | ||
import org.owasp.validator.html.PolicyException; | ||
|
||
/** | ||
* @author Gerardo Canedo | ||
*/ | ||
public class AntiSamyMalformedPolicyTest { | ||
|
||
@Test | ||
public void testDirectConfigMalformedValidationOn() throws Exception { | ||
Policy.setSchemaValidation(false); | ||
InputStream stream = AntiSamyMalformedPolicyTest.class.getResourceAsStream("/invalidPolicyMalformedXml.xml"); | ||
try { | ||
Policy.getInstance(stream); | ||
fail("For Malformed XML, PolicyException expected whether schema validation is enabled or not."); | ||
} catch (PolicyException e) { | ||
// This is expected, so do nothing. Any other kind of exception is a failed test case. | ||
} | ||
} | ||
|
||
@Test | ||
public void testDirectConfigMalformedValidationOff() throws Exception { | ||
Policy.setSchemaValidation(true); | ||
InputStream stream = AntiSamyMalformedPolicyTest.class.getResourceAsStream("/invalidPolicyMalformedXml.xml"); | ||
try { | ||
Policy.getInstance(stream); | ||
fail("For Malformed XML, PolicyException expected whether schema validation is enabled or not."); | ||
} catch (PolicyException e) { | ||
// This is expected, so do nothing. Any other kind of exception is a failed test case. | ||
} | ||
} | ||
|
||
@Test | ||
public void testDirectConfigAsBaisMalformedValidationOn() throws Exception { | ||
Policy.setSchemaValidation(true); | ||
InputStream stream = ESAPIInvalidPolicyTest.class.getResourceAsStream("/invalidPolicyMalformedXml.xml"); | ||
try { | ||
Policy.getInstance(ESAPIInvalidPolicyTest.toByteArrayStream(stream)); | ||
fail("For Malformed XML, PolicyException expected whether schema validation is enabled or not."); | ||
} catch (PolicyException e) { | ||
// This is expected, so do nothing. Any other kind of exception is a failed test case. | ||
} | ||
} | ||
|
||
@Test | ||
public void testDirectConfigAsBaisMalformedValidationOff() throws Exception { | ||
Policy.setSchemaValidation(false); | ||
InputStream stream = ESAPIInvalidPolicyTest.class.getResourceAsStream("/invalidPolicyMalformedXml.xml"); | ||
try { | ||
Policy.getInstance(ESAPIInvalidPolicyTest.toByteArrayStream(stream)); | ||
fail("For Malformed XML, PolicyException expected whether schema validation is enabled or not."); | ||
} catch (PolicyException e) { | ||
// This is expected, so do nothing. Any other kind of exception is a failed test case. | ||
} | ||
} | ||
} |
Oops, something went wrong.