April 14, 2021

How to Employ HTTP Basic Authentication in JMeter

Occasionally, you'll need to examination URLs that tin can sometimes exist restricted from anonymous visits. The types and resources tin vary from corporate libraries and knowledge bases to targeted forums or others. All tend to have express or restricted access.

For instance, if you lot download something from an FTP server, you would run across the "gatekeeper" screen shown beneath. This pop-up window is generated by a browser when the server requires a username/password. The frame volition vary from browser to browser (e.g. Mozilla Firefox, Apple Safari, or Microsoft Internet Explorer), but regardless, a username/countersign is required to access what are frequently some bones resources.

This blazon of case is when HTTP bones hallmark will come into play. This blog will share insights into how to use HTTP basic authentication when running tests in JMeter.

Table of Contents:

  • What is HTTP Bones Authentication?
  • HTTP Basic Hallmark in JMeter

What is HTTP Basic Hallmark?

HTTP Basic Authentication (BA) is the simplest technique for enforcing access controls to spider web resources because it doesn't crave cookies, a session identifier, or login pages.

Withal, yous demand a strategy for such situations while executing functioning tests. Let's see how to do this using a local installation of phpmyadmin. (This web application helps manage MySQL databases without writing SQL queries.)

*Annotation: past default, phpmyadmin uses the login screen.

phpmyadmin installation

To change this behavior and utilize bones authentication, alter config.inc.php (for Linux, it is placed in /etc/phpmyadmin). Observe the post-obit string in it:

                  $cfg['Servers'][$i]['auth_type'] = 'cookie';                

and edit it to the following:

                  $cfg['Servers'][$i]['auth_type'] = 'http';                

HTTP Basic Authentication in JMeter

Ok. At present await at JMeter.  Amidst other elements, y'all accept the HTTP Authorization Manager. The Authorization Manager lets you specify one or more user logins to Web pages that are restricted using server hallmark. You see this manner of authentication when you attempt to admission a restricted page, and your browser displays a login dialog box. JMeter transmits the login data when it encounters this type of page.

Note: Say-so headers are not shown in the View Results Tree Listener, so you lot won't be able to bank check their values from the exam script.

Earlier diving into the details, here's a quick overview of the exam script:

view results tree

Now, let'due south check out the HTTP Authorization Manager. Which fields does information technology have?

JMeter HTTP Authorization Manager

Three fields should be taken intendance of in this example:

  • The Base URL– the link to the resource we want to access.
  • Username and password – they should be defined.
  • The HTTP Potency Managing director is disabled during the commencement run.

JMeter HTTP Authorization Manager: Fields

Since nosotros've configured information technology properly, the system does non provide access to the resources.

At present, let'southward see how it works when the HTTP Authorization Managing director is enabled.

HTTP Authorization Manager enabled on JMeter

In this scenario, the server has given us authorization and JMeter has received the HTML as a response.

How the BlazeMeter Load Testing Cloud Complements and Strengthens JMeter

While JMeter represents a potent and compelling way to perform load testing, of course, it's recommended to supplement that tool with BlazeMeter, which lets you simulate up to millions of users in a single developer-friendly, self-service platform.  With BlazeMeter, you can examination the performance of any mobile app, website, or API in under ten minutes.  Here's why we think the BlazeMeter/JMeter combination is bonny to developers:

  • Unproblematic Scalability – It'south easy to create big-calibration JMeter tests. Y'all can run far larger loads far more easily with BlazeMeter than you could with an in-house lab.
  • Rapid-Start Deployment – BlazeMeter's recorder helps you lot go started with JMeter right away, and BlazeMeter likewise provides complete tutorials and tips.
  • Web-Based Interactive Reports – You can hands share results across distributed teams and overcome the limitations of JMeter's standalone UI.
  • Built-In Intelligence – BlazeMeter provides on-demand geographic distribution of load generation, including congenital-in CDN-aware testing.

BlazeMeter results

Start Testing Now