@testsmith/perfornium 0.1.0
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/README.md +360 -0
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.js +192 -0
- package/dist/cli/commands/distributed.d.ts +11 -0
- package/dist/cli/commands/distributed.js +179 -0
- package/dist/cli/commands/import.d.ts +23 -0
- package/dist/cli/commands/import.js +461 -0
- package/dist/cli/commands/init.d.ts +7 -0
- package/dist/cli/commands/init.js +923 -0
- package/dist/cli/commands/mock.d.ts +7 -0
- package/dist/cli/commands/mock.js +281 -0
- package/dist/cli/commands/report.d.ts +5 -0
- package/dist/cli/commands/report.js +70 -0
- package/dist/cli/commands/run.d.ts +12 -0
- package/dist/cli/commands/run.js +260 -0
- package/dist/cli/commands/validate.d.ts +3 -0
- package/dist/cli/commands/validate.js +35 -0
- package/dist/cli/commands/worker.d.ts +27 -0
- package/dist/cli/commands/worker.js +320 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +20 -0
- package/dist/config/parser.d.ts +19 -0
- package/dist/config/parser.js +330 -0
- package/dist/config/types/global-config.d.ts +74 -0
- package/dist/config/types/global-config.js +2 -0
- package/dist/config/types/hooks.d.ts +58 -0
- package/dist/config/types/hooks.js +3 -0
- package/dist/config/types/import-types.d.ts +33 -0
- package/dist/config/types/import-types.js +2 -0
- package/dist/config/types/index.d.ts +11 -0
- package/dist/config/types/index.js +27 -0
- package/dist/config/types/load-config.d.ts +32 -0
- package/dist/config/types/load-config.js +9 -0
- package/dist/config/types/output-config.d.ts +10 -0
- package/dist/config/types/output-config.js +2 -0
- package/dist/config/types/report-config.d.ts +10 -0
- package/dist/config/types/report-config.js +2 -0
- package/dist/config/types/runtime-types.d.ts +6 -0
- package/dist/config/types/runtime-types.js +2 -0
- package/dist/config/types/scenario-config.d.ts +30 -0
- package/dist/config/types/scenario-config.js +2 -0
- package/dist/config/types/step-types.d.ts +139 -0
- package/dist/config/types/step-types.js +2 -0
- package/dist/config/types/test-configuration.d.ts +18 -0
- package/dist/config/types/test-configuration.js +2 -0
- package/dist/config/types/worker-config.d.ts +12 -0
- package/dist/config/types/worker-config.js +2 -0
- package/dist/config/validator.d.ts +19 -0
- package/dist/config/validator.js +198 -0
- package/dist/core/csv-data-provider.d.ts +47 -0
- package/dist/core/csv-data-provider.js +265 -0
- package/dist/core/hooks-manager.d.ts +33 -0
- package/dist/core/hooks-manager.js +129 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +11 -0
- package/dist/core/script-executor.d.ts +14 -0
- package/dist/core/script-executor.js +290 -0
- package/dist/core/step-executor.d.ts +41 -0
- package/dist/core/step-executor.js +680 -0
- package/dist/core/test-runner.d.ts +34 -0
- package/dist/core/test-runner.js +465 -0
- package/dist/core/threshold-evaluator.d.ts +43 -0
- package/dist/core/threshold-evaluator.js +170 -0
- package/dist/core/virtual-user-pool.d.ts +42 -0
- package/dist/core/virtual-user-pool.js +136 -0
- package/dist/core/virtual-user.d.ts +51 -0
- package/dist/core/virtual-user.js +488 -0
- package/dist/distributed/coordinator.d.ts +34 -0
- package/dist/distributed/coordinator.js +158 -0
- package/dist/distributed/health-monitor.d.ts +18 -0
- package/dist/distributed/health-monitor.js +72 -0
- package/dist/distributed/load-distributor.d.ts +17 -0
- package/dist/distributed/load-distributor.js +106 -0
- package/dist/distributed/remote-worker.d.ts +37 -0
- package/dist/distributed/remote-worker.js +241 -0
- package/dist/distributed/result-aggregator.d.ts +43 -0
- package/dist/distributed/result-aggregator.js +146 -0
- package/dist/dsl/index.d.ts +3 -0
- package/dist/dsl/index.js +11 -0
- package/dist/dsl/test-builder.d.ts +111 -0
- package/dist/dsl/test-builder.js +514 -0
- package/dist/importers/har-importer.d.ts +17 -0
- package/dist/importers/har-importer.js +172 -0
- package/dist/importers/open-api-importer.d.ts +23 -0
- package/dist/importers/open-api-importer.js +181 -0
- package/dist/importers/wsdl-importer.d.ts +42 -0
- package/dist/importers/wsdl-importer.js +440 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +17 -0
- package/dist/load-patterns/arrivals.d.ts +7 -0
- package/dist/load-patterns/arrivals.js +118 -0
- package/dist/load-patterns/base.d.ts +9 -0
- package/dist/load-patterns/base.js +2 -0
- package/dist/load-patterns/basic.d.ts +7 -0
- package/dist/load-patterns/basic.js +117 -0
- package/dist/load-patterns/stepping.d.ts +6 -0
- package/dist/load-patterns/stepping.js +122 -0
- package/dist/metrics/collector.d.ts +72 -0
- package/dist/metrics/collector.js +662 -0
- package/dist/metrics/types.d.ts +135 -0
- package/dist/metrics/types.js +2 -0
- package/dist/outputs/base.d.ts +7 -0
- package/dist/outputs/base.js +2 -0
- package/dist/outputs/csv.d.ts +13 -0
- package/dist/outputs/csv.js +163 -0
- package/dist/outputs/graphite.d.ts +13 -0
- package/dist/outputs/graphite.js +126 -0
- package/dist/outputs/influxdb.d.ts +12 -0
- package/dist/outputs/influxdb.js +82 -0
- package/dist/outputs/json.d.ts +14 -0
- package/dist/outputs/json.js +107 -0
- package/dist/outputs/streaming-csv.d.ts +37 -0
- package/dist/outputs/streaming-csv.js +254 -0
- package/dist/outputs/streaming-json.d.ts +43 -0
- package/dist/outputs/streaming-json.js +353 -0
- package/dist/outputs/webhook.d.ts +16 -0
- package/dist/outputs/webhook.js +96 -0
- package/dist/protocols/base.d.ts +33 -0
- package/dist/protocols/base.js +2 -0
- package/dist/protocols/rest/handler.d.ts +67 -0
- package/dist/protocols/rest/handler.js +776 -0
- package/dist/protocols/soap/handler.d.ts +12 -0
- package/dist/protocols/soap/handler.js +165 -0
- package/dist/protocols/web/core-web-vitals.d.ts +121 -0
- package/dist/protocols/web/core-web-vitals.js +373 -0
- package/dist/protocols/web/handler.d.ts +50 -0
- package/dist/protocols/web/handler.js +706 -0
- package/dist/recorder/native-recorder.d.ts +14 -0
- package/dist/recorder/native-recorder.js +533 -0
- package/dist/recorder/scenario-recorder.d.ts +55 -0
- package/dist/recorder/scenario-recorder.js +296 -0
- package/dist/reporting/constants.d.ts +94 -0
- package/dist/reporting/constants.js +82 -0
- package/dist/reporting/enhanced-html-generator.d.ts +55 -0
- package/dist/reporting/enhanced-html-generator.js +965 -0
- package/dist/reporting/generator.d.ts +42 -0
- package/dist/reporting/generator.js +1217 -0
- package/dist/reporting/statistics.d.ts +144 -0
- package/dist/reporting/statistics.js +742 -0
- package/dist/reporting/templates/enhanced-report.hbs +2812 -0
- package/dist/reporting/templates/html.hbs +2453 -0
- package/dist/utils/faker-manager.d.ts +55 -0
- package/dist/utils/faker-manager.js +166 -0
- package/dist/utils/file-manager.d.ts +33 -0
- package/dist/utils/file-manager.js +154 -0
- package/dist/utils/handlebars-manager.d.ts +42 -0
- package/dist/utils/handlebars-manager.js +172 -0
- package/dist/utils/logger.d.ts +16 -0
- package/dist/utils/logger.js +46 -0
- package/dist/utils/template.d.ts +80 -0
- package/dist/utils/template.js +513 -0
- package/dist/utils/test-output-writer.d.ts +56 -0
- package/dist/utils/test-output-writer.js +643 -0
- package/dist/utils/time.d.ts +3 -0
- package/dist/utils/time.js +23 -0
- package/dist/utils/timestamp-helper.d.ts +17 -0
- package/dist/utils/timestamp-helper.js +53 -0
- package/dist/workers/manager.d.ts +18 -0
- package/dist/workers/manager.js +95 -0
- package/dist/workers/server.d.ts +21 -0
- package/dist/workers/server.js +205 -0
- package/dist/workers/worker.d.ts +19 -0
- package/dist/workers/worker.js +147 -0
- package/package.json +102 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HARImporter = void 0;
|
|
4
|
+
class HARImporter {
|
|
5
|
+
constructor(harContent) {
|
|
6
|
+
this.har = harContent;
|
|
7
|
+
}
|
|
8
|
+
extractEndpoints() {
|
|
9
|
+
const endpoints = [];
|
|
10
|
+
const entries = this.har.log?.entries || [];
|
|
11
|
+
entries.forEach((entry, index) => {
|
|
12
|
+
const request = entry.request;
|
|
13
|
+
const response = entry.response;
|
|
14
|
+
// Skip non-API requests (images, CSS, JS, etc.)
|
|
15
|
+
if (!this.isAPIRequest(request))
|
|
16
|
+
return;
|
|
17
|
+
endpoints.push({
|
|
18
|
+
id: `har_${index}`,
|
|
19
|
+
name: `${request.method} ${this.extractPath(request.url)}`,
|
|
20
|
+
method: request.method,
|
|
21
|
+
path: this.extractPath(request.url),
|
|
22
|
+
description: `Captured from HAR: ${request.url}`,
|
|
23
|
+
parameters: this.extractParametersFromHAR(request),
|
|
24
|
+
requestBody: this.extractRequestBodyFromHAR(request),
|
|
25
|
+
responses: [{
|
|
26
|
+
statusCode: response.status,
|
|
27
|
+
contentType: this.extractContentType(response),
|
|
28
|
+
schema: null,
|
|
29
|
+
example: response.content?.text
|
|
30
|
+
}],
|
|
31
|
+
selected: false
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
return this.deduplicateEndpoints(endpoints);
|
|
35
|
+
}
|
|
36
|
+
generateScenarios(selectedEndpoints) {
|
|
37
|
+
return selectedEndpoints.map(endpoint => ({
|
|
38
|
+
name: `test_${endpoint.path.replace(/[\/\{\}]/g, '_')}`,
|
|
39
|
+
steps: [{
|
|
40
|
+
name: endpoint.name,
|
|
41
|
+
method: endpoint.method,
|
|
42
|
+
path: endpoint.path,
|
|
43
|
+
headers: this.extractHeadersFromEndpoint(endpoint),
|
|
44
|
+
json: this.parseRequestBody(endpoint.requestBody),
|
|
45
|
+
extract: this.generateHARExtractions(endpoint)
|
|
46
|
+
}]
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
isAPIRequest(request) {
|
|
50
|
+
const url = request.url.toLowerCase();
|
|
51
|
+
const method = request.method.toUpperCase();
|
|
52
|
+
// Skip static resources
|
|
53
|
+
const staticExtensions = ['.js', '.css', '.png', '.jpg', '.gif', '.ico', '.svg', '.woff', '.ttf'];
|
|
54
|
+
if (staticExtensions.some(ext => url.includes(ext)))
|
|
55
|
+
return false;
|
|
56
|
+
// Include API-like requests
|
|
57
|
+
const apiIndicators = ['/api/', '/v1/', '/v2/', '/graphql', '.json', '.xml'];
|
|
58
|
+
const hasAPIIndicator = apiIndicators.some(indicator => url.includes(indicator));
|
|
59
|
+
// Include non-GET requests to any endpoint
|
|
60
|
+
const isNonGetRequest = method !== 'GET';
|
|
61
|
+
return hasAPIIndicator || isNonGetRequest;
|
|
62
|
+
}
|
|
63
|
+
extractPath(url) {
|
|
64
|
+
try {
|
|
65
|
+
const urlObj = new URL(url);
|
|
66
|
+
return urlObj.pathname + urlObj.search;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return url;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
extractParametersFromHAR(request) {
|
|
73
|
+
const params = [];
|
|
74
|
+
// Query parameters
|
|
75
|
+
request.queryString?.forEach((param) => {
|
|
76
|
+
params.push({
|
|
77
|
+
name: param.name,
|
|
78
|
+
in: 'query',
|
|
79
|
+
required: false,
|
|
80
|
+
type: 'string',
|
|
81
|
+
example: param.value
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
// Header parameters (excluding standard headers)
|
|
85
|
+
const skipHeaders = ['host', 'user-agent', 'accept', 'accept-encoding', 'connection'];
|
|
86
|
+
request.headers?.forEach((header) => {
|
|
87
|
+
if (!skipHeaders.includes(header.name.toLowerCase())) {
|
|
88
|
+
params.push({
|
|
89
|
+
name: header.name,
|
|
90
|
+
in: 'header',
|
|
91
|
+
required: false,
|
|
92
|
+
type: 'string',
|
|
93
|
+
example: header.value
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return params;
|
|
98
|
+
}
|
|
99
|
+
extractRequestBodyFromHAR(request) {
|
|
100
|
+
const postData = request.postData;
|
|
101
|
+
if (!postData)
|
|
102
|
+
return undefined;
|
|
103
|
+
return {
|
|
104
|
+
contentType: postData.mimeType || 'application/json',
|
|
105
|
+
schema: null,
|
|
106
|
+
example: postData.text,
|
|
107
|
+
required: true
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
extractContentType(response) {
|
|
111
|
+
const contentTypeHeader = response.headers?.find((h) => h.name.toLowerCase() === 'content-type');
|
|
112
|
+
return contentTypeHeader?.value || 'application/json';
|
|
113
|
+
}
|
|
114
|
+
deduplicateEndpoints(endpoints) {
|
|
115
|
+
const seen = new Set();
|
|
116
|
+
return endpoints.filter(endpoint => {
|
|
117
|
+
const key = `${endpoint.method}_${endpoint.path}`;
|
|
118
|
+
if (seen.has(key))
|
|
119
|
+
return false;
|
|
120
|
+
seen.add(key);
|
|
121
|
+
return true;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
extractHeadersFromEndpoint(endpoint) {
|
|
125
|
+
const headers = {};
|
|
126
|
+
endpoint.parameters?.forEach(param => {
|
|
127
|
+
if (param.in === 'header') {
|
|
128
|
+
headers[param.name] = param.example || `{{${param.name}}}`;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return headers;
|
|
132
|
+
}
|
|
133
|
+
parseRequestBody(requestBody) {
|
|
134
|
+
if (!requestBody?.example)
|
|
135
|
+
return undefined;
|
|
136
|
+
try {
|
|
137
|
+
return JSON.parse(requestBody.example);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return requestBody.example;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
generateHARExtractions(endpoint) {
|
|
144
|
+
// Generate common extractions based on response patterns
|
|
145
|
+
const extractions = [];
|
|
146
|
+
endpoint.responses?.forEach(response => {
|
|
147
|
+
if (response.example) {
|
|
148
|
+
try {
|
|
149
|
+
const parsed = JSON.parse(response.example);
|
|
150
|
+
const commonFields = ['id', 'token', 'access_token', 'sessionId'];
|
|
151
|
+
commonFields.forEach(field => {
|
|
152
|
+
if (this.hasField(parsed, field)) {
|
|
153
|
+
extractions.push({
|
|
154
|
+
name: field,
|
|
155
|
+
type: 'json_path',
|
|
156
|
+
expression: `$.${field}`
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// Not JSON, skip extraction generation
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return extractions;
|
|
167
|
+
}
|
|
168
|
+
hasField(obj, field) {
|
|
169
|
+
return obj && typeof obj === 'object' && field in obj;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.HARImporter = HARImporter;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ImportableEndpoint } from "../config/types/import-types";
|
|
2
|
+
export declare class OpenAPIImporter {
|
|
3
|
+
private spec;
|
|
4
|
+
constructor(spec: any);
|
|
5
|
+
/**
|
|
6
|
+
* Parse OpenAPI spec and extract all available endpoints
|
|
7
|
+
*/
|
|
8
|
+
extractEndpoints(): ImportableEndpoint[];
|
|
9
|
+
/**
|
|
10
|
+
* Generate test scenarios from selected endpoints
|
|
11
|
+
*/
|
|
12
|
+
generateScenarios(selectedEndpoints: ImportableEndpoint[]): any[];
|
|
13
|
+
private extractParameters;
|
|
14
|
+
private parseParameters;
|
|
15
|
+
private extractRequestBody;
|
|
16
|
+
private extractResponses;
|
|
17
|
+
private generateHeaders;
|
|
18
|
+
private generateRequestBody;
|
|
19
|
+
private generateExtractions;
|
|
20
|
+
private generateFromSchema;
|
|
21
|
+
private generateValueFromSchema;
|
|
22
|
+
private schemaHasProperty;
|
|
23
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenAPIImporter = void 0;
|
|
4
|
+
class OpenAPIImporter {
|
|
5
|
+
constructor(spec) {
|
|
6
|
+
this.spec = spec;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parse OpenAPI spec and extract all available endpoints
|
|
10
|
+
*/
|
|
11
|
+
extractEndpoints() {
|
|
12
|
+
const endpoints = [];
|
|
13
|
+
const paths = this.spec.paths || {};
|
|
14
|
+
for (const [path, pathItem] of Object.entries(paths)) {
|
|
15
|
+
const methods = ['get', 'post', 'put', 'patch', 'delete', 'options', 'head'];
|
|
16
|
+
for (const method of methods) {
|
|
17
|
+
const operation = pathItem[method];
|
|
18
|
+
if (!operation)
|
|
19
|
+
continue;
|
|
20
|
+
endpoints.push({
|
|
21
|
+
id: `${method.toUpperCase()}_${path}`,
|
|
22
|
+
name: operation.summary || operation.operationId || `${method.toUpperCase()} ${path}`,
|
|
23
|
+
method: method.toUpperCase(),
|
|
24
|
+
path: path,
|
|
25
|
+
description: operation.description,
|
|
26
|
+
parameters: this.extractParameters(operation, pathItem),
|
|
27
|
+
requestBody: this.extractRequestBody(operation),
|
|
28
|
+
responses: this.extractResponses(operation),
|
|
29
|
+
tags: operation.tags || [],
|
|
30
|
+
selected: false
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return endpoints;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Generate test scenarios from selected endpoints
|
|
38
|
+
*/
|
|
39
|
+
generateScenarios(selectedEndpoints) {
|
|
40
|
+
return selectedEndpoints.map(endpoint => ({
|
|
41
|
+
name: `test_${endpoint.name.toLowerCase().replace(/\s+/g, '_')}`,
|
|
42
|
+
steps: [{
|
|
43
|
+
name: endpoint.name,
|
|
44
|
+
method: endpoint.method,
|
|
45
|
+
path: endpoint.path,
|
|
46
|
+
headers: this.generateHeaders(endpoint),
|
|
47
|
+
json: this.generateRequestBody(endpoint),
|
|
48
|
+
extract: this.generateExtractions(endpoint)
|
|
49
|
+
}]
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
extractParameters(operation, pathItem) {
|
|
53
|
+
const params = [];
|
|
54
|
+
// Operation-level parameters
|
|
55
|
+
if (operation.parameters) {
|
|
56
|
+
params.push(...this.parseParameters(operation.parameters));
|
|
57
|
+
}
|
|
58
|
+
// Path-level parameters
|
|
59
|
+
if (pathItem.parameters) {
|
|
60
|
+
params.push(...this.parseParameters(pathItem.parameters));
|
|
61
|
+
}
|
|
62
|
+
return params;
|
|
63
|
+
}
|
|
64
|
+
parseParameters(parameters) {
|
|
65
|
+
return parameters.map(param => ({
|
|
66
|
+
name: param.name,
|
|
67
|
+
in: param.in,
|
|
68
|
+
required: param.required || false,
|
|
69
|
+
type: param.schema?.type || param.type || 'string',
|
|
70
|
+
description: param.description,
|
|
71
|
+
example: param.example || param.schema?.example,
|
|
72
|
+
enum: param.schema?.enum || param.enum
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
extractRequestBody(operation) {
|
|
76
|
+
if (!operation.requestBody)
|
|
77
|
+
return undefined;
|
|
78
|
+
const content = operation.requestBody.content || {};
|
|
79
|
+
const contentType = Object.keys(content)[0]; // Take first content type
|
|
80
|
+
if (!contentType)
|
|
81
|
+
return undefined;
|
|
82
|
+
return {
|
|
83
|
+
contentType,
|
|
84
|
+
schema: content[contentType].schema,
|
|
85
|
+
example: content[contentType].example,
|
|
86
|
+
required: operation.requestBody.required || false
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
extractResponses(operation) {
|
|
90
|
+
const responses = [];
|
|
91
|
+
for (const [statusCode, response] of Object.entries(operation.responses || {})) {
|
|
92
|
+
const content = response.content || {};
|
|
93
|
+
for (const [contentType, mediaType] of Object.entries(content)) {
|
|
94
|
+
responses.push({
|
|
95
|
+
statusCode: parseInt(statusCode),
|
|
96
|
+
contentType,
|
|
97
|
+
schema: mediaType.schema,
|
|
98
|
+
example: mediaType.example
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return responses;
|
|
103
|
+
}
|
|
104
|
+
generateHeaders(endpoint) {
|
|
105
|
+
const headers = {};
|
|
106
|
+
endpoint.parameters?.forEach(param => {
|
|
107
|
+
if (param.in === 'header') {
|
|
108
|
+
headers[param.name] = param.example || `{{${param.name}}}`;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return headers;
|
|
112
|
+
}
|
|
113
|
+
generateRequestBody(endpoint) {
|
|
114
|
+
if (!endpoint.requestBody)
|
|
115
|
+
return undefined;
|
|
116
|
+
if (endpoint.requestBody.example) {
|
|
117
|
+
return endpoint.requestBody.example;
|
|
118
|
+
}
|
|
119
|
+
// Generate from schema
|
|
120
|
+
return this.generateFromSchema(endpoint.requestBody.schema);
|
|
121
|
+
}
|
|
122
|
+
generateExtractions(endpoint) {
|
|
123
|
+
const extractions = [];
|
|
124
|
+
// Extract common response fields that might be useful for correlation
|
|
125
|
+
endpoint.responses?.forEach(response => {
|
|
126
|
+
if (response.statusCode >= 200 && response.statusCode < 300 && response.schema) {
|
|
127
|
+
const commonFields = ['id', 'token', 'access_token', 'refresh_token', 'sessionId'];
|
|
128
|
+
commonFields.forEach(field => {
|
|
129
|
+
if (this.schemaHasProperty(response.schema, field)) {
|
|
130
|
+
extractions.push({
|
|
131
|
+
name: field,
|
|
132
|
+
type: 'json_path',
|
|
133
|
+
expression: `$.${field}`
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return extractions;
|
|
140
|
+
}
|
|
141
|
+
generateFromSchema(schema) {
|
|
142
|
+
if (!schema)
|
|
143
|
+
return {};
|
|
144
|
+
// Basic schema-to-example generation
|
|
145
|
+
if (schema.example)
|
|
146
|
+
return schema.example;
|
|
147
|
+
if (schema.properties) {
|
|
148
|
+
const example = {};
|
|
149
|
+
for (const [prop, propSchema] of Object.entries(schema.properties)) {
|
|
150
|
+
example[prop] = this.generateValueFromSchema(propSchema);
|
|
151
|
+
}
|
|
152
|
+
return example;
|
|
153
|
+
}
|
|
154
|
+
return {};
|
|
155
|
+
}
|
|
156
|
+
generateValueFromSchema(schema) {
|
|
157
|
+
if (schema.example !== undefined)
|
|
158
|
+
return schema.example;
|
|
159
|
+
if (schema.enum)
|
|
160
|
+
return schema.enum[0];
|
|
161
|
+
switch (schema.type) {
|
|
162
|
+
case 'string':
|
|
163
|
+
return schema.format === 'email' ? '{{faker.internet.email}}' : '{{faker.lorem.word}}';
|
|
164
|
+
case 'number':
|
|
165
|
+
case 'integer':
|
|
166
|
+
return '{{faker.number.int}}';
|
|
167
|
+
case 'boolean':
|
|
168
|
+
return true;
|
|
169
|
+
case 'array':
|
|
170
|
+
return [this.generateValueFromSchema(schema.items || {})];
|
|
171
|
+
case 'object':
|
|
172
|
+
return this.generateFromSchema(schema);
|
|
173
|
+
default:
|
|
174
|
+
return `{{${schema.type || 'value'}}}`;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
schemaHasProperty(schema, property) {
|
|
178
|
+
return schema && schema.properties && schema.properties[property];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.OpenAPIImporter = OpenAPIImporter;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ImportableEndpoint } from "../config/types/import-types";
|
|
2
|
+
interface SoapVersion {
|
|
3
|
+
version: string;
|
|
4
|
+
bindingName: string;
|
|
5
|
+
description: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class WSDLImporter {
|
|
8
|
+
private wsdlContent;
|
|
9
|
+
private selectedSoapVersions;
|
|
10
|
+
constructor(wsdlContent: string);
|
|
11
|
+
detectSoapVersions(): SoapVersion[];
|
|
12
|
+
setSoapVersions(versions: string[]): void;
|
|
13
|
+
extractServices(): ImportableEndpoint[];
|
|
14
|
+
generateOutputFilename(baseFilename: string): string;
|
|
15
|
+
generateScenarios(selectedServices: ImportableEndpoint[]): any[];
|
|
16
|
+
getWsdlUrl(selectedServices: ImportableEndpoint[]): string;
|
|
17
|
+
private extractServiceElements;
|
|
18
|
+
private extractPortElements;
|
|
19
|
+
private extractEndpointFromPort;
|
|
20
|
+
private isBindingVersionSelected;
|
|
21
|
+
private getSoapVersionFromBinding;
|
|
22
|
+
private extractOperationsFromBinding;
|
|
23
|
+
private extractSoapAction;
|
|
24
|
+
private getOperationDocumentation;
|
|
25
|
+
private parseSchemaElement;
|
|
26
|
+
private mapXsdType;
|
|
27
|
+
private createImportableEndpoint;
|
|
28
|
+
private getContentType;
|
|
29
|
+
private getResponseContentType;
|
|
30
|
+
private generateSOAPParameters;
|
|
31
|
+
private generateSOAPExample;
|
|
32
|
+
private generateSOAPResponseExample;
|
|
33
|
+
private generateSampleParameters;
|
|
34
|
+
private getSampleValue;
|
|
35
|
+
private generateArgsFromSchema;
|
|
36
|
+
private extractWsdlUrl;
|
|
37
|
+
private generateSOAPExtractions;
|
|
38
|
+
private getPathFromUrl;
|
|
39
|
+
private getTargetNamespace;
|
|
40
|
+
private extractAttribute;
|
|
41
|
+
}
|
|
42
|
+
export {};
|