@onlineapps/conn-orch-validator 2.0.16 → 2.0.18

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": "@onlineapps/conn-orch-validator",
3
- "version": "2.0.16",
3
+ "version": "2.0.18",
4
4
  "description": "Validation orchestrator for OA Drive microservices - coordinates validation across all layers (base, infra, orch, business)",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -21,7 +21,7 @@
21
21
  "author": "OnlineApps",
22
22
  "license": "PROPRIETARY",
23
23
  "dependencies": {
24
- "@onlineapps/service-validator-core": "^1.0.4",
24
+ "@onlineapps/service-validator-core": "1.0.9",
25
25
  "@onlineapps/runtime-config": "1.0.2",
26
26
  "ajv": "^8.12.0",
27
27
  "ajv-formats": "^2.1.1",
@@ -5,6 +5,7 @@ const path = require('path');
5
5
  const axios = require('axios');
6
6
  const MockMQClient = require('./mocks/MockMQClient');
7
7
  const MockRegistry = require('./mocks/MockRegistry');
8
+ const { resolveHeaders } = require('./utils/resolveHeaders');
8
9
 
9
10
  /**
10
11
  * CookbookTestRunner - Executes cookbook tests offline with mocked infrastructure
@@ -161,7 +162,11 @@ class CookbookTestRunner {
161
162
  method: endpoint.method,
162
163
  url: `${this.serviceUrl}${endpoint.path}`,
163
164
  data: step.input,
164
- timeout: testConfig.timeout || this.timeout
165
+ timeout: testConfig.timeout || this.timeout,
166
+ headers: {
167
+ ...resolveHeaders(endpoint.headers),
168
+ ...resolveHeaders(step.headers)
169
+ }
165
170
  };
166
171
 
167
172
  result.request = request;
@@ -370,7 +375,8 @@ class CookbookTestRunner {
370
375
 
371
376
  return {
372
377
  path: operation.endpoint,
373
- method: operation.method
378
+ method: operation.method,
379
+ headers: operation.headers || {}
374
380
  };
375
381
  }
376
382
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  const ServiceValidator = require('./ServiceValidator');
4
4
  const CookbookTestUtils = require('./CookbookTestUtils');
5
+ const { resolveHeaders } = require('./utils/resolveHeaders');
5
6
 
6
7
  /**
7
8
  * ServiceReadinessValidator - Orchestrates complete service validation
@@ -213,6 +214,7 @@ class ServiceReadinessValidator {
213
214
 
214
215
  // Generate test input based on schema
215
216
  const testInput = this.generateTestInput(operation.input);
217
+ const headers = resolveHeaders(operation.headers);
216
218
 
217
219
  // Make request
218
220
  const response = await axios({
@@ -220,6 +222,7 @@ class ServiceReadinessValidator {
220
222
  url,
221
223
  data: method !== 'get' ? testInput : undefined,
222
224
  params: method === 'get' ? testInput : undefined,
225
+ headers,
223
226
  timeout: 5000,
224
227
  validateStatus: () => true // Accept any status for validation
225
228
  });
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Resolve headers map with ${ENV_VAR} placeholders.
5
+ *
6
+ * Fail-fast rules:
7
+ * - If placeholder env var is missing or empty -> throw.
8
+ * - Header values must resolve to non-empty strings.
9
+ */
10
+ function resolveHeaders(headers, options = {}) {
11
+ if (!headers) return {};
12
+ if (typeof headers !== 'object') {
13
+ throw new Error(`[conn-orch-validator][Headers] Invalid headers - Expected object, got: ${typeof headers}`);
14
+ }
15
+
16
+ const env = options.env || process.env;
17
+ const resolved = {};
18
+
19
+ for (const [key, rawValue] of Object.entries(headers)) {
20
+ if (rawValue === undefined || rawValue === null) {
21
+ throw new Error(`[conn-orch-validator][Headers] Invalid header value - ${key} is ${rawValue}`);
22
+ }
23
+
24
+ const valueStr = String(rawValue);
25
+
26
+ const resolvedValue = valueStr.replace(/\$\{([A-Z0-9_]+)\}/g, (match, varName) => {
27
+ const envValue = env[varName];
28
+ if (envValue === undefined || envValue === null || String(envValue).trim() === '') {
29
+ throw new Error(`[conn-orch-validator][Headers] Missing environment variable - Expected ${varName} for header ${key}`);
30
+ }
31
+ return String(envValue);
32
+ });
33
+
34
+ if (resolvedValue.trim() === '') {
35
+ throw new Error(`[conn-orch-validator][Headers] Invalid resolved header - ${key} resolved to empty string`);
36
+ }
37
+
38
+ resolved[key] = resolvedValue;
39
+ }
40
+
41
+ return resolved;
42
+ }
43
+
44
+ module.exports = { resolveHeaders };
45
+
46
+