use of org.wso2.carbon.apimgt.ballerina.threatprotection.analyzer.JSONAnalyzer in project carbon-apimgt by wso2.
the class JSONAnalyzerTestCase method testMaxArrayElementCountPass.
@Test
public void testMaxArrayElementCountPass() throws Exception {
JSONConfig config = Mockito.mock(JSONConfig.class);
Mockito.when(config.getMaxArrayElementCount()).thenReturn(5);
JSONAnalyzer analyzer = new JSONAnalyzer();
analyzer.configure(config);
String jsonString = "{\"a\": [1, 2, 3, 4, 5]}";
analyzer.analyze(jsonString, "/foo");
}
use of org.wso2.carbon.apimgt.ballerina.threatprotection.analyzer.JSONAnalyzer in project carbon-apimgt by wso2.
the class JSONAnalyzerTestCase method testMaxStringLengthInsideAnArrayFail.
@Test(expectedExceptions = APIMThreatAnalyzerException.class)
public void testMaxStringLengthInsideAnArrayFail() throws Exception {
JSONConfig config = Mockito.mock(JSONConfig.class);
Mockito.when(config.getMaxStringLength()).thenReturn(5);
JSONAnalyzer analyzer = new JSONAnalyzer();
analyzer.configure(config);
String jsonString = "{\"abcdef\": [1, \"123456\", 3, 4, 5, 6]}";
analyzer.analyze(jsonString, "/foo");
}
use of org.wso2.carbon.apimgt.ballerina.threatprotection.analyzer.JSONAnalyzer in project carbon-apimgt by wso2.
the class JSONAnalyzerTestCase method testConfigureAnalyzerException.
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testConfigureAnalyzerException() throws Exception {
JSONAnalyzer analyzer = new JSONAnalyzer();
XMLConfig config = new XMLConfig();
analyzer.configure(config);
}
use of org.wso2.carbon.apimgt.ballerina.threatprotection.analyzer.JSONAnalyzer in project carbon-apimgt by wso2.
the class JSONAnalyzerTestCase method testMaxFieldLengthPass.
@Test
public void testMaxFieldLengthPass() throws Exception {
JSONConfig config = Mockito.mock(JSONConfig.class);
Mockito.when(config.getMaxKeyLength()).thenReturn(5);
JSONAnalyzer analyzer = new JSONAnalyzer();
analyzer.configure(config);
String jsonString = "{\"abcde\": [1, 2, 3, 4, 5]}";
analyzer.analyze(jsonString, "/foo");
}
use of org.wso2.carbon.apimgt.ballerina.threatprotection.analyzer.JSONAnalyzer in project carbon-apimgt by wso2.
the class JSONAnalyzerTestCase method testMaxArrayElementCountFail.
@Test(expectedExceptions = APIMThreatAnalyzerException.class)
public void testMaxArrayElementCountFail() throws Exception {
JSONConfig config = Mockito.mock(JSONConfig.class);
Mockito.when(config.getMaxArrayElementCount()).thenReturn(5);
JSONAnalyzer analyzer = new JSONAnalyzer();
analyzer.configure(config);
String jsonString = "{\"a\": [1, 2, 3, 4, 5, 6]}";
analyzer.analyze(jsonString, "/foo");
}
Aggregations