@gatling.io/postman 3.14.200 → 3.14.301
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gatling.io/postman",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.301",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"homepage": "https://gatling.io",
|
|
6
6
|
"bugs": "https://github.com/gatling/gatling/issues",
|
|
@@ -20,20 +20,21 @@
|
|
|
20
20
|
"main": "target/index.js",
|
|
21
21
|
"types": "target/index.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@gatling.io/core": "3.14.
|
|
24
|
-
"@gatling.io/http": "3.14.
|
|
23
|
+
"@gatling.io/core": "3.14.301",
|
|
24
|
+
"@gatling.io/http": "3.14.301",
|
|
25
25
|
"mime-types": "3.0.1",
|
|
26
26
|
"postman-collection": "5.0.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/mime-types": "2.1.4",
|
|
30
30
|
"@types/jest": "29.5.14",
|
|
31
|
+
"crypto-js": "4.2.0",
|
|
31
32
|
"jest": "29.7.0",
|
|
32
33
|
"prettier": "3.5.3",
|
|
34
|
+
"moment": "2.30.1",
|
|
33
35
|
"rimraf": "6.0.1",
|
|
34
36
|
"ts-jest": "29.3.4",
|
|
35
|
-
"typescript": "5.8.3"
|
|
36
|
-
"workspace-version": "0.1.4"
|
|
37
|
+
"typescript": "5.8.3"
|
|
37
38
|
},
|
|
38
39
|
"scripts": {
|
|
39
40
|
"clean": "rimraf target",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Duration, ScenarioBuilder } from "@gatling.io/core";
|
|
2
|
-
import { HttpRequestActionBuilder } from "@gatling.io/http";
|
|
1
|
+
import { ActionBuilder, ChainBuilder, Duration, ScenarioBuilder } from "@gatling.io/core";
|
|
3
2
|
export interface Postman {
|
|
4
3
|
/**
|
|
5
4
|
* @param collectionPath - Path to an exported collection file in the project resources
|
|
@@ -19,6 +18,18 @@ export interface PostmanCollection extends PostmanCollectionFolder {
|
|
|
19
18
|
* @param variables - A dictionary of variables, or the path to an exported environment file in the project resources
|
|
20
19
|
*/
|
|
21
20
|
globals(variables: Record<string, string> | string): PostmanCollection;
|
|
21
|
+
/**
|
|
22
|
+
* Inject a CSV data file in the collection.
|
|
23
|
+
*/
|
|
24
|
+
csvDataFile(path: string): PostmanCollection;
|
|
25
|
+
/**
|
|
26
|
+
* Inject a JSON data file in the collection.
|
|
27
|
+
*/
|
|
28
|
+
jsonDataFile(path: string): PostmanCollection;
|
|
29
|
+
/**
|
|
30
|
+
* Call at the start of a scenario to initialize variables.
|
|
31
|
+
*/
|
|
32
|
+
initVariables: ChainBuilder;
|
|
22
33
|
}
|
|
23
34
|
export interface PostmanCollectionFolder {
|
|
24
35
|
/**
|
|
@@ -33,7 +44,7 @@ export interface PostmanCollectionFolder {
|
|
|
33
44
|
* @param request - Name of a request contained in the current folder
|
|
34
45
|
* @param overrideName - Optionally override the Gatling request name, otherwise the Postman request name will be used
|
|
35
46
|
*/
|
|
36
|
-
request(request: string, overrideName?: string):
|
|
47
|
+
request(request: string, overrideName?: string): ActionBuilder;
|
|
37
48
|
/**
|
|
38
49
|
* Create a Gatling scenario from the list of requests contained in the current folder.
|
|
39
50
|
*
|
package/target/postman/index.js
CHANGED
|
@@ -3,25 +3,48 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.postman = void 0;
|
|
4
4
|
const core_1 = require("@gatling.io/core");
|
|
5
5
|
const jvm_1 = require("../jvm");
|
|
6
|
+
const runtimeData_1 = require("./runtimeData");
|
|
6
7
|
const request_1 = require("./request");
|
|
7
8
|
const utils_1 = require("./utils");
|
|
8
9
|
(0, jvm_1.onInit)();
|
|
9
10
|
exports.postman = {
|
|
10
|
-
fromResource: (collectionPath) => postmanCollectionImpl((0, utils_1.readCollectionFromResource)(collectionPath), {}, {})
|
|
11
|
+
fromResource: (collectionPath) => postmanCollectionImpl((0, utils_1.readCollectionFromResource)(collectionPath), {}, {}, undefined)
|
|
12
|
+
};
|
|
13
|
+
const postmanCollectionImpl = (collection, environment, globals, dataFile) => {
|
|
14
|
+
const runtimeDataKey = `postman-runtime-data-coll-${collection.id}`;
|
|
15
|
+
const feeder = buildFeeder(dataFile);
|
|
16
|
+
const initVariables = (0, core_1.exec)((session) => {
|
|
17
|
+
const data = feeder !== undefined ? request_1.PostmanDataFile.feed(feeder) : {};
|
|
18
|
+
const newJvmSession = runtimeData_1.PostmanRuntimeData.createInSession(session._underlying, runtimeDataKey, globals, collection.variables.toObject(true), environment, data, {});
|
|
19
|
+
return (0, core_1.wrapSession)(newJvmSession);
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
environment: (variables) => postmanCollectionImpl(collection, resolveEnvironment(variables), globals, dataFile),
|
|
23
|
+
globals: (variables) => postmanCollectionImpl(collection, environment, resolveEnvironment(variables), dataFile),
|
|
24
|
+
csvDataFile: (path) => postmanCollectionImpl(collection, environment, globals, { path, type: "csv" }),
|
|
25
|
+
jsonDataFile: (path) => postmanCollectionImpl(collection, environment, globals, { path, type: "json" }),
|
|
26
|
+
initVariables,
|
|
27
|
+
...postmanCollectionFolder(collection, collection, environment, globals, initVariables, runtimeDataKey)
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const buildFeeder = (dataFile) => {
|
|
31
|
+
if (dataFile === undefined) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const builder = dataFile?.type === "csv" ? (0, core_1.csv)(dataFile.path) : (0, core_1.jsonFile)(dataFile.path);
|
|
36
|
+
return builder.circular()._underlying.asScala().apply();
|
|
37
|
+
}
|
|
11
38
|
};
|
|
12
|
-
const postmanCollectionImpl = (collection, environment, globals) => ({
|
|
13
|
-
environment: (variables) => postmanCollectionImpl(collection, resolveEnvironment(variables), globals),
|
|
14
|
-
globals: (variables) => postmanCollectionImpl(collection, environment, resolveEnvironment(variables)),
|
|
15
|
-
...postmanCollectionFolder(collection, collection, environment, globals)
|
|
16
|
-
});
|
|
17
39
|
const resolveEnvironment = (variables) => typeof variables === "string" ? (0, utils_1.readEnvironmentFromResource)(variables) : variables;
|
|
18
|
-
const
|
|
40
|
+
const postmanRequest = (requestName, postmanItem, runtimeDataKey) => (0, core_1.wrapActionBuilder)(request_1.PostmanDsl.postmanRequest(requestName, postmanItem, runtimeDataKey));
|
|
41
|
+
const postmanCollectionFolder = (collection, currentItemGroup, environment, globals, initVariables, runtimeDataKey) => ({
|
|
19
42
|
folder: (folder) => {
|
|
20
43
|
const newItemGroup = (0, utils_1.findItemGroup)(currentItemGroup, folder);
|
|
21
44
|
if (newItemGroup === undefined) {
|
|
22
45
|
throw Error(`Postman folder '${folder}' not found`);
|
|
23
46
|
}
|
|
24
|
-
return postmanCollectionFolder(collection, newItemGroup, environment, globals);
|
|
47
|
+
return postmanCollectionFolder(collection, newItemGroup, environment, globals, initVariables, runtimeDataKey);
|
|
25
48
|
},
|
|
26
49
|
request: (request, overrideName) => {
|
|
27
50
|
const name = overrideName !== undefined ? overrideName : request;
|
|
@@ -29,17 +52,17 @@ const postmanCollectionFolder = (collection, currentItemGroup, environment, glob
|
|
|
29
52
|
if (item === undefined) {
|
|
30
53
|
throw Error(`Postman request '${request}' not found`);
|
|
31
54
|
}
|
|
32
|
-
return
|
|
55
|
+
return postmanRequest(name, item, runtimeDataKey);
|
|
33
56
|
},
|
|
34
57
|
scenario: (name, options) => {
|
|
35
|
-
let scn = (0, core_1.scenario)(name);
|
|
58
|
+
let scn = (0, core_1.scenario)(name).exec(initVariables);
|
|
36
59
|
const recursive = options?.recursive || false;
|
|
37
60
|
const pauses = options?.pauses;
|
|
38
61
|
(0, utils_1.listItems)(currentItemGroup, recursive).forEach((item, idx) => {
|
|
39
62
|
if (pauses !== undefined && idx > 0) {
|
|
40
63
|
scn = scn.pause(pauses);
|
|
41
64
|
}
|
|
42
|
-
scn = scn.exec(
|
|
65
|
+
scn = scn.exec(postmanRequest(item.name, item, runtimeDataKey));
|
|
43
66
|
});
|
|
44
67
|
return scn;
|
|
45
68
|
}
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
import "@gatling.io/jvm-types";
|
|
2
|
+
import { ActionBuilder } from "@gatling.io/core";
|
|
1
3
|
import * as pm from "postman-collection";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
+
import JvmActionBuilder = io.gatling.javaapi.core.ActionBuilder;
|
|
5
|
+
import JvmChainBuilder = io.gatling.javaapi.core.ChainBuilder;
|
|
6
|
+
interface JvmPostmanRequestActionBuilder extends JvmActionBuilder {
|
|
7
|
+
asScala(): any;
|
|
8
|
+
toChainBuilder(): JvmChainBuilder;
|
|
9
|
+
}
|
|
10
|
+
export interface PostmanDslStatic {
|
|
11
|
+
postmanRequest(requestName: string, postmanItem: pm.Item, runtimeDataKey: string): JvmPostmanRequestActionBuilder;
|
|
12
|
+
}
|
|
13
|
+
export declare const PostmanDsl: PostmanDslStatic;
|
|
14
|
+
export interface PostmanRequestActionBuilder extends ActionBuilder {
|
|
15
|
+
}
|
|
16
|
+
export interface ScalaFeeder {
|
|
17
|
+
next(): Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
export interface PostmanDataFileStatic {
|
|
20
|
+
feed(feeder: ScalaFeeder): Record<string, any>;
|
|
21
|
+
}
|
|
22
|
+
export declare const PostmanDataFile: PostmanDataFileStatic;
|
|
23
|
+
export {};
|
|
@@ -1,125 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const http_1 = require("@gatling.io/http");
|
|
41
|
-
const jvm_1 = require("../jvm");
|
|
42
|
-
const postmanRequest = (name, collection, item, environment, globals) => {
|
|
43
|
-
const variableDefinitions = [environment, collection.variables, globals];
|
|
44
|
-
const resolvedItem = new pm.Item(item.toObjectResolved(null, variableDefinitions, { ignoreOwnVariables: true }));
|
|
45
|
-
const method = resolvedItem.request.method;
|
|
46
|
-
const url = resolvedItem.request.url.toString();
|
|
47
|
-
const w = jvm_1.wrapUrl;
|
|
48
|
-
let gatlingRequest = w !== undefined
|
|
49
|
-
? (0, http_1.http)(name).httpRequest(method, (session) => w(url, session.userId()))
|
|
50
|
-
: (0, http_1.http)(name).httpRequest(method, url);
|
|
51
|
-
// Body
|
|
52
|
-
if (resolvedItem.request.body !== undefined) {
|
|
53
|
-
gatlingRequest = setBody(gatlingRequest, resolvedItem.request.body);
|
|
54
|
-
}
|
|
55
|
-
// Headers
|
|
56
|
-
resolvedItem.request.headers.each((h) => {
|
|
57
|
-
if (!h.disabled) {
|
|
58
|
-
gatlingRequest = gatlingRequest.header(h.key, h.value);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return gatlingRequest;
|
|
62
|
-
};
|
|
63
|
-
exports.postmanRequest = postmanRequest;
|
|
64
|
-
const setBody = (gatlingRequest, body) => {
|
|
65
|
-
switch (body.mode) {
|
|
66
|
-
case "formdata":
|
|
67
|
-
gatlingRequest = gatlingRequest.asMultipartForm();
|
|
68
|
-
if (body.formdata) {
|
|
69
|
-
body.formdata.each((param) => {
|
|
70
|
-
if (!param.disabled) {
|
|
71
|
-
if (param.type === "file") {
|
|
72
|
-
const filePath = resolveFile(param.src);
|
|
73
|
-
gatlingRequest = gatlingRequest.formUpload(param.key, filePath);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
gatlingRequest = gatlingRequest.formParam(param.key, param.value);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return gatlingRequest;
|
|
82
|
-
case "urlencoded":
|
|
83
|
-
gatlingRequest = gatlingRequest.asFormUrlEncoded();
|
|
84
|
-
if (body.urlencoded) {
|
|
85
|
-
body.urlencoded.each((param) => {
|
|
86
|
-
if (!param.disabled) {
|
|
87
|
-
gatlingRequest = gatlingRequest.formParam(param.key, param.value);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
return gatlingRequest;
|
|
92
|
-
case "raw":
|
|
93
|
-
const language = body.options?.raw?.language || "text";
|
|
94
|
-
return gatlingRequest.body((0, core_1.StringBody)(body.raw || "")).header("content-type", rawContentTypes[language]);
|
|
95
|
-
case "file":
|
|
96
|
-
const src = resolveFile(body.file?.src || "");
|
|
97
|
-
const mimeType = (0, mime_types_1.lookup)(src) || "application/octet-stream";
|
|
98
|
-
return gatlingRequest.body((0, core_1.RawFileBody)(src)).header("content-type", mimeType);
|
|
99
|
-
case "graphql":
|
|
100
|
-
const query = body.graphql?.query;
|
|
101
|
-
const jsonBody = body.graphql?.variables !== undefined && body.graphql.variables.length > 0
|
|
102
|
-
? { query, variables: JSON.parse(body.graphql.variables) }
|
|
103
|
-
: { query };
|
|
104
|
-
return gatlingRequest.body((0, core_1.StringBody)(JSON.stringify(jsonBody))).asJson();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
const rawContentTypes = {
|
|
108
|
-
text: "text/plain",
|
|
109
|
-
javascript: "application/javascript",
|
|
110
|
-
json: "application/json",
|
|
111
|
-
html: "text/html",
|
|
112
|
-
xml: "application/xml"
|
|
113
|
-
};
|
|
114
|
-
const resolveFile = (src) => {
|
|
115
|
-
if (src.startsWith("postman-cloud://")) {
|
|
116
|
-
// TODO implement downloading files from Postman Cloud
|
|
117
|
-
throw Error("Downloading files from Postman Cloud is not implemented yet, unable to retrieve " + src);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
// TODO check if file exists
|
|
121
|
-
// File is assumed to be in the project resources by default
|
|
122
|
-
// TODO allow configuring location of Postman working directory in the protocol
|
|
123
|
-
return src;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
3
|
+
exports.PostmanDataFile = exports.PostmanDsl = void 0;
|
|
4
|
+
require("@gatling.io/jvm-types");
|
|
5
|
+
exports.PostmanDsl = Java.type("io.gatling.javaapi.postman.PostmanDsl");
|
|
6
|
+
exports.PostmanDataFile = Java.type("io.gatling.postman.PostmanDataFile");
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import "@gatling.io/jvm-types";
|
|
2
|
+
import JvmSession = io.gatling.javaapi.core.Session;
|
|
3
|
+
import { MutationTracker, Variable } from "postman-collection";
|
|
4
|
+
export interface PostmanRuntimeDataStatic {
|
|
5
|
+
createInSession(session: JvmSession, key: string, globalVariables: Record<string, any>, collectionVariables: Record<string, any>, environmentVariables: Record<string, any>, dataVariables: Record<string, any>, localVariables: Record<string, any>): JvmSession;
|
|
6
|
+
}
|
|
7
|
+
export interface PostmanVariableScope {
|
|
8
|
+
toObject(excludeDisabled: boolean, caseSensitive: boolean): any;
|
|
9
|
+
has(key: string): boolean;
|
|
10
|
+
get(key: string): any;
|
|
11
|
+
set(key: string, value: any, type?: Variable.types): void;
|
|
12
|
+
unset(key: string): void;
|
|
13
|
+
clear(): void;
|
|
14
|
+
replaceIn(template: string | any): string | any;
|
|
15
|
+
enableTracking(options?: MutationTracker.definition): void;
|
|
16
|
+
disableTracking(): void;
|
|
17
|
+
toJSON(): any;
|
|
18
|
+
}
|
|
19
|
+
export interface JvmPostmanInfo {
|
|
20
|
+
eventName: string;
|
|
21
|
+
iteration: number;
|
|
22
|
+
iterationCount: number;
|
|
23
|
+
requestName: string;
|
|
24
|
+
requestId: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PostmanRuntimeData {
|
|
27
|
+
globalVariables: PostmanVariableScope;
|
|
28
|
+
collectionVariables: PostmanVariableScope;
|
|
29
|
+
environmentVariables: PostmanVariableScope;
|
|
30
|
+
localVariables: PostmanVariableScope;
|
|
31
|
+
}
|
|
32
|
+
export declare const PostmanRuntimeData: PostmanRuntimeDataStatic;
|