Sunday, March 14, 2010

Tip #10: How to add authentication to Test Plan

Most of websites have user communities and allow users to do some actions like posting comments if they are authenticated on this website. Often the performance of a web page can be quite different depending on that fact if this page was visited by authenticated user or anonymous one. So we need to test theese pages by both anonymous users and authenticated ones. How to add authentication is described below.

The steps are mostly similar to the steps of adding website search but have some small differencies.

First record HTTP/HTTPS requests going to authentication page with login/password form in your browser and submitting this form. You will get Authentication Form Page and Authentication Process transactions. Then you need to replace login and password parameters values by some variables like ${USER} and ${PASSWORD} on Authentication Process HTTP request settings.



After that you need to prepare the text file where each line contains username and password separated by some delimiter character, e.g., comma and add new CSV Data Set Config element like below.


And now all next HTTP requests will be performed by authenticated users.

34 comments:

  1. Hi Victor,

    I have a query regarding jMeter tool.
    -> How can i get to know the total number of requests sent by jMeter to my server. Where will be the count residing and if there is any drop in the requests received at server end, can i analyze it and get to know the issue?

    ReplyDelete
    Replies
    1. You can add custom User-Agent header to your HTTP requests in JMeter and then grep your server logs and count the number of lines. Also if you save testing results to xml or csv file (using Simple Data Writer) you can grep them too. And finally if you run JMeter in GUI mode you can see the number of requests done in some listeners like Graph Results, Aggregate Report, etc. (look at http://jmeter.apache.org/usermanual/component_reference.html#listeners)

      Delete
  2. Hi Victor,
    I want to check my account section of our web application.To do this login is necessary.If I have username and password then how do i check login process of 100 users at same time.Please help me.Its urgent for me.

    ReplyDelete
    Replies
    1. Just set the number of threads to 100 in your Thread Group and you will have 100 simultaneous threads (users).

      Delete
  3. Hi Victor,
    Thanks for your response.I want to check inner pages like my account, profile..etc.I know load testing for external pages.But I would like to check the features like if 100 users are viewing my account section at the same time then what is the status of average response time.For eg:if 1000 users are logged into gmail at the same time and viewing inbox,like that,Can you please explain it????

    ReplyDelete
    Replies
    1. The testing of internal pages (user pages) is almost the same as the testing of external pages (visitor pages). The difference is that you should:
      a) add 'sign in' samples;
      b) add regexp/xpath postprocessors and 'if' controllers to ensure that the user is signed in;
      c) turn on cookies (add cookies manager).
      There is enough in general and all these things were covered in this blog.

      Delete
  4. Hi Victor
    Thanks for your answer.Can I user proxy recording for authentication and inner page load testing.I think this blog does not provide a solution for my question.I checked all posts of this blog.But Still I am struggling with my question.Suppose I want to check average load time of inbox of yahoo mail which may access 1000 users simultaneously ,how do I check it?It would be great if you could provide me a solution.

    ReplyDelete
    Replies
    1. Of course, you can use recording proxy for it.

      Delete
  5. hi victor
    i have checked login pages with proxy recording.But I gets 'Response code: 302' in 'sampler result.Do you have any idea why it happens?

    ReplyDelete
    Replies
    1. HTTP 302 response code means that your browser will be redirected to another URI specified in response headers (Location). Usually this happens after 'sign in' form posted on server.

      Delete
    2. That means browser successfully logged in to the website and jmeter recorded those actions correctly, right?

      Delete
    3. No, this means only that your browser will be redirected after the login/password verification. You can try View Results Tree listener to see the response body and check if the 'sign in' process was successful.

      Delete
    4. Response data in sampler was not contained any details after load testing of internal pages.So I think jmeter is not done load testing of internal pages.Then how do I get internal pages??, I tried it with proxy recording.At the time of proxy recording it was successfully recorded all process.But load testing of internal pages still failed.Can you help me?

      Delete
    5. Please upload your jmx file somewhere and provide me with URL.

      Delete
    6. Hi victor .The url of uploaded file is given below pls check and let me know the details.
      http://www.box.com/s/pgefzfqlz5qlx0zfe7il

      Delete
    7. Maneesh, the test plan you give me is totally incorrect. First, you must locate all your samplers inside Thread Group. Second, HTTP Request Defaults does not make HTTP requests. It's just default settings and you need use HTTP Request Sampler with it or instead of it.
      So, I moved you contactaway node to Thread Group, then added empty HTTP Request sampler to Thread Group and finally added View Results Tree listener to the Test Plan. After I run the test plan I saw HTTP 200 requests in View Results Tree listener.

      Delete
    8. Ok thanks Victor,Did you check login feature using proxy recorder ?.Please login to contactaway username:maneesh_pn@interberry.com/maneesh , and check my account feature with 10 users at same time.It works fine with simple http requests but not working for authentication.please verify it

      Delete
    9. The URL you provided (http://interberry.com/maneesh) redirects my browser to the home page. Seems you missed something.

      Delete
  6. Sorry Victor the url is http://contactaway.com/
    username and password is maneesh_pn@interberry.com/maneesh.Please try login process using proxy recorder and run a load test with 10 users and please let me know the flow if you gets result.

    ReplyDelete
    Replies
    1. I've created a test plan, you can use it as base for futher extending - http://dl.dropbox.com/u/36265375/maneesh.jmx
      Enjoy!

      Delete
    2. Hi Victor,
      Thanks you so much for your valuable support.I will come back when I need you help.

      Delete
  7. Hi Victor
    I have received jmx file you provided for me.i have one doubt on some fields.In that I saw 'http header manager' which contains some values like 'content type,accept-language ..etc.Actually from where you gets these values,I couldn't understand.I am not technically fit.Can you please explain how can I add it ?

    ReplyDelete
    Replies
    1. It is created by recording proxy server automatically.

      Delete
  8. Hi Victor,
    I am back with some doubts. Recently you have provided me one JMX file named maneesh.jmx.I tried load testing of internal page using that file.It works fine.So I tried to create such type of file using proxy,nothing recorded on cookie manager and HTTP header manager.Can you please explain the work flow you created for recording internal pages using proxy recording feature to check internal pages

    ReplyDelete
    Replies
    1. Maneesh, I've just added Recording Proxy Server and Recording Controller to the Workbench, specified the Recording Controller as a target in Proxy Server settings and started the Proxy Server. Then I've done all the job in browser and moved all recorded samples from the Recording Controller to the Thread Group in Test plan. Also I've added Cookie manager manually. That's all I've done.

      Delete
    2. okay,How can I add cookie manually?What is the use of it.On what basis we can add cookies?please explain those.I am not getting any idea on those

      Delete
    3. If you add Cookie Manager (Add -> Config Element -> HTTP Cookie Manager) JMeter will handle cookies operations itself like browser. Also here you can define your own cookies which will be added to each HTTP request during the testing.

      Delete
    4. Ok thanks for your reply.In thread group we can see that there is an option called scheduler which can help us to set a time to run a specific test.I added only 2s for one test and added 'number of threads as 100 users ,ramp up period as 0 sec.However we know that the test cannot be processed properly with in 2seconds for 100 users.Do you have any idea?Or can you say how can I schedule a particular test which should perform in a specific time?

      Delete
  9. I think it's better to use cron for test scheduling. And as for the duration of test please read my post: http://jmeter-tips.blogspot.com/2010/02/tip-5-how-to-run-test-plan-for-certain.html

    ReplyDelete
    Replies
    1. Hi victor
      As per the test plan in http://jmeter-tips.blogspot.com/2010/02/tip-5-how-to-run-test-plan-for-certain.html I have specified a test duration time 1000 in 'duration' field and added '0' in 'startup delay with a thread group of 20 users.I executed the test.But it does not fail even though it does not complete the test in 1 seconds.So how can I get a failre result?.My aim was to make it as a failure by entering 20 requests simultaneously .Can you please reply?

      Delete
    2. Actually I meant the second way from that blog post (using extra Thread Group).

      Delete
  10. Hi Victor,

    How to load test Login functionality using Jmeter having Viewstate & Eventvalidation.

    ReplyDelete
  11. Casino in Dallas - Mapyro
    Casino 동두천 출장샵 in Dallas. Find mapyro real-time driving directions, reviews 통영 출장마사지 and 구미 출장안마 reviews of casinos and other gaming 부산광역 출장안마 facilities located in Dallas,  Rating: 7/10 목포 출장샵 · ‎13 reviews · ‎Price range: $$

    ReplyDelete