use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class ParseCurlCommandActionTest method testCanAddAuthManagerInHttpRequest.
@Test
public void testCanAddAuthManagerInHttpRequest() throws Exception {
ParseCurlCommandAction p = new ParseCurlCommandAction();
AuthManager authManager = new AuthManager();
Authorization authorization = new Authorization();
authorization.setPass("passwd");
authorization.setUser("user");
authorization.setURL("http://jmeter.apache.org/");
authorization.setMechanism(Mechanism.BASIC);
authManager.addAuth(authorization);
BasicCurlParser basicCurlParser = new BasicCurlParser();
Request request = basicCurlParser.parse("curl 'http://jmeter.apache.org/' -u 'user:passwd'");
Method method = getMethodFor("canAddAuthManagerInHttpRequest", Request.class, AuthManager.class);
assertFalse((boolean) method.invoke(p, request, authManager), "When AuthManager contains this authorization, shouldn't add a AuthManager in Http Request");
request = basicCurlParser.parse("curl 'http://jmeter.apache.org/' -u 'user1:passwd1'");
assertTrue((boolean) method.invoke(p, request, authManager), "When AuthManager contains this url, but the username or password isn't the same," + "should add a AuthManager in Http Request");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testDnsServer.
@Test
public void testDnsServer() {
String cmdLine = "curl -X POST \"https://api.imgur.com/3/upload\" " + " -H 'Authorization: Client-ID fb52f2bfa714a36' --dns-servers '0.0.0.0,1.1.1.1'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertTrue(request.getDnsServers().contains("0.0.0.0"), "With method 'parser', the Dns Server 0.0.0.0 should exist");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testBug65270SingleEqualsWithDataUrlEncodeOptions.
@Test
public void testBug65270SingleEqualsWithDataUrlEncodeOptions() {
String cmdLine = String.join(" \\\n", Arrays.asList("curl --location --request POST 'https://example.invalid/access/token'", "--header 'HTTP_X_FORWARDED_FOR: 127.0.0.1'", "--header 'Accept-Language: it-IT'", "--header 'Content-Type: application/x-www-form-urlencoded'", "--data-urlencode '='"));
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("https://example.invalid/access/token", request.getUrl());
assertEquals(3, request.getHeaders().size());
assertEquals("", request.getPostData());
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testDataUrlEncodeMoreThanOneParameters.
@Test
public void testDataUrlEncodeMoreThanOneParameters() {
String cmdLine = "curl -v 'https://postman-echo.com/post' -H 'Content-Type: application/x-www-form-urlencoded'" + " -H 'cache-control: no-cache' --data-urlencode 'foo1=!!!&foo2=???'";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
assertEquals("foo1=%21%21%21%26foo2%3D%3F%3F%3F", request.getPostData(), "With method 'parser',the parameters need to be encoded' ");
}
use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.
the class BasicCurlParserTest method testCookieInHeader.
@Test
public void testCookieInHeader() {
String cmdLine = "curl 'http://jmeter.apache.org/' -H 'cookie: PHPSESSID=testphpsessid;a=b' --compressed";
BasicCurlParser basicCurlParser = new BasicCurlParser();
BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
List<Cookie> cookies = request.getCookieInHeaders("http://jmeter.apache.org/");
Cookie c1 = new Cookie();
c1.setDomain("jmeter.apache.org");
c1.setName("a");
c1.setValue("b");
c1.setPath("/");
assertEquals(c1, cookies.get(0), "Just static cookie in header can be added in CookieManager");
assertEquals(1, cookies.size(), "Just static cookie in header can be added in CookieManager");
}
Aggregations