use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testCertType.
@Test
public void testCertType() {
String cmdLine = "curl 'http://jmeter.apache.org/' --cert-type 'test'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("cert-type", request.getCaCert(), "With method 'parser',the cacert need to show a warning' ");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testFormWithEmptyHeader.
@Test
public void testFormWithEmptyHeader() {
String cmdLine = "curl 'https://example.invalid' -H 'X-Something;' ";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
List<Pair<String, String>> res = request.getHeaders();
assertTrue(res.contains(Pair.of("X-Something", "")), "With method 'parser', we should post form data: " + request.getFormData());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testDataUrlEncodeWith2AtSymbol.
@Test
public void testDataUrlEncodeWith2AtSymbol() throws IOException {
String encoding = StandardCharsets.UTF_8.name();
FileUtils.writeStringToFile(tempFile, "test@", encoding, true);
String pathname = tempFile.getAbsolutePath();
String cmdLine = "curl 'https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_submit/action_page.php' " + "-H 'cache-control: no-cache' --data-urlencode 'name@" + pathname + "' ";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("name=test%40", request.getPostData(), "With method 'parser',the parameters in the file need to be encoded'");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testDataReadFromNonexistentFile.
@Test
public void testDataReadFromNonexistentFile() {
String cmdLine = "curl 'https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_submit/action_page.php' " + "-H 'cache-control: no-cache' --data '@test.txt' ";
BasicCurlParser basicCurlParser = new BasicCurlParser();
assertThrows(IllegalArgumentException.class, () -> basicCurlParser.parse(cmdLine), "The method 'translateCommandline shouldn't run when the path of file is incorrect");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testFormString.
@Test
public void testFormString() {
String cmdLine = "curl 'https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_submit/action_page.php' " + "-H 'cache-control: no-cache' --form-string 'image=@C:\\Test\\test.jpg' ";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
List<Pair<String, String>> res = request.getFormStringData();
assertTrue(res.contains(Pair.of("image", "@C:\\Test\\test.jpg")), "With method 'parser', we should post form data: " + request.getFormStringData());
}
Aggregations