Skip to content

tilln/jmeter-cors-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jmeter-cors-plugin github-actions

Overview

Apache JMeter plugin for making CORS-preflight requests before HTTP requests to resources on other origins.

Similar to how a browser preflights cross-origin requests, e.g. REST API requests from single-page applications, this plugin creates a preflight request if necessary, without the need to explicitly add a Sampler for it to the JMeter Test Plan.

It also simulates a CORS-preflight cache to avoid unnecessary preflight requests, just as a browser would.

Example

cors-preprocessor

Usage

CORS Pre-Processor

Simply add a CORS Pre-Processor to the scope of any samplers that should make preflight requests.

settings

Preflight Requests

  • Sample Suffix: String to append to the preflight request's sample label (default: "-preflight").

Preflight Cache

  • Clear cache each iteration?: When set to "True" or "False" the preflight cache can be explicitly cleared or kept between Thread iterations. When left blank, it is only cleared when Thread Group property "Same user on each iteration" is not set.
  • Default expiry (seconds): Cache expiry duration to apply when no "Access-Control-Max-Age" header is returned. This allows overriding the 5 seconds the specification defines.

Installation

Under tab "Available Plugins", select "CORS Pre-Processor", then click "Apply Changes and Restart JMeter".

Via Package from JMeter-Plugins.org

Extract the zip package into JMeter's home directory, then restart JMeter.

Via Manual Download

  1. Copy the jmeter-cors-plugin jar file into JMeter's lib/ext directory.
  2. Restart JMeter.

Limitations

  • Minimum JMeter version 5.2.1
  • Timers, Pre-Processors, Post-Processors, and Assertions are not executed for the preflight request, but only once for the actual HTTP sampler. The preflight request will be made by a clone of the actual sampler after the preceding Pre-Processors have run. Pre-processors appearing after the CORS Pre-Processor will be effective for the actual sampler only.
  • CORS Pre-Processors are not "aware" of one another, so if a sampler's scope contains more than one, multiple preflight requests will be made.

About

JMeter Plugin for making CORS preflight requests

Topics

Resources

License

Stars

Watchers

Forks

Languages