|
| 1 | +package org.owasp.esapi; |
| 2 | + |
| 3 | +import org.junit.Assert; |
| 4 | +import org.junit.Test; |
| 5 | + |
| 6 | + |
| 7 | +public class ESAPIVerifyAllowedMethods { |
| 8 | + |
| 9 | + @Test (expected = IllegalArgumentException.class) |
| 10 | + public void verifyNulParamThrows() { |
| 11 | + ESAPI.isMethodExplicityEnabled(null); |
| 12 | + } |
| 13 | + |
| 14 | + @Test (expected = IllegalArgumentException.class) |
| 15 | + public void verifyEmptyNoWhitespaceParameterThrows() { |
| 16 | + ESAPI.isMethodExplicityEnabled(""); |
| 17 | + } |
| 18 | + |
| 19 | + @Test (expected = IllegalArgumentException.class) |
| 20 | + public void verifyEmptyOnlyWhitespaceParameterThrows() { |
| 21 | + ESAPI.isMethodExplicityEnabled(" "); |
| 22 | + } |
| 23 | + |
| 24 | + @Test (expected = IllegalArgumentException.class) |
| 25 | + public void verifyEmptyOnlyTabWhitespaceParameterThrows() { |
| 26 | + ESAPI.isMethodExplicityEnabled("\t"); |
| 27 | + } |
| 28 | + |
| 29 | + @Test (expected = IllegalArgumentException.class) |
| 30 | + public void verifyEmptyOnlyNewlineWhitespaceParameterThrows() { |
| 31 | + ESAPI.isMethodExplicityEnabled("\n"); |
| 32 | + } |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + @Test (expected = IllegalArgumentException.class) |
| 37 | + public void verifyNonEsapiPackageParameterThrows() { |
| 38 | + ESAPI.isMethodExplicityEnabled("com.myPackage.myScope.method"); |
| 39 | + } |
| 40 | + @Test |
| 41 | + public void verifyUnknownMethodFailsEnableCheck() { |
| 42 | + Assert.assertFalse(ESAPI.isMethodExplicityEnabled("org.owasp.esapi.reference.DefaultEncoder.encodeForSQ")); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void verifyDefinedRestrictionIsCaught() { |
| 47 | + Assert.assertTrue(ESAPI.isMethodExplicityEnabled("org.owasp.esapi.reference.DefaultEncoder.encodeForSQL")); |
| 48 | + } |
| 49 | + |
| 50 | +} |
0 commit comments