Search in sources :

Example 76 with BasicCurlParser

use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.

the class BasicCurlParserTest method testCacert.

@Test
public void testCacert() {
    String cmdLine = "curl 'http://jmeter.apache.org/' --cacert 'test.pem' ";
    BasicCurlParser basicCurlParser = new BasicCurlParser();
    BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
    assertEquals("cacert", request.getCaCert(), "With method 'parser',the cacert need to show a warning' ");
}
Also used : BasicCurlParser(org.apache.jmeter.protocol.http.curl.BasicCurlParser) Test(org.junit.jupiter.api.Test)

Example 77 with BasicCurlParser

use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.

the class BasicCurlParserTest method testHead.

@Test
public void testHead() {
    String cmdLine = "curl 'http://jmeter.apache.org/' --head";
    BasicCurlParser basicCurlParser = new BasicCurlParser();
    BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
    assertEquals("HEAD", request.getMethod());
}
Also used : BasicCurlParser(org.apache.jmeter.protocol.http.curl.BasicCurlParser) Test(org.junit.jupiter.api.Test)

Example 78 with BasicCurlParser

use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.

the class BasicCurlParserTest method testError.

@Test
public void testError() {
    String cmdLine = "curl 'https://jmeter.apache.org/' --error -H 'Proxy-Connection: keep-alive' " + "-H 'Proxy-Authorization: Basic XXXXXXXXX/' " + "-H 'User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/70.0.3538.102 Mobile Safari/537.36' " + "-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' " + "-H 'Accept-Encoding: gzip, deflate' " + "-H 'Accept-Language: en-US,en;q=0.9,fr;q=0.8'";
    BasicCurlParser basicCurlParser = new BasicCurlParser();
    assertThrows(IllegalArgumentException.class, () -> basicCurlParser.parse(cmdLine));
}
Also used : BasicCurlParser(org.apache.jmeter.protocol.http.curl.BasicCurlParser) Test(org.junit.jupiter.api.Test)

Example 79 with BasicCurlParser

use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.

the class BasicCurlParserTest method testChromeParsing.

@Test
public void testChromeParsing() {
    String cmdLine = "curl 'https://jmeter.apache.org/' -H 'Proxy-Connection: keep-alive' " + "-H 'Proxy-Authorization: Basic XXXXXXXXX/' -H 'Upgrade-Insecure-Requests: 1' " + "-H 'User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/70.0.3538.102 Mobile Safari/537.36' " + "-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' " + "-H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9,fr;q=0.8' --compressed";
    BasicCurlParser basicCurlParser = new BasicCurlParser();
    BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
    assertEquals("https://jmeter.apache.org/", request.getUrl());
    assertEquals(7, request.getHeaders().size());
    assertTrue(request.isCompressed());
}
Also used : BasicCurlParser(org.apache.jmeter.protocol.http.curl.BasicCurlParser) Test(org.junit.jupiter.api.Test)

Example 80 with BasicCurlParser

use of org.apache.jmeter.protocol.http.curl.BasicCurlParser in project jmeter by apache.

the class BasicCurlParserTest method testDefaultAuthMechanism.

@Test
public void testDefaultAuthMechanism() {
    String cmdLine = "curl 'http://jmeter.apache.org/' -u 'arun:12345'";
    BasicCurlParser basicCurlParser = new BasicCurlParser();
    BasicCurlParser.Request request = basicCurlParser.parse(cmdLine);
    assertEquals("BASIC", request.getAuthorization().getMechanism().toString());
}
Also used : BasicCurlParser(org.apache.jmeter.protocol.http.curl.BasicCurlParser) Test(org.junit.jupiter.api.Test)

Aggregations

BasicCurlParser (org.apache.jmeter.protocol.http.curl.BasicCurlParser)84 Test (org.junit.jupiter.api.Test)81 Request (org.apache.jmeter.protocol.http.curl.BasicCurlParser.Request)20 ParseCurlCommandAction (org.apache.jmeter.protocol.http.gui.action.ParseCurlCommandAction)19 Method (java.lang.reflect.Method)16 Pair (org.apache.commons.lang3.tuple.Pair)8 HTTPSamplerProxy (org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy)6 DNSCacheManager (org.apache.jmeter.protocol.http.control.DNSCacheManager)4 AuthManager (org.apache.jmeter.protocol.http.control.AuthManager)3 HttpTestSampleGui (org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Authorization (org.apache.jmeter.protocol.http.control.Authorization)2 Cookie (org.apache.jmeter.protocol.http.control.Cookie)2 CookieManager (org.apache.jmeter.protocol.http.control.CookieManager)2 TestPlan (org.apache.jmeter.testelement.TestPlan)2 ThreadGroup (org.apache.jmeter.threads.ThreadGroup)2 HashTree (org.apache.jorphan.collections.HashTree)2 Field (java.lang.reflect.Field)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1