forked from StellarRouter/StellarRouter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartillery-processor.js
More file actions
25 lines (21 loc) · 787 Bytes
/
Copy pathartillery-processor.js
File metadata and controls
25 lines (21 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Artillery processor for router-metrics-exporter load tests
// Handles dynamic header generation and request customization
module.exports = {
// Generate random nonce for replay protection
generateNonce: generateNonce,
// Add API key to request if configured
addApiKey: addApiKey,
};
function generateNonce(requestParams, context, ee, next) {
const nonce = `nonce-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
requestParams.headers = requestParams.headers || {};
requestParams.headers['X-Nonce'] = nonce;
return next();
}
function addApiKey(requestParams, context, ee, next) {
if (context.vars.api_key) {
requestParams.headers = requestParams.headers || {};
requestParams.headers['X-API-Key'] = context.vars.api_key;
}
return next();
}