use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testAuthorization.
@Test
public void testAuthorization() {
String cmdLine = "curl 'http://jmeter.apache.org/' -u 'arun:12345'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("arun", request.getAuthorization().getUser());
assertEquals("12345", request.getAuthorization().getPass());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testAuthorizationMechanismIsDigest.
@Test
public void testAuthorizationMechanismIsDigest() {
String cmdLine = "curl 'http://jmeter.apache.org/' -u 'arun:12345' --digest";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("DIGEST", request.getAuthorization().getMechanism().toString());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testDataBinaryReadFromFile.
@Test
public void testDataBinaryReadFromFile() throws IOException {
String encoding = StandardCharsets.UTF_8.name();
FileUtils.writeStringToFile(tempFile, "name=test" + System.lineSeparator(), 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-binary '@" + pathname + "' ";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("name=test" + System.lineSeparator(), request.getPostData(), "With method 'parser',the parameters need to reserve '\n' and '\r'");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testPost.
@Test
public void testPost() {
String cmdLine = "curl 'https://jmeter.apache.org/test' -X 'POST' " + "-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:63.0) Gecko/20100101 Firefox/63.0' -H 'Accept: */*' " + "-H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: https://www.example.com/' " + "-H 'content-type: application/json;charset=UTF-8' -H 'Origin: https://www.example.com' " + "-H 'DNT: 1' -H 'Connection: keep-alive' -H 'TE: Trailers' " + "--data '{\"abc\":\"123\",\"no\":\"matter on sunshine\"}'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("https://jmeter.apache.org/test", request.getUrl());
assertEquals(8, request.getHeaders().size());
assertTrue(request.isCompressed());
assertEquals("POST", request.getMethod());
assertEquals("{\"abc\":\"123\",\"no\":\"matter on sunshine\"}", request.getPostData(), "The method 'getPostData' should return the data correctly");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testNoSupport.
@Test
public void testNoSupport() {
String cmdLine = "curl 'http://jmeter.apache.org/' -x 'https://aa:bb@example.com:8042' --proxy-ntlm";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertTrue(request.getOptionsNoSupport().contains("proxy-ntlm"), "Option proxy-ntlm should show warning");
}
Aggregations