benams
benams

Reputation: 4646

create a JMeter https request with credentials (username and password)

I want to create an https request to a server that requires username and password. Where can I provide the credentials? I couldn't find this option in the jmeter UI

Upvotes: 2

Views: 32546

Answers (3)

Gryu
Gryu

Reputation: 2189

HTTP Request based Authentication

  • Get your credentials names using Developer tools -> Network tab -> Your POST Request -> Headers tab -> Form Data section.

    dev tools, network, headers

  • Create a Test Plan with some name and some elements test plan elements addition

  • HTTP Request Defaults http request defaults
  • Empty HTTP Cookie Manager http cookie manager
  • Login HTTP Request with credentials specified enter image description here
  • Required HTTP Request enter image description here
  • View Results Tree listener enter image description here

Testing:
During Login Page passing jmeter gets a Cookie:
enter image description here

During a real request, jmeter uses the Cookie which have been set during Login Page passing:
enter image description here

Also, make sure you have CookieManager.save.cookies=true in your jmeter user.properties file. I've already done it earlier.

$ cat ~/.local/share/jmeter/bin/user.properties | grep Cookie
CookieManager.save.cookies=true

After file modification restart your jmeter.

Upvotes: 0

Somaiah Kumbera
Somaiah Kumbera

Reputation: 7489

To set up jmeter to access an https url:

Create an HTTP Request Defaults with your server name.

Set implementation to httpClient3.1 (it didnt work for me otherwise) Set protocol to https

Create an HTTP Request for the login

I used spring security, so I set path to /j_spring_security_check

Set method to post

In the parameters section, add the params you need to log in in the section called Send Parameters with the request. In my case I had to send a username and password param exactly as its defined in my login form.

Finally add a Response assertion to search for a text response. Here I checked for the full display name of the logged in person, since that shows up in the response.

If you want to save the cookie you might also want to create an HTTP Cookie Manager for the thread group

I followed this doc: http://jmeter.apache.org/usermanual/build-web-test-plan.html

Upvotes: 4

UBIK LOAD PACK
UBIK LOAD PACK

Reputation: 34516

It depends on authentication policy, if it's Basic Auth then it would be done through an Http Authorization Manager If it's form based, then passing them as parameters in Http Request will do it.

If you don't know your option is to record through browser and JMeter Proxy Server:

Upvotes: 0

Related Questions