use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testBug65270DuplicateDataUrlEncodeOptions.
@Test
public void testBug65270DuplicateDataUrlEncodeOptions() {
String cmdLine = String.join(" \\\n", Arrays.asList("curl --location --request POST 'http://example.invalid/access/token'", "--header 'HTTP_X_FORWARDED_FOR: 127.0.0'", "--header 'Accept-Language: it-IT'", "--header 'Content-Type: application/x-www-form-urlencoded'", "--data-urlencode 'client_id=someID'", "--data-urlencode 'client_secret=someSecret'", "--data-urlencode 'grant_type=password'", "--data-urlencode 'username=test'", "--data-urlencode 'password=Password1234'"));
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("http://example.invalid/access/token", request.getUrl());
assertEquals(3, request.getHeaders().size());
assertEquals("client_id=someID&client_secret=someSecret&grant_type=password&username=test&password=Password1234", request.getPostData());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testFormWithQuotedValue.
@Test
public void testFormWithQuotedValue() {
String cmdLine = "curl 'https://www.exaple.invalid/' " + "--form 'test=\"something quoted\"'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
List<Pair<String, ArgumentHolder>> res = request.getFormData();
assertTrue(res.contains(Pair.of("test", StringArgumentHolder.of("something quoted"))), "With method 'form', we should post form data");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testInterface.
@Test
public void testInterface() {
String cmdLine = "curl 'http://jmeter.apache.org/' --interface 'etho'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("etho", request.getInterfaceName());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testCookieFromFile.
@Test
public void testCookieFromFile() throws IOException {
String pathname = tempFile.getAbsolutePath();
String cmdLine = "curl -X POST \"https://api.imgur.com/3/upload\" -b '" + pathname + "'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals(pathname, request.getFilepathCookie(), "With method 'parser', the file of cookie should be uploaded in CookieManager");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testForm.
@Test
public void testForm() {
String cmdLine = "curl 'https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_submit/action_page.php' " + "-H 'cache-control: no-cache' -F 'test=name' -F 'test1=name1' ";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
List<Pair<String, ArgumentHolder>> res = request.getFormData();
assertTrue(res.contains(Pair.of("test1", StringArgumentHolder.of("name1"))), "With method 'parser', we should post form data");
}
Aggregations