I have a gatling simulation where I would like to run a mix of scenarios, some authenticating like users logging into the system and others where our apis are authenticated via certificates.
The issue I am running into is that the gatling.conf file allows you to specify a single keystore/trustore which gets loaded prior to the simulation being run. This results in the scenarios which do NOT use certificates erroring out.
Is there a way to specify cert or standard auth within the setup of the Simulation or within the specifc scenario? I would potentially like to pass different certificates to different scenarios as well. Is this possible and are there examples of how this is done anywhere?
Here is an example of my simulation.
def httpProtocol: HttpProtocolBuilder = http
.baseUrl(SimulationUtils.BASE_URL)
.headers(SimulationUtils.DEFAULT_HEADERS)
.inferHtmlResources(WhiteList(SimulationUtils.BASE_URL + "/docp/.*")) //automatically load injected javascript that comes from HTML
.disableCaching
def httpProtocolLocal: HttpProtocolBuilder = http
.baseUrl(SimulationUtils.BASE_URL_LOCAL)
.header("Content-Type", "application/json")
.disableCaching
.disableUrlEncoding
setUp(
/**
* 1. Login
* 2. Search for an invoice
* 3. Click on random invoice in the row
* 4. Repeat steps 2 and 3, 10 times
*/
BuyerInvoiceSearchScenario.ScenarioBuilder.inject(
heavisideUsers(50) during (60 seconds)
).protocols(httpProtocol),
/**
* 1. Login
* 2. Search for an PO
* 3. Click on random PO in the row
* 4. Repeat steps 2 and 3, 2 times
*/
BuyerPurchaseOrderSearchScenario.ScenarioBuilder.inject(
heavisideUsers(50) during (60 seconds)
).protocols(httpProtocol),
/**
* 1. Go to the welcome app.
* 2. Request invoices using access token
* 3. Request invoice history
* 4. Repeat steps 2 and 3, 10 times
*/
InvoiceWelcomeAppScenario.ScenarioBuilder.inject(
heavisideUsers(100) during (60 seconds)
).protocols(
httpProtocol
.header("x-p2p-client", "welcome")
)
)
/** 1. Hit api with cert user credentials to retrieve invoices */
CertUserScenario.ScenarioBuilder.inject(heavisideUsers(100) during (10 seconds)
).protocols(httpProtocolLocal)
}