Skip to content

Commit 2474d44

Browse files
Test Coverage
using the SecurityConfigurationWrapper to verify remaining test case when a ConfigurationException is thrown when the new property is missing or undefined.
1 parent 717d9f1 commit 2474d44

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/test/java/org/owasp/esapi/ESAPIVerifyAllowedMethods.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.owasp.esapi;
22

3+
import org.bouncycastle.crypto.modes.CBCModeCipher;
34
import org.junit.Assert;
45
import org.junit.Test;
6+
import org.mockito.Mockito;
7+
import org.owasp.esapi.errors.ConfigurationException;
58

69

710
public class ESAPIVerifyAllowedMethods {
@@ -47,4 +50,19 @@ public void verifyDefinedRestrictionIsCaught() {
4750
Assert.assertTrue(ESAPI.isMethodExplicityEnabled("org.owasp.esapi.reference.DefaultEncoder.encodeForSQL"));
4851
}
4952

53+
@Test
54+
public void testMissingPropertyReturnsFalse() {
55+
try {
56+
SecurityConfiguration mockConfig = Mockito.mock(SecurityConfiguration.class);
57+
Mockito.when(mockConfig.getStringProp("ESAPI.dangerouslyAllowUnsafeMethods.methodNames")).thenThrow(ConfigurationException.class);
58+
ESAPI.override(mockConfig);
59+
60+
Assert.assertFalse(ESAPI.isMethodExplicityEnabled("org.owasp.esapi.thisValueDoesNotMatter"));
61+
Mockito.verify(mockConfig, Mockito.times(1)).getStringProp("ESAPI.dangerouslyAllowUnsafeMethods.methodNames");
62+
} finally {
63+
ESAPI.override(null);
64+
}
65+
66+
}
67+
5068
}

0 commit comments

Comments
 (0)