Open asfimport opened 3 years ago
@FSchumacher (migrated from Bugzilla): @Nikola could you test next trunk or nightly build? The first two problems should be addressed (even if I don't know, whether you wanted an empty post for the second issue).
The third issue is a bit more work and probably deserves its own issue. The request should work, though. The post data is filled, but the wrong tab is shown (one could argue :) ).
commit 5f5b8166402fbe66ba2aadc51ccdc284d9c8c030 AuthorDate: Tue Apr 27 20:57:27 2021 +0200
POST application/x-www-form-urlencoded cURL code generated from Postman is not imported correctly
Allow multiple occurrences of --data-urlencode options and empty key and value on that option.
The data will be added as post data and not as form data, which is a bit inconvenient and asked for
in the same issue entry.
https://github.com/apache/jmeter/issues/5526
.../jmeter/protocol/http/curl/BasicCurlParser.java | 5 +++- .../apache/jmeter/curl/BasicCurlParserTest.java | 34 ++++++++++++++++++++++ xdocs/changes.xml | 1 + 3 files changed, 39 insertions(+), 1 deletion(-)
eR@SeR (migrated from Bugzilla): Hi,
The first two issues are resolved. The third one is opened here https://github.com/apache/jmeter/issues/5528 with one more example that doesn't behave as expected.
By fixing first two, now there is one more where blank data-urlencode is among others who are not blank:
curl --location --request POST 'http://example.com/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 'client_id=someID' \ --data-urlencode '=' \ --data-urlencode 'client_secret=someSecret' \ --data-urlencode 'grant_type=password' \ --data-urlencode 'username=test' \ --data-urlencode 'password=Password1234'
HTTP Sampler's data is successfully generated but value "client_id=someID&&ata-urlencode&grant_type=password&username=test&password=Password1234" is wrong.
Correct one should be "client_id=someID&&client_secret=someSecret&grant_type=password&username=test&password=Password1234"
Jmeter 5.5 5f5b816 Microsoft Windows 10 Enterprise 64-bit java version "15.0.1" 2020-10-20
@FSchumacher (migrated from Bugzilla): The last comment is really another problem with our choice of the CLI parser. It can't see the single "=" and gets confused by it.
@all we should look into changing the CLI parser, as this is the second time we stumble about some quirks with unexpected data, like an empty string or in this case a single equals sign. That would probably be better tracked in its own issue.
eR@SeR (Bug 65270): Hello,
When POST application/x-www-form-urlencoded request is opened in Code/cURL mode in Postman, then entire lines copied and pasted into "Import from cURL" in JMeter, HTTP Sampler is not generated:
cURL example - more than one --data-urlencode:
curl --location --request POST 'http://example.com/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 'client_id=someID' \ --data-urlencode 'client_secret=someSecret' \ --data-urlencode 'grant_type=password' \ --data-urlencode 'username=test' \ --data-urlencode 'password=Password1234'
Error:
ERROR o.a.j.p.h.g.a.ParseCurlCommandAction: Error creating test plan from cURL command:curl --location --request POST 'http://example.com/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', error:Unexpected format for command line:curl --location --request POST 'http://example.com/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', error:Duplicate options for -맢/--data-urlencode found. java.lang.IllegalArgumentException: Unexpected format for command line:curl --location --request POST 'http://example.com/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', error:Duplicate options for -맢/--data-urlencode found. at org.apache.jmeter.protocol.http.curl.BasicCurlParser.parse(BasicCurlParser.java:820) ~[ApacheJMeter_http.jar:5.5-SNAPSHOT] at org.apache.jmeter.protocol.http.gui.action.ParseCurlCommandAction.parseCommands(ParseCurlCommandAction.java:685) ~[ApacheJMeter_http.jar:5.5-SNAPSHOT] at org.apache.jmeter.protocol.http.gui.action.ParseCurlCommandAction.actionPerformed(ParseCurlCommandAction.java:634) ~[ApacheJMeter_http.jar:5.5-SNAPSHOT] at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967) ~[?:?] at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308) ~[?:?] at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) ~[?:?] at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) ~[?:?] at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279) ~[?:?] at java.awt.Component.processMouseEvent(Component.java:6614) ~[?:?] at javax.swing.JComponent.processMouseEvent(JComponent.java:3342) ~[?:?] at java.awt.Component.processEvent(Component.java:6379) ~[?:?] at java.awt.Container.processEvent(Container.java:2263) ~[?:?] at java.awt.Component.dispatchEventImpl(Component.java:4990) ~[?:?] at java.awt.Container.dispatchEventImpl(Container.java:2321) ~[?:?] at java.awt.Component.dispatchEvent(Component.java:4822) ~[?:?] at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4919) ~[?:?] at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4548) ~[?:?] at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4489) ~[?:?] at java.awt.Container.dispatchEventImpl(Container.java:2307) ~[?:?] at java.awt.Window.dispatchEventImpl(Window.java:2769) ~[?:?] at java.awt.Component.dispatchEvent(Component.java:4822) ~[?:?] at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772) ~[?:?] at java.awt.EventQueue$4.run(EventQueue.java:721) ~[?:?] at java.awt.EventQueue$4.run(EventQueue.java:715) ~[?:?] at java.security.AccessController.doPrivileged(AccessController.java:391) [?:?] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) ~[?:?] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) ~[?:?] at java.awt.EventQueue$5.run(EventQueue.java:745) ~[?:?] at java.awt.EventQueue$5.run(EventQueue.java:743) ~[?:?] at java.security.AccessController.doPrivileged(AccessController.java:391) [?:?] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) [?:?] at java.awt.EventQueue.dispatchEvent(EventQueue.java:742) [?:?] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) [?:?] at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) [?:?] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) [?:?] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) [?:?] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:?] at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) [?:?] ERROR o.a.j.p.h.g.a.ParseCurlCommandAction: Error creating test plan from cURL command list:[curl --location --request POST 'http://example.com/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'] java.lang.IllegalArgumentException: Unexpected format for command line:curl --location --request POST 'http://example.com/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', error:Duplicate options for -맢/--data-urlencode found. at org.apache.jmeter.protocol.http.curl.BasicCurlParser.parse(BasicCurlParser.java:820) ~[ApacheJMeter_http.jar:5.5-SNAPSHOT] at org.apache.jmeter.protocol.http.gui.action.ParseCurlCommandAction.parseCommands(ParseCurlCommandAction.java:685) ~[ApacheJMeter_http.jar:5.5-SNAPSHOT] at org.apache.jmeter.protocol.http.gui.action.ParseCurlCommandAction.actionPerformed(ParseCurlCommandAction.java:634) ~[ApacheJMeter_http.jar:5.5-SNAPSHOT] at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967) ~[?:?] at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308) ~[?:?] at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) ~[?:?] at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) ~[?:?] at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279) ~[?:?] at java.awt.Component.processMouseEvent(Component.java:6614) ~[?:?] at javax.swing.JComponent.processMouseEvent(JComponent.java:3342) ~[?:?] at java.awt.Component.processEvent(Component.java:6379) ~[?:?] at java.awt.Container.processEvent(Container.java:2263) ~[?:?] at java.awt.Component.dispatchEventImpl(Component.java:4990) ~[?:?] at java.awt.Container.dispatchEventImpl(Container.java:2321) ~[?:?] at java.awt.Component.dispatchEvent(Component.java:4822) ~[?:?] at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4919) ~[?:?] at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4548) ~[?:?] at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4489) ~[?:?] at java.awt.Container.dispatchEventImpl(Container.java:2307) ~[?:?] at java.awt.Window.dispatchEventImpl(Window.java:2769) ~[?:?] at java.awt.Component.dispatchEvent(Component.java:4822) ~[?:?] at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772) ~[?:?] at java.awt.EventQueue$4.run(EventQueue.java:721) ~[?:?] at java.awt.EventQueue$4.run(EventQueue.java:715) ~[?:?] at java.security.AccessController.doPrivileged(AccessController.java:391) [?:?] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) ~[?:?] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) ~[?:?] at java.awt.EventQueue$5.run(EventQueue.java:745) ~[?:?] at java.awt.EventQueue$5.run(EventQueue.java:743) ~[?:?] at java.security.AccessController.doPrivileged(AccessController.java:391) [?:?] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) [?:?] at java.awt.EventQueue.dispatchEvent(EventQueue.java:742) [?:?] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) [?:?] at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) [?:?] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) [?:?] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) [?:?] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:?] at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) [?:?]
It seems that it cannot generate more than 1 --data-urlencode parameter. When one is provided then HTTP Sampler is successfully generated.
cURL example - blank parameter and value in "--data-urlencode" (if parameter name and value are blank but left checked accidentally in Postman):
curl --location --request POST 'http://example.com/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 '='
Error:
ERROR o.a.j.p.h.g.a.ParseCurlCommandAction: Error creating test plan from cURL command list:[curl --location --request POST 'http://example.com/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 '='] java.lang.NullPointerException: Cannot invoke "String.trim()" because "value" is null at org.apache.jmeter.protocol.http.curl.BasicCurlParser.parse(BasicCurlParser.java:721) ~[ApacheJMeter_http.jar:5.5-SNAPSHOT] at org.apache.jmeter.protocol.http.gui.action.ParseCurlCommandAction.parseCommands(ParseCurlCommandAction.java:685) ~[ApacheJMeter_http.jar:5.5-SNAPSHOT] at org.apache.jmeter.protocol.http.gui.action.ParseCurlCommandAction.actionPerformed(ParseCurlCommandAction.java:634) ~[ApacheJMeter_http.jar:5.5-SNAPSHOT] at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967) ~[?:?] at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308) ~[?:?] at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) ~[?:?] at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) ~[?:?] at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279) ~[?:?] at java.awt.Component.processMouseEvent(Component.java:6614) ~[?:?] at javax.swing.JComponent.processMouseEvent(JComponent.java:3342) ~[?:?] at java.awt.Component.processEvent(Component.java:6379) ~[?:?] at java.awt.Container.processEvent(Container.java:2263) ~[?:?] at java.awt.Component.dispatchEventImpl(Component.java:4990) ~[?:?] at java.awt.Container.dispatchEventImpl(Container.java:2321) ~[?:?] at java.awt.Component.dispatchEvent(Component.java:4822) ~[?:?] at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4919) ~[?:?] at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4548) ~[?:?] at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4489) ~[?:?] at java.awt.Container.dispatchEventImpl(Container.java:2307) ~[?:?] at java.awt.Window.dispatchEventImpl(Window.java:2769) ~[?:?] at java.awt.Component.dispatchEvent(Component.java:4822) ~[?:?] at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772) ~[?:?] at java.awt.EventQueue$4.run(EventQueue.java:721) ~[?:?] at java.awt.EventQueue$4.run(EventQueue.java:715) ~[?:?] at java.security.AccessController.doPrivileged(AccessController.java:391) [?:?] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) ~[?:?] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) ~[?:?] at java.awt.EventQueue$5.run(EventQueue.java:745) ~[?:?] at java.awt.EventQueue$5.run(EventQueue.java:743) ~[?:?] at java.security.AccessController.doPrivileged(AccessController.java:391) [?:?] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) [?:?] at java.awt.EventQueue.dispatchEvent(EventQueue.java:742) [?:?] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) [?:?] at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) [?:?] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) [?:?] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) [?:?] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:?] at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) [?:?]
cURL example - one "--data-urlencode" parameter:
curl --location --request POST 'http://example.com/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 'username=test'
HTTP Sampler is successfully created. However, parameter name and value are generated inside the Value column like "username=test", instead of being properly put to Name and Value columns inside the Parameters tab. Check the attached image.
Jmeter 5.5 08c3c59 Microsoft Windows 10 Enterprise 64-bit java version "15.0.1" 2020-10-20
Created attachment generated%20cURL.jpg: generated cURL
Version: Nightly Severity: normal OS: All