Base solution for your next web application
Open Closed

Any reference to use Jmeter to loadtest Aspnet zero #8288


User avatar
0
zdeen created

Any doc or link that would share some pointers on how to loadtest aspnet zero with Jmeter. Looking for option on how to set the authentication cookie in Jmeter which we get once API (ASP.NET CORE version) is authenticated.


6 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    If the authentication is successful, the login endpoint will return cookies containing the user's identity information. Please carry these cookies with your subsequent requests.

    https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/Controllers/AccountController.cs#L161

  • User Avatar
    0
    alper created
    Support Team

    We can create a jMeter script that authorizes to the backend.

    Make a POST request to
    http://YourWebHost.com/api/TokenAuth/Authenticate

    {
    "userNameOrEmailAddress":"admin",
    "password":"123456"
    }
    

    Sample:

    await fetch("http://YourSite.com/api/TokenAuth/Authenticate", {
        "credentials": "include",
        "headers": {
            "Content-Type": "application/json-patch+json"
        },   
        "body": "{\"userNameOrEmailAddress\":\"admin\",\"password\":\"123456\"}",
        "method": "POST",
        "mode": "cors"
    });
    
    
    
  • User Avatar
    0
    zdeen created

    Thanks all for the help. Would try these options

  • User Avatar
    0
    alper created
    Support Team

    hi guys,

    I created a jMeter test case which retrieves an authentication token and makes a GET request to fetch users.

    Download the AspNet Zero jMeter test example.

  • User Avatar
    0
    zdeen created

    Thanks a million.This was great help.

  • User Avatar
    0
    zdeen created

    I just realized that in my case I need to get to UI login screen capture the cookies and then pass the cookie to other calls.

    The reason is I have some checks in my code for certain feature and while making a call with Token which apparently takes host context, the call to check feature fails since these are enabled at Tenant level and not at host level

    Probably I can add a validation in these calls to check if AbpSession.Tenantid==null then take it as host context and don't do the vlidation but its very risky and may be can open spots for some securty gaps.

    Something like this: