import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import test from 'node:test' const read = (name) => readFileSync(new URL(name, import.meta.url), 'utf8') const client = read('./client-test-env-acceptance.mjs') const clientPhase2 = read('./client-phase2-test-env-acceptance.mjs') const pendingOrders = read('./create-pending-review-orders.mjs') const activeHttpScripts = [client, clientPhase2, pendingOrders] const removedEnvironmentVariables = [ 'CLIENT_TEST_GATEWAY', 'CLIENT_PHASE2_TEST_GATEWAY', 'PLATFORM_USERNAME', 'PLATFORM_PASSWORD', 'EXISTING_CLIENT_USERNAME', 'EXISTING_CLIENT_PASSWORD', 'CLIENT_PHASE2_USERNAME', 'CLIENT_PHASE2_PASSWORD', ] test('active Client and data-generation scripts share the canonical environment variables', () => { for (const source of activeHttpScripts) { assert.match(source, /process\.env\.ADMIN_TEST_GATEWAY/) assert.match(source, /process\.env\.MERCHANT_TEST_USERNAME/) assert.match(source, /process\.env\.MERCHANT_TEST_PASSWORD/) } assert.match(client, /process\.env\.ADMIN_TEST_USERNAME/) assert.match(client, /process\.env\.ADMIN_TEST_PASSWORD/) assert.match(clientPhase2, /process\.env\.ADMIN_TEST_USERNAME/) assert.match(clientPhase2, /process\.env\.ADMIN_TEST_PASSWORD/) }) test('active scripts no longer carry the retired variables, fixed Gateway, or source password config', () => { for (const source of activeHttpScripts) { for (const variable of removedEnvironmentVariables) assert.doesNotMatch(source, new RegExp(`process\\.env\\.${variable}`)) assert.doesNotMatch(source, /8\.163\.30\.128/) } assert.doesNotMatch(pendingOrders, /const CONFIG\s*=/) assert.doesNotMatch(pendingOrders, /PASSWORD:\s*'[^']+'/) })