@teevee98/synapse-hub 0.0.0-stage → 3.8.3
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/.agents/agents/api-engineer.md +67 -0
- package/.agents/agents/failure-analyst.md +75 -0
- package/.agents/agents/live-explorer.md +70 -0
- package/.agents/agents/orchestrator.md +104 -0
- package/.agents/agents/perf-engineer.md +74 -0
- package/.agents/agents/pom-crafter.md +112 -0
- package/.agents/agents/quality-gatekeeper.md +87 -0
- package/.agents/agents/test-designer.md +73 -0
- package/.agents/agents/test-runner.md +67 -0
- package/.agents/rules/author-integrity-guard.md +33 -0
- package/.agents/rules/communication-style.md +18 -0
- package/.agents/rules/context-engineering.md +37 -0
- package/.agents/rules/git-push-protocol.md +33 -0
- package/.agents/rules/graphify.md +14 -0
- package/.agents/rules/lessons-learned.md +25 -0
- package/.agents/rules/mandatory-playwright-live.md +25 -0
- package/.agents/rules/mobile_appium_rules.md +43 -0
- package/.agents/rules/performance_testing_rules.md +35 -0
- package/.agents/rules/skill-precedence.md +29 -0
- package/.agents/rules/systematic-debugging.md +36 -0
- package/.agents/skills/actor-qa-swarm/SKILL.md +77 -0
- package/.agents/skills/actor-qa-swarm/examples/broker_sharding_sample.json +12 -0
- package/.agents/skills/agent-orchestration-multi-agent-optimize/SKILL.md +88 -0
- package/.agents/skills/agent-orchestration-multi-agent-optimize/examples/swarm_workload_config.json +15 -0
- package/.agents/skills/agentless-qa-repair/SKILL.md +69 -0
- package/.agents/skills/agentless-qa-repair/examples/healing_report_sample.json +17 -0
- package/.agents/skills/agentless-qa-repair/examples/three_phase_repair_workflow.md +40 -0
- package/.agents/skills/antigravity-test-sentinel/SKILL.md +63 -0
- package/.agents/skills/antigravity-test-sentinel/examples/dod_gate_policy.json +11 -0
- package/.agents/skills/antigravity-test-sentinel/examples/sprint_dod_enforcement.md +47 -0
- package/.agents/skills/api-network-mocking-interception/SKILL.md +142 -0
- package/.agents/skills/api-network-mocking-interception/examples/network_route_stub.json +9 -0
- package/.agents/skills/api-spec-to-e2e-matrix/SKILL.md +80 -0
- package/.agents/skills/api-spec-to-e2e-matrix/examples/sample_openapi.json +19 -0
- package/.agents/skills/architecture-decision-records/SKILL.md +64 -0
- package/.agents/skills/architecture-decision-records/examples/0001-record-architecture-decisions.md +12 -0
- package/.agents/skills/auth-session-and-cookie-manager/SKILL.md +75 -0
- package/.agents/skills/auth-session-and-cookie-manager/examples/multi_role_auth_matrix.md +70 -0
- package/.agents/skills/auth-session-and-cookie-manager/examples/storage_state_sample.json +11 -0
- package/.agents/skills/backend-load-and-stress-patterns/SKILL.md +85 -0
- package/.agents/skills/backend-load-and-stress-patterns/examples/k6_load_test_sample.js +13 -0
- package/.agents/skills/backend-load-and-stress-patterns/references/k6_load_template.js +82 -0
- package/.agents/skills/bats-testing-patterns/SKILL.md +100 -0
- package/.agents/skills/bats-testing-patterns/examples/cli_runner_test.bats +6 -0
- package/.agents/skills/bats-testing-patterns/resources/implementation-playbook.md +614 -0
- package/.agents/skills/clean-pom-crafter/SKILL.md +110 -0
- package/.agents/skills/clean-pom-crafter/examples/standard_test_case.groovy +28 -0
- package/.agents/skills/clean-pom-crafter/references/pom_patterns.groovy +138 -0
- package/.agents/skills/code-refactoring-refactor-clean/SKILL.md +64 -0
- package/.agents/skills/code-refactoring-refactor-clean/examples/refactored_page_sample.groovy +9 -0
- package/.agents/skills/code-refactoring-refactor-clean/examples/refactored_playwright_pom.ts +52 -0
- package/.agents/skills/code-refactoring-refactor-clean/resources/implementation-playbook.md +881 -0
- package/.agents/skills/consumer-driven-contract-testing/SKILL.md +147 -0
- package/.agents/skills/consumer-driven-contract-testing/examples/order_service_pact.json +45 -0
- package/.agents/skills/db-state-verifier-and-seeder/SKILL.md +123 -0
- package/.agents/skills/db-state-verifier-and-seeder/examples/db_fixture_seed.json +12 -0
- package/.agents/skills/e2e-testing-patterns/SKILL.md +103 -0
- package/.agents/skills/e2e-testing-patterns/examples/playwright_sharded_config.ts +12 -0
- package/.agents/skills/e2e-testing-patterns/resources/implementation-playbook.md +522 -0
- package/.agents/skills/event-stream-qa-orchestrator/SKILL.md +79 -0
- package/.agents/skills/event-stream-qa-orchestrator/examples/timeline_sample.jsonl +2 -0
- package/.agents/skills/failure-autopsy-and-healing/SKILL.md +66 -0
- package/.agents/skills/failure-autopsy-and-healing/examples/closed_loop_healing_walkthrough.md +48 -0
- package/.agents/skills/failure-autopsy-and-healing/examples/sample_junit_failure.xml +8 -0
- package/.agents/skills/failure-autopsy-and-healing/references/healing_matrix.md +64 -0
- package/.agents/skills/failure-autopsy-and-healing/references/qa_investigation_protocol.md +56 -0
- package/.agents/skills/failure-autopsy-and-healing/scripts/triage_failures.sh +83 -0
- package/.agents/skills/file-and-report-validator/SKILL.md +90 -0
- package/.agents/skills/file-and-report-validator/examples/sample_export_schema.json +14 -0
- package/.agents/skills/flaky-test-sentinel-and-quarantine/SKILL.md +114 -0
- package/.agents/skills/flaky-test-sentinel-and-quarantine/examples/quarantine_registry.json +11 -0
- package/.agents/skills/gherkin-to-suite/SKILL.md +103 -0
- package/.agents/skills/gherkin-to-suite/examples/checkout.feature +39 -0
- package/.agents/skills/gherkin-to-suite/examples/suite_report_sample.json +334 -0
- package/.agents/skills/github-actions-templates/SKILL.md +77 -0
- package/.agents/skills/github-actions-templates/examples/matrix_test_pipeline.yml +8 -0
- package/.agents/skills/graphify-impact-analyzer/SKILL.md +76 -0
- package/.agents/skills/graphify-impact-analyzer/examples/dependency_blast_radius.json +8 -0
- package/.agents/skills/katalon-cli-runner/SKILL.md +76 -0
- package/.agents/skills/katalon-cli-runner/examples/headless_kre_exec.sh +3 -0
- package/.agents/skills/katalon-cli-runner/references/groovy-patterns.md +209 -0
- package/.agents/skills/katalon-cli-runner/references/katalon-api.md +155 -0
- package/.agents/skills/katalon-cli-runner/references/runner_commands.md +67 -0
- package/.agents/skills/lam-script-generator/SKILL.md +123 -0
- package/.agents/skills/lam-script-generator/examples/user_story_sample.md +8 -0
- package/.agents/skills/lean-code-ladder/SKILL.md +94 -0
- package/.agents/skills/lean-code-ladder/examples/ladder_walkthrough.md +37 -0
- package/.agents/skills/lean-impact-scoreboard/SKILL.md +48 -0
- package/.agents/skills/lean-impact-scoreboard/examples/sample_benchmark_gain.md +20 -0
- package/.agents/skills/lean-impact-scoreboard/examples/sample_scoreboard.md +15 -0
- package/.agents/skills/meta-prompt-crafter/SKILL.md +107 -0
- package/.agents/skills/meta-prompt-crafter/examples/qa_prompt_template.md +35 -0
- package/.agents/skills/mipro-prompt-compiler/SKILL.md +59 -0
- package/.agents/skills/mipro-prompt-compiler/examples/compiled_module_sample.json +22 -0
- package/.agents/skills/mipro-prompt-compiler/examples/dspy_assertion_optimizer_case.md +46 -0
- package/.agents/skills/mobile-appium-som/SKILL.md +88 -0
- package/.agents/skills/mobile-appium-som/examples/BaseScreen.java +88 -0
- package/.agents/skills/mobile-appium-som/examples/LoginScreen.java +46 -0
- package/.agents/skills/mobile-appium-som/examples/TC_MobileLogin.java +43 -0
- package/.agents/skills/persistent-planning-files/SKILL.md +108 -0
- package/.agents/skills/persistent-planning-files/examples/task_plan_example.md +56 -0
- package/.agents/skills/playwright-live-interaction/SKILL.md +131 -0
- package/.agents/skills/playwright-live-interaction/examples/live_probe_script.js +5 -0
- package/.agents/skills/playwright-live-interaction/references/advanced_superpowers.md +160 -0
- package/.agents/skills/playwright-live-interaction/references/compact_accessibility_snapshots.md +75 -0
- package/.agents/skills/playwright-live-interaction/references/recipes.md +388 -0
- package/.agents/skills/playwright-live-interaction/references/swarm_orchestration.md +134 -0
- package/.agents/skills/playwright-webapp-testing/SKILL.md +93 -0
- package/.agents/skills/playwright-webapp-testing/examples/server_lifecycle_playwright.py +63 -0
- package/.agents/skills/qa-aci-interface/SKILL.md +67 -0
- package/.agents/skills/qa-aci-interface/examples/surgical_code_window_walkthrough.md +40 -0
- package/.agents/skills/qa-aci-interface/examples/surgical_edit_sample.json +12 -0
- package/.agents/skills/qa-memory-os/SKILL.md +80 -0
- package/.agents/skills/qa-memory-os/examples/archival_memory_sample.json +21 -0
- package/.agents/skills/rbt-manual-testing/SKILL.md +137 -0
- package/.agents/skills/rbt-manual-testing/examples/checkout_rbt_manual_suite.md +25 -0
- package/.agents/skills/rbt-manual-testing/references/field_validation_checklist.md +29 -0
- package/.agents/skills/repo-quality-audit/SKILL.md +68 -0
- package/.agents/skills/repo-quality-audit/examples/sample_audit_walkthrough.md +15 -0
- package/.agents/skills/repo-quality-audit/examples/sample_repo_audit.md +33 -0
- package/.agents/skills/review-spec/SKILL.md +60 -0
- package/.agents/skills/review-spec/examples/pocock_grilling_decision_rubric.md +40 -0
- package/.agents/skills/review-spec/examples/sample_spec_review.md +33 -0
- package/.agents/skills/security-dast-sentinel/SKILL.md +119 -0
- package/.agents/skills/security-dast-sentinel/examples/dast_scan_config.json +10 -0
- package/.agents/skills/security-dast-sentinel/references/AI-AND-LLM.md +113 -0
- package/.agents/skills/security-dast-sentinel/references/ATTACK-CLASSES.md +89 -0
- package/.agents/skills/security-dast-sentinel/references/dast_recipes.ts +33 -0
- package/.agents/skills/self-healing-locator/SKILL.md +86 -0
- package/.agents/skills/self-healing-locator/examples/aom_diff_sample.json +16 -0
- package/.agents/skills/senior-code-review/SKILL.md +108 -0
- package/.agents/skills/senior-code-review/examples/sample_review_walkthrough.md +29 -0
- package/.agents/skills/skillspector-security-guard/SKILL.md +57 -0
- package/.agents/skills/skillspector-security-guard/examples/audit_threat_vectors_report.json +35 -0
- package/.agents/skills/skillspector-security-guard/examples/safe_mcp_config.json +12 -0
- package/.agents/skills/surgical-coding-principles/SKILL.md +89 -0
- package/.agents/skills/surgical-coding-principles/examples/surgical_vs_scope_creep.md +46 -0
- package/.agents/skills/synthetic-test-data-generator/SKILL.md +135 -0
- package/.agents/skills/synthetic-test-data-generator/examples/idempotent_data_recipe.json +9 -0
- package/.agents/skills/systematic-debugging/SKILL.md +100 -0
- package/.agents/skills/systematic-debugging/examples/four_phase_case.md +44 -0
- package/.agents/skills/technical-debt-harvester/SKILL.md +70 -0
- package/.agents/skills/technical-debt-harvester/examples/sample_debt_ledger.md +25 -0
- package/.agents/skills/technical-debt-harvester/examples/sample_ledger_output.md +20 -0
- package/.agents/skills/test-driven-development/SKILL.md +114 -0
- package/.agents/skills/test-driven-development/examples/red_green_refactor_qa.md +78 -0
- package/.agents/skills/token-and-context-optimizer/SKILL.md +70 -0
- package/.agents/skills/token-and-context-optimizer/examples/distilled_log_sample.txt +3 -0
- package/.agents/skills/token-and-context-optimizer/references/context_engineering_guide.md +49 -0
- package/.agents/skills/tot-exploratory-testing/SKILL.md +59 -0
- package/.agents/skills/tot-exploratory-testing/examples/payment_gateway_tot_tree.json +62 -0
- package/.agents/skills/tot-exploratory-testing/examples/tot_graph_sample.json +35 -0
- package/.agents/skills/verification-before-completion/SKILL.md +100 -0
- package/.agents/skills/verification-before-completion/examples/evidence_log_example.md +46 -0
- package/.agents/skills/visual-regression-sentinel/SKILL.md +82 -0
- package/.agents/skills/visual-regression-sentinel/examples/visual_mask_rules.json +9 -0
- package/.agents/skills/wcag-audit-patterns/SKILL.md +77 -0
- package/.agents/skills/wcag-audit-patterns/examples/wcag_compliance_checklist.json +10 -0
- package/.agents/skills/wcag-audit-patterns/resources/implementation-playbook.md +541 -0
- package/.agents/skills/web-agent-gym-benchmarking/SKILL.md +62 -0
- package/.agents/skills/web-agent-gym-benchmarking/examples/benchmark_report_sample.json +22 -0
- package/.agents/skills/web-agent-gym-benchmarking/examples/enterprise_tasks_suite.json +38 -0
- package/.agents/skills/web-vitals-and-performance-profiler/SKILL.md +65 -0
- package/.agents/skills/web-vitals-and-performance-profiler/examples/cwv_budget_policy.json +6 -0
- package/.agents/skills/web-vitals-and-performance-profiler/examples/playwright_cwv_profiler_fixture.ts +118 -0
- package/.agents/templates/completion_report.md +57 -0
- package/.agents/workflows/analyze_requirement_document.md +18 -0
- package/.agents/workflows/export_testcases_excel.md +32 -0
- package/.agents/workflows/generate_combinatorial_test_data.md +28 -0
- package/.agents/workflows/generate_cross_module_test_plan.md +37 -0
- package/.agents/workflows/generate_manual_testcases_rbt.md +56 -0
- package/.agents/workflows/generate_requirements_from_website.md +25 -0
- package/.agents/workflows/generate_testcases_from_requirements.md +21 -0
- package/.agents/workflows/graphify.md +10 -0
- package/.agents/workflows/test-impact.md +15 -0
- package/.agents/workflows/verify.md +34 -0
- package/.cursor/rules/agents.mdc +16 -0
- package/.cursor/rules/language.mdc +7 -0
- package/.cursor/rules/synapse-qa.mdc +24 -0
- package/.cursorrules +27 -0
- package/.dockerignore +53 -0
- package/.pre-commit-hooks.yaml +14 -0
- package/.windsurfrules +26 -0
- package/AGENTS.md +86 -0
- package/CLAUDE.md +54 -0
- package/Dockerfile +81 -0
- package/LICENSE +52 -0
- package/NOTICE +264 -0
- package/README.en.md +171 -0
- package/README.md +170 -2
- package/action.yml +51 -0
- package/agentskills.json +16 -0
- package/bin/agent-qa.js +138 -0
- package/docker-compose.yml +74 -0
- package/docs/ARCHITECTURE.en.md +198 -0
- package/docs/ARCHITECTURE.md +199 -0
- package/docs/CI_CD_INTEGRATION.en.md +170 -0
- package/docs/CI_CD_INTEGRATION.md +170 -0
- package/docs/CLI_REFERENCE.en.md +174 -0
- package/docs/CLI_REFERENCE.md +176 -0
- package/docs/CONTRIBUTING.en.md +49 -0
- package/docs/CONTRIBUTING.md +49 -0
- package/docs/PERFORMANCE_AUDIT_REPORT.md +783 -0
- package/docs/PLUGIN_DEVELOPMENT_GUIDE.md +127 -0
- package/docs/QUALITY_GATES.en.md +118 -0
- package/docs/QUALITY_GATES.md +118 -0
- package/docs/TOKEN_QUOTA_PLAYBOOK.md +41 -0
- package/docs/TOOL_CATALOG.md +129 -0
- package/docs/adopted-ecosystem-tools.md +96 -0
- package/docs/research/EXTERNAL_AGENT_SKILLS_SURVEY.md +1062 -0
- package/docs/research/agent_skill_training_analysis.md +1358 -0
- package/docs/schemas/synapse.config.schema.json +86 -0
- package/package.json +94 -4
- package/plugin.json +31 -0
- package/scripts/generate_skill_examples.py +244 -0
- package/scripts/install.ps1 +112 -0
- package/scripts/install_global_plugin.ps1 +94 -0
- package/scripts/install_global_plugin.sh +49 -0
- package/scripts/lint_skills.ps1 +57 -0
- package/scripts/package_dist.py +337 -0
- package/scripts/setup.sh +59 -0
- package/scripts/update_hub.ps1 +19 -0
- package/scripts/update_hub.sh +15 -0
- package/skills_manifest.json +854 -0
- package/synapse.config.json +31 -0
- package/templates/PROJECT_AI_GUIDE_TEMPLATE.md +111 -0
- package/templates/PROJECT_STATE_TEMPLATE.md +20 -0
- package/templates/ai_bridges/CLAUDE.md +54 -0
- package/templates/ai_bridges/copilot-instructions.md +20 -0
- package/templates/ai_bridges/cursor_synapse_qa.mdc +24 -0
- package/templates/ai_bridges/windsurfrules +26 -0
- package/templates/ci/github-actions-synapse.yml +95 -0
- package/templates/ci/gitlab-ci-synapse.yml +16 -0
- package/templates/ui/index.html +1069 -0
- package/templates/welcome.html.tmpl +2074 -0
- package/tools/.infer_baseline.json +30 -0
- package/tools/TOOLS_RUNBOOK.md +1553 -0
- package/tools/TOOL_CATALOG.json +1769 -0
- package/tools/__init__.py +43 -0
- package/tools/_openapi_parser.py +158 -0
- package/tools/agent_canary.py +525 -0
- package/tools/agentless_patcher.py +417 -0
- package/tools/analyze_project.py +262 -0
- package/tools/api_drift_sentinel.py +208 -0
- package/tools/api_fuzzer.py +762 -0
- package/tools/author_integrity.py +190 -0
- package/tools/auto_heal.py +271 -0
- package/tools/auto_heal_reflexion.py +532 -0
- package/tools/autogen_qa_broker.py +844 -0
- package/tools/benchmark_swarm_context.py +394 -0
- package/tools/browser_helpers.js +746 -0
- package/tools/browsergym_eval.py +236 -0
- package/tools/bug_reporter.py +252 -0
- package/tools/bump_version.py +423 -0
- package/tools/cache_resolver.py +1214 -0
- package/tools/check_env.py +426 -0
- package/tools/check_version_sync.py +256 -0
- package/tools/ci_healing_hook.py +126 -0
- package/tools/cli.py +1598 -0
- package/tools/config_decoupler.py +253 -0
- package/tools/contract_validator.py +141 -0
- package/tools/core/__init__.py +70 -0
- package/tools/core/adapters.py +431 -0
- package/tools/core/circuit_breaker.py +263 -0
- package/tools/core/cli_runtime.py +66 -0
- package/tools/core/file_lock.py +159 -0
- package/tools/core/i18n.py +394 -0
- package/tools/core/memory_bus.py +905 -0
- package/tools/core/process_supervisor.py +332 -0
- package/tools/core/telemetry.py +329 -0
- package/tools/count_tokens.py +1267 -0
- package/tools/create_mock_docx.py +104 -0
- package/tools/dashboard_generator.py +2403 -0
- package/tools/db_sandbox.py +675 -0
- package/tools/debt_harvester.py +237 -0
- package/tools/distill_log.py +161 -0
- package/tools/dspy_qa_signatures.py +356 -0
- package/tools/e2e_flow_prober.py +132 -0
- package/tools/export_postman_collection.py +945 -0
- package/tools/flaky_detector.py +389 -0
- package/tools/fsm_enforcer.py +450 -0
- package/tools/fsm_middleware.py +401 -0
- package/tools/fuzz_payloads.py +197 -0
- package/tools/generate_allure_report.py +88 -0
- package/tools/generate_api_matrix.py +193 -0
- package/tools/generate_jmx_plan.py +1322 -0
- package/tools/generate_sbom.py +252 -0
- package/tools/generate_tc_from_story.py +203 -0
- package/tools/generate_test_reports.py +133 -0
- package/tools/generate_tool_catalog.py +482 -0
- package/tools/gherkin_suite.py +758 -0
- package/tools/git_pre_commit_guard.py +298 -0
- package/tools/goldfish_review.py +366 -0
- package/tools/heal/__init__.py +28 -0
- package/tools/heal_pr_automator.py +220 -0
- package/tools/heuristic_locator_matcher.py +351 -0
- package/tools/hub_publisher.py +623 -0
- package/tools/humanize_linter.py +438 -0
- package/tools/infer_linter.py +977 -0
- package/tools/init_config.py +306 -0
- package/tools/interview_story.py +116 -0
- package/tools/jira_sync.py +566 -0
- package/tools/jtl_analyzer.py +474 -0
- package/tools/lint/__init__.py +30 -0
- package/tools/lint_ai_docs.py +374 -0
- package/tools/lookup_tc.py +165 -0
- package/tools/lookup_xpath.py +167 -0
- package/tools/matrix_sharder.py +148 -0
- package/tools/mcp/__init__.py +18 -0
- package/tools/mcp_docx_server.ps1 +13 -0
- package/tools/mcp_docx_server.py +851 -0
- package/tools/mcp_excel_server.ps1 +13 -0
- package/tools/mcp_excel_server.py +441 -0
- package/tools/mcp_server.py +725 -0
- package/tools/md_to_xlsx.py +327 -0
- package/tools/micro_mutator.py +887 -0
- package/tools/mipro_assertion_tuner.py +210 -0
- package/tools/network_mock_shield.py +311 -0
- package/tools/newman_analyzer.py +384 -0
- package/tools/omni_emitter.py +579 -0
- package/tools/omni_parser.py +450 -0
- package/tools/omni_transpiler.py +168 -0
- package/tools/openxml_guard.py +438 -0
- package/tools/output_formatter.py +182 -0
- package/tools/package_release.py +325 -0
- package/tools/perf/__init__.py +24 -0
- package/tools/pinpoint_failure.py +190 -0
- package/tools/project_state.py +171 -0
- package/tools/qa_event_stream.py +358 -0
- package/tools/repo_map.py +346 -0
- package/tools/report/__init__.py +32 -0
- package/tools/reversible_sandbox.py +344 -0
- package/tools/safety_firewall.py +437 -0
- package/tools/security_coverage_ledger.py +538 -0
- package/tools/security_scanner.py +229 -0
- package/tools/senior_code_review.py +393 -0
- package/tools/setup_project.py +770 -0
- package/tools/skill_collision_guard.py +304 -0
- package/tools/skill_profiles.py +217 -0
- package/tools/skill_vault.py +481 -0
- package/tools/skillspector.py +1278 -0
- package/tools/smart_visual_masker.py +132 -0
- package/tools/spec_drift_sentinel.py +438 -0
- package/tools/swe_qa_aci.py +369 -0
- package/tools/synapse_observer.py +485 -0
- package/tools/synapse_qa_bench.py +190 -0
- package/tools/sync_agent_rules.py +274 -0
- package/tools/telemetry_correlator.py +397 -0
- package/tools/template_excel_exporter.py +514 -0
- package/tools/templates/jmeter-distributed/README.md +54 -0
- package/tools/templates/jmeter-distributed/docker-compose.yml +83 -0
- package/tools/test_impact.py +419 -0
- package/tools/test_memory_os.py +462 -0
- package/tools/textgrad_mutation_optimizer.py +237 -0
- package/tools/tms_sync_bridge.py +834 -0
- package/tools/tot_exploratory_tester.py +239 -0
- package/tools/trace_data_flow.py +240 -0
- package/tools/traffic_session_converter.py +256 -0
- package/tools/trend_analytics.py +314 -0
- package/tools/ui_server.py +401 -0
- package/tools/universal_ir.py +488 -0
- package/tools/update_sentinel.py +383 -0
- package/tools/validate_groovy_scripts.py +173 -0
- package/tools/verify_all.py +1271 -0
- package/tools/visual_diff_canvas.py +143 -0
- package/tools/visual_som_helper.py +550 -0
- package/tools/watch_mode.py +308 -0
- package/tools/wcag_audit.py +239 -0
- package/tools/welcome_page.py +290 -0
|
@@ -0,0 +1,945 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
tools/export_postman_collection.py — Enterprise API to Postman Collection v2.1.0 Exporter (Postman Pinnacle)
|
|
5
|
+
-----------------------------------------------------------------------------------------------------------
|
|
6
|
+
Converts OpenAPI / Swagger specifications, JSON endpoint schemas, HTTP Archives (HAR),
|
|
7
|
+
or Natural Language Domain archetypes into production-ready Postman Collections v2.1.0.
|
|
8
|
+
|
|
9
|
+
Pinnacle Enterprise Capabilities:
|
|
10
|
+
1. Multi-Format Ingestion: OpenAPI 3.0 / Swagger 2.0, HAR traffic traces, or Zero-Input Domain Synthesis.
|
|
11
|
+
2. Autonomous Zero-Input Synthesis: Generates complete multi-tier API collections from scratch
|
|
12
|
+
when no input files exist (`--domain [ecommerce|banking|saas]`).
|
|
13
|
+
3. Pre-request Scripts: Dynamic request timestamps, UUIDs, nonces, and automated Bearer Auth headers.
|
|
14
|
+
4. Test Scripts (pm.test):
|
|
15
|
+
- Expected HTTP Status assertions.
|
|
16
|
+
- SLA Latency assertions (< 1000ms).
|
|
17
|
+
- Response Content-Type JSON header validation.
|
|
18
|
+
- Autonomous Token & ID Extractor (`pm.environment.set('bearerToken', ...)`).
|
|
19
|
+
- Native AJV JSON Schema Validation (`pm.response.to.have.jsonSchema(schema)`).
|
|
20
|
+
5. Companion Environment Generator: Outputs `postman_environment.json` with base URLs and variables.
|
|
21
|
+
6. Data-Driven Testing (DDT) Suite: Outputs companion `test_data.csv` for Newman matrix execution.
|
|
22
|
+
7. 100% UTF-8 No BOM, portable, Newman CLI and CI/CD compatible.
|
|
23
|
+
|
|
24
|
+
Usage:
|
|
25
|
+
# 1. From existing OpenAPI / Swagger
|
|
26
|
+
python tools/export_postman_collection.py --spec swagger.json -o collection.json --env-output env.json
|
|
27
|
+
|
|
28
|
+
# 2. Zero-Input Autonomous Generation (No input files!)
|
|
29
|
+
python tools/export_postman_collection.py --domain ecommerce -o ecom_collection.json --ddt-output ecom_data.csv
|
|
30
|
+
python tools/export_postman_collection.py --domain banking -o banking_collection.json --env-output banking_env.json
|
|
31
|
+
|
|
32
|
+
# 3. From browser network trace (.har)
|
|
33
|
+
python tools/export_postman_collection.py --har traffic.har -o collection.json
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
import os
|
|
37
|
+
import sys
|
|
38
|
+
import json
|
|
39
|
+
import re
|
|
40
|
+
import uuid
|
|
41
|
+
import csv
|
|
42
|
+
import argparse
|
|
43
|
+
from typing import Dict, Any, List, Optional
|
|
44
|
+
from urllib.parse import urlparse
|
|
45
|
+
|
|
46
|
+
# Enforce UTF-8 stdout encoding for Windows/macOS/Linux console compatibility
|
|
47
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
48
|
+
try:
|
|
49
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
50
|
+
sys.stderr.reconfigure(encoding="utf-8")
|
|
51
|
+
except Exception:
|
|
52
|
+
pass
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def generate_uuid() -> str:
|
|
56
|
+
return str(uuid.uuid4())
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def build_pre_request_script() -> List[str]:
|
|
60
|
+
"""Generates standard Postman Pre-request script lines."""
|
|
61
|
+
return [
|
|
62
|
+
"// Auto-generated Pre-request Script by Synapse-Hub",
|
|
63
|
+
"// 1. Dynamic Timestamp & Correlation ID generation",
|
|
64
|
+
"pm.variables.set('req_timestamp', new Date().toISOString());",
|
|
65
|
+
"pm.variables.set('req_nonce', Math.random().toString(36).substring(2, 12));",
|
|
66
|
+
"pm.variables.set('correlation_id', 'CORR-' + pm.variables.get('req_nonce'));",
|
|
67
|
+
"",
|
|
68
|
+
"// 2. Automated Bearer Token Injection if present in environment",
|
|
69
|
+
"var token = pm.environment.get('bearerToken') || pm.collectionVariables.get('bearerToken');",
|
|
70
|
+
"if (token && !pm.request.headers.has('Authorization')) {",
|
|
71
|
+
" pm.request.headers.add({ key: 'Authorization', value: 'Bearer ' + token });",
|
|
72
|
+
"}"
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def build_test_script(
|
|
77
|
+
expected_status: int = 200,
|
|
78
|
+
max_time_ms: int = 1000,
|
|
79
|
+
response_schema: Optional[Dict[str, Any]] = None
|
|
80
|
+
) -> List[str]:
|
|
81
|
+
"""Generates comprehensive Postman Test script lines with AJV JSON Schema assertion."""
|
|
82
|
+
lines = [
|
|
83
|
+
"// Auto-generated Test Assertions by Synapse-Hub",
|
|
84
|
+
f"// 1. Assert Status Code is {expected_status}",
|
|
85
|
+
f"pm.test('Status code is {expected_status}', function () {{",
|
|
86
|
+
f" pm.expect(pm.response.code).to.eql({expected_status});",
|
|
87
|
+
"});",
|
|
88
|
+
"",
|
|
89
|
+
f"// 2. Assert SLA Latency (< {max_time_ms}ms)",
|
|
90
|
+
f"pm.test('Response time is below {max_time_ms}ms SLA', function () {{",
|
|
91
|
+
f" pm.expect(pm.response.responseTime).to.be.below({max_time_ms});",
|
|
92
|
+
"});",
|
|
93
|
+
"",
|
|
94
|
+
"// 3. Assert Content-Type JSON Header",
|
|
95
|
+
"pm.test('Response header Content-Type is JSON', function () {",
|
|
96
|
+
" if (pm.response.code !== 204) {",
|
|
97
|
+
" pm.expect(pm.response.headers.get('Content-Type')).to.include('application/json');",
|
|
98
|
+
" }",
|
|
99
|
+
"});",
|
|
100
|
+
"",
|
|
101
|
+
"// 4. Autonomous Token / Entity ID Extraction & Session Chaining",
|
|
102
|
+
"if (pm.response.code >= 200 && pm.response.code < 300) {",
|
|
103
|
+
" try {",
|
|
104
|
+
" var jsonBody = pm.response.json();",
|
|
105
|
+
" // Auto-extract JWT / OAuth tokens",
|
|
106
|
+
" var authToken = jsonBody.token || jsonBody.access_token || (jsonBody.data && (jsonBody.data.token || jsonBody.data.access_token));",
|
|
107
|
+
" if (authToken) {",
|
|
108
|
+
" pm.environment.set('bearerToken', authToken);",
|
|
109
|
+
" pm.collectionVariables.set('bearerToken', authToken);",
|
|
110
|
+
" console.log('[Synapse-Hub] Captured dynamic bearerToken: ' + authToken.substring(0, 15) + '...');",
|
|
111
|
+
" }",
|
|
112
|
+
" // Auto-extract newly created ID",
|
|
113
|
+
" var entityId = jsonBody.id || jsonBody.code || (jsonBody.data && (jsonBody.data.id || jsonBody.data.code));",
|
|
114
|
+
" if (entityId) {",
|
|
115
|
+
" pm.environment.set('lastCreatedId', String(entityId));",
|
|
116
|
+
" console.log('[Synapse-Hub] Captured lastCreatedId: ' + entityId);",
|
|
117
|
+
" }",
|
|
118
|
+
" } catch (e) {",
|
|
119
|
+
" // Response is non-JSON or empty body",
|
|
120
|
+
" }",
|
|
121
|
+
"}"
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
# 5. AJV Native JSON Schema Validation
|
|
125
|
+
if response_schema:
|
|
126
|
+
schema_clean = json.dumps(response_schema, ensure_ascii=False)
|
|
127
|
+
lines.extend([
|
|
128
|
+
"",
|
|
129
|
+
"// 5. AJV JSON Schema Contract Validation",
|
|
130
|
+
"pm.test('Response conforms to OpenAPI JSON Schema', function () {",
|
|
131
|
+
f" var schema = {schema_clean};",
|
|
132
|
+
" pm.response.to.have.jsonSchema(schema);",
|
|
133
|
+
"});"
|
|
134
|
+
])
|
|
135
|
+
|
|
136
|
+
return lines
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def mock_schema_payload(schema: Dict[str, Any], depth: int = 0) -> Any:
|
|
140
|
+
"""Recursively generates realistic mock JSON payload from OpenAPI schema."""
|
|
141
|
+
if depth > 3 or not schema:
|
|
142
|
+
return {}
|
|
143
|
+
|
|
144
|
+
stype = schema.get("type", "object")
|
|
145
|
+
|
|
146
|
+
if stype == "string":
|
|
147
|
+
fmt = schema.get("format", "")
|
|
148
|
+
if fmt == "email":
|
|
149
|
+
return "{{$randomEmail}}"
|
|
150
|
+
elif fmt == "uuid":
|
|
151
|
+
return "{{$guid}}"
|
|
152
|
+
elif fmt in ("date-time", "date"):
|
|
153
|
+
return "{{$isoTimestamp}}"
|
|
154
|
+
return schema.get("example") or "AUTO_{{$randomAlphaNumeric}}"
|
|
155
|
+
|
|
156
|
+
elif stype in ("integer", "number"):
|
|
157
|
+
return schema.get("example") or schema.get("minimum", 100)
|
|
158
|
+
|
|
159
|
+
elif stype == "boolean":
|
|
160
|
+
return schema.get("example", True)
|
|
161
|
+
|
|
162
|
+
elif stype == "array":
|
|
163
|
+
items_schema = schema.get("items", {})
|
|
164
|
+
return [mock_schema_payload(items_schema, depth + 1)]
|
|
165
|
+
|
|
166
|
+
elif stype == "object":
|
|
167
|
+
props = schema.get("properties", {})
|
|
168
|
+
obj = {}
|
|
169
|
+
for p_name, p_schema in props.items():
|
|
170
|
+
obj[p_name] = mock_schema_payload(p_schema, depth + 1)
|
|
171
|
+
return obj
|
|
172
|
+
|
|
173
|
+
return {}
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def parse_openapi_spec(spec_data: Dict[str, Any], base_url_override: Optional[str] = None) -> Dict[str, Any]:
|
|
177
|
+
"""Parses OpenAPI 2.0 / 3.0 dictionary into a Postman Collection v2.1.0 structure."""
|
|
178
|
+
info_dict = spec_data.get("info", {})
|
|
179
|
+
col_name = info_dict.get("title", "Enterprise API Collection")
|
|
180
|
+
col_desc = info_dict.get("description", "Auto-generated Postman Collection from OpenAPI / Swagger")
|
|
181
|
+
|
|
182
|
+
# Determine Base URL
|
|
183
|
+
if base_url_override:
|
|
184
|
+
base_url_default = base_url_override
|
|
185
|
+
elif "servers" in spec_data and spec_data["servers"]:
|
|
186
|
+
base_url_default = spec_data["servers"][0].get("url", "https://api.staging.enterprise.local")
|
|
187
|
+
elif "host" in spec_data:
|
|
188
|
+
schemes = spec_data.get("schemes", ["https"])
|
|
189
|
+
base_url_default = f"{schemes[0]}://{spec_data['host']}{spec_data.get('basePath', '')}"
|
|
190
|
+
else:
|
|
191
|
+
base_url_default = "https://api.staging.enterprise.local"
|
|
192
|
+
|
|
193
|
+
# Postman root structure
|
|
194
|
+
collection: Dict[str, Any] = {
|
|
195
|
+
"info": {
|
|
196
|
+
"_postman_id": generate_uuid(),
|
|
197
|
+
"name": col_name,
|
|
198
|
+
"description": col_desc,
|
|
199
|
+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
|
200
|
+
},
|
|
201
|
+
"variable": [
|
|
202
|
+
{
|
|
203
|
+
"key": "baseUrl",
|
|
204
|
+
"value": base_url_default,
|
|
205
|
+
"type": "string"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"key": "bearerToken",
|
|
209
|
+
"value": "",
|
|
210
|
+
"type": "string"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"key": "lastCreatedId",
|
|
214
|
+
"value": "1",
|
|
215
|
+
"type": "string"
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
"item": []
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
folders: Dict[str, List[Dict[str, Any]]] = {}
|
|
222
|
+
paths = spec_data.get("paths", {})
|
|
223
|
+
|
|
224
|
+
for path, path_item in paths.items():
|
|
225
|
+
for method in ("get", "post", "put", "patch", "delete"):
|
|
226
|
+
if method not in path_item:
|
|
227
|
+
continue
|
|
228
|
+
|
|
229
|
+
op = path_item[method]
|
|
230
|
+
summary = op.get("summary") or f"{method.upper()} {path}"
|
|
231
|
+
tags = op.get("tags", ["Default"])
|
|
232
|
+
tag_name = tags[0] if tags else "Default"
|
|
233
|
+
|
|
234
|
+
# Parse headers
|
|
235
|
+
headers = [
|
|
236
|
+
{"key": "Content-Type", "value": "application/json", "type": "text"},
|
|
237
|
+
{"key": "Accept", "value": "application/json", "type": "text"}
|
|
238
|
+
]
|
|
239
|
+
|
|
240
|
+
# Parse Query Parameters
|
|
241
|
+
query_params = []
|
|
242
|
+
for p in op.get("parameters", []):
|
|
243
|
+
if p.get("in") == "query":
|
|
244
|
+
query_params.append({
|
|
245
|
+
"key": p.get("name"),
|
|
246
|
+
"value": str(p.get("example", "")),
|
|
247
|
+
"description": p.get("description", "")
|
|
248
|
+
})
|
|
249
|
+
elif p.get("in") == "header":
|
|
250
|
+
headers.append({
|
|
251
|
+
"key": p.get("name"),
|
|
252
|
+
"value": str(p.get("example", "")),
|
|
253
|
+
"type": "text"
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
# Parse Request Body
|
|
257
|
+
body_dict = None
|
|
258
|
+
if method in ("post", "put", "patch"):
|
|
259
|
+
req_body = op.get("requestBody", {})
|
|
260
|
+
content = req_body.get("content", {})
|
|
261
|
+
json_content = content.get("application/json", {})
|
|
262
|
+
schema = json_content.get("schema")
|
|
263
|
+
|
|
264
|
+
if not schema:
|
|
265
|
+
for p in op.get("parameters", []):
|
|
266
|
+
if p.get("in") == "body":
|
|
267
|
+
schema = p.get("schema")
|
|
268
|
+
break
|
|
269
|
+
|
|
270
|
+
if schema:
|
|
271
|
+
payload = mock_schema_payload(schema)
|
|
272
|
+
body_dict = {
|
|
273
|
+
"mode": "raw",
|
|
274
|
+
"raw": json.dumps(payload, indent=2, ensure_ascii=False),
|
|
275
|
+
"options": {"raw": {"language": "json"}}
|
|
276
|
+
}
|
|
277
|
+
else:
|
|
278
|
+
body_dict = {
|
|
279
|
+
"mode": "raw",
|
|
280
|
+
"raw": "{}",
|
|
281
|
+
"options": {"raw": {"language": "json"}}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
# URL decomposition and path parameterization
|
|
285
|
+
raw_path = path
|
|
286
|
+
path_variables = []
|
|
287
|
+
normalized_segments = []
|
|
288
|
+
for seg in path.strip("/").split("/"):
|
|
289
|
+
if not seg:
|
|
290
|
+
continue
|
|
291
|
+
match = re.match(r"^\{([a-zA-Z0-9_-]+)\}$", seg)
|
|
292
|
+
if match:
|
|
293
|
+
param_name = match.group(1)
|
|
294
|
+
raw_path = raw_path.replace(f"{{{param_name}}}", f":{param_name}")
|
|
295
|
+
normalized_segments.append(f":{param_name}")
|
|
296
|
+
default_val = "{{lastCreatedId}}" if param_name.lower() in ("id", "entityid", "orderid") else f"{{{{{param_name}}}}}"
|
|
297
|
+
path_variables.append({
|
|
298
|
+
"key": param_name,
|
|
299
|
+
"value": default_val,
|
|
300
|
+
"description": f"URL Path variable {param_name}"
|
|
301
|
+
})
|
|
302
|
+
else:
|
|
303
|
+
normalized_segments.append(seg)
|
|
304
|
+
|
|
305
|
+
url_obj: Dict[str, Any] = {
|
|
306
|
+
"raw": f"{{{{baseUrl}}}}{raw_path}",
|
|
307
|
+
"host": ["{{baseUrl}}"],
|
|
308
|
+
"path": normalized_segments
|
|
309
|
+
}
|
|
310
|
+
if path_variables:
|
|
311
|
+
url_obj["variable"] = path_variables
|
|
312
|
+
if query_params:
|
|
313
|
+
url_obj["query"] = query_params
|
|
314
|
+
|
|
315
|
+
# Status code and response schema for assertion
|
|
316
|
+
responses = op.get("responses", {})
|
|
317
|
+
expected_status = 200
|
|
318
|
+
for code_str in responses.keys():
|
|
319
|
+
if code_str.isdigit():
|
|
320
|
+
expected_status = int(code_str)
|
|
321
|
+
break
|
|
322
|
+
|
|
323
|
+
resp_info = responses.get(str(expected_status), {}) or responses.get("200", {}) or responses.get("201", {})
|
|
324
|
+
resp_schema = resp_info.get("content", {}).get("application/json", {}).get("schema")
|
|
325
|
+
if not resp_schema and "schema" in resp_info:
|
|
326
|
+
resp_schema = resp_info["schema"]
|
|
327
|
+
|
|
328
|
+
postman_request: Dict[str, Any] = {
|
|
329
|
+
"name": summary,
|
|
330
|
+
"event": [
|
|
331
|
+
{
|
|
332
|
+
"listen": "prerequest",
|
|
333
|
+
"script": {
|
|
334
|
+
"type": "text/javascript",
|
|
335
|
+
"exec": build_pre_request_script()
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"listen": "test",
|
|
340
|
+
"script": {
|
|
341
|
+
"type": "text/javascript",
|
|
342
|
+
"exec": build_test_script(
|
|
343
|
+
expected_status=expected_status,
|
|
344
|
+
response_schema=resp_schema
|
|
345
|
+
)
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
],
|
|
349
|
+
"request": {
|
|
350
|
+
"method": method.upper(),
|
|
351
|
+
"header": headers,
|
|
352
|
+
"url": url_obj,
|
|
353
|
+
"description": op.get("description", "")
|
|
354
|
+
},
|
|
355
|
+
"response": []
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if body_dict:
|
|
359
|
+
postman_request["request"]["body"] = body_dict
|
|
360
|
+
|
|
361
|
+
if tag_name not in folders:
|
|
362
|
+
folders[tag_name] = []
|
|
363
|
+
folders[tag_name].append(postman_request)
|
|
364
|
+
|
|
365
|
+
# Nest grouped requests into folder items
|
|
366
|
+
for folder_name, req_list in folders.items():
|
|
367
|
+
collection["item"].append({
|
|
368
|
+
"name": folder_name,
|
|
369
|
+
"item": req_list,
|
|
370
|
+
"description": f"Endpoints grouped under {folder_name}"
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
return collection
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def parse_har_file(har_data: Dict[str, Any], base_url_override: Optional[str] = None) -> Dict[str, Any]:
|
|
377
|
+
"""Parses HTTP Archive (.har) into a Postman Collection v2.1.0."""
|
|
378
|
+
entries = har_data.get("log", {}).get("entries", [])
|
|
379
|
+
collection_name = "HAR Recorded API Collection"
|
|
380
|
+
|
|
381
|
+
base_url_default = base_url_override or "https://api.staging.enterprise.local"
|
|
382
|
+
|
|
383
|
+
collection: Dict[str, Any] = {
|
|
384
|
+
"info": {
|
|
385
|
+
"_postman_id": generate_uuid(),
|
|
386
|
+
"name": collection_name,
|
|
387
|
+
"description": "Generated from HTTP Archive Network Trace",
|
|
388
|
+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
|
389
|
+
},
|
|
390
|
+
"variable": [
|
|
391
|
+
{"key": "baseUrl", "value": base_url_default, "type": "string"},
|
|
392
|
+
{"key": "bearerToken", "value": "", "type": "string"},
|
|
393
|
+
{"key": "lastCreatedId", "value": "1", "type": "string"}
|
|
394
|
+
],
|
|
395
|
+
"item": []
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
requests_by_host: Dict[str, List[Dict[str, Any]]] = {}
|
|
399
|
+
|
|
400
|
+
for idx, e in enumerate(entries, 1):
|
|
401
|
+
req = e.get("request", {})
|
|
402
|
+
resp = e.get("response", {})
|
|
403
|
+
raw_url = req.get("url", "/")
|
|
404
|
+
method = req.get("method", "GET").upper()
|
|
405
|
+
p = urlparse(raw_url)
|
|
406
|
+
host = p.netloc or "Default"
|
|
407
|
+
|
|
408
|
+
headers = []
|
|
409
|
+
for h in req.get("headers", []):
|
|
410
|
+
name = h.get("name", "")
|
|
411
|
+
if name.lower() not in ("cookie", "host", "content-length"):
|
|
412
|
+
headers.append({"key": name, "value": h.get("value", ""), "type": "text"})
|
|
413
|
+
|
|
414
|
+
path_segments = [seg for seg in p.path.strip("/").split("/") if seg]
|
|
415
|
+
url_obj = {
|
|
416
|
+
"raw": f"{{{{baseUrl}}}}{p.path}" + (f"?{p.query}" if p.query else ""),
|
|
417
|
+
"host": ["{{baseUrl}}"],
|
|
418
|
+
"path": path_segments
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
body_dict = None
|
|
422
|
+
post_data = req.get("postData", {})
|
|
423
|
+
if post_data.get("text"):
|
|
424
|
+
body_dict = {
|
|
425
|
+
"mode": "raw",
|
|
426
|
+
"raw": post_data["text"],
|
|
427
|
+
"options": {"raw": {"language": "json"}}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
expected_status = resp.get("status", 200) or 200
|
|
431
|
+
postman_item: Dict[str, Any] = {
|
|
432
|
+
"name": f"[{method}] {p.path or '/'}",
|
|
433
|
+
"event": [
|
|
434
|
+
{
|
|
435
|
+
"listen": "prerequest",
|
|
436
|
+
"script": {"type": "text/javascript", "exec": build_pre_request_script()}
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"listen": "test",
|
|
440
|
+
"script": {"type": "text/javascript", "exec": build_test_script(expected_status=expected_status)}
|
|
441
|
+
}
|
|
442
|
+
],
|
|
443
|
+
"request": {
|
|
444
|
+
"method": method,
|
|
445
|
+
"header": headers,
|
|
446
|
+
"url": url_obj,
|
|
447
|
+
"description": f"Recorded step {idx}"
|
|
448
|
+
},
|
|
449
|
+
"response": []
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
if body_dict:
|
|
453
|
+
postman_item["request"]["body"] = body_dict
|
|
454
|
+
|
|
455
|
+
if host not in requests_by_host:
|
|
456
|
+
requests_by_host[host] = []
|
|
457
|
+
requests_by_host[host].append(postman_item)
|
|
458
|
+
|
|
459
|
+
for host, reqs in requests_by_host.items():
|
|
460
|
+
collection["item"].append({
|
|
461
|
+
"name": f"Host: {host}",
|
|
462
|
+
"item": reqs,
|
|
463
|
+
"description": f"Recorded requests against {host}"
|
|
464
|
+
})
|
|
465
|
+
|
|
466
|
+
return collection
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
def generate_postman_environment(name: str = "Enterprise-Staging-Env", base_url: str = "https://api.staging.enterprise.local") -> Dict[str, Any]:
|
|
470
|
+
"""Generates companion Postman environment JSON for Newman/CLI integration."""
|
|
471
|
+
return {
|
|
472
|
+
"id": generate_uuid(),
|
|
473
|
+
"name": name,
|
|
474
|
+
"values": [
|
|
475
|
+
{"key": "baseUrl", "value": base_url, "enabled": True},
|
|
476
|
+
{"key": "bearerToken", "value": "", "type": "secret", "enabled": True},
|
|
477
|
+
{"key": "lastCreatedId", "value": "1", "enabled": True},
|
|
478
|
+
{"key": "adminUser", "value": "qa_admin@enterprise.local", "enabled": True},
|
|
479
|
+
{"key": "adminPass", "value": "SecretVault#2026", "type": "secret", "enabled": True}
|
|
480
|
+
],
|
|
481
|
+
"_postman_variable_scope": "environment"
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
def generate_ddt_dataset(domain: str = "ecommerce") -> List[Dict[str, Any]]:
|
|
486
|
+
"""Generates companion Data-Driven Testing (DDT) matrix for Newman execution."""
|
|
487
|
+
if domain == "banking":
|
|
488
|
+
return [
|
|
489
|
+
{"scenario": "Valid Domestic Transfer", "sender": "ACC-101", "recipient": "ACC-902", "amount": 500000, "expectedStatus": 201},
|
|
490
|
+
{"scenario": "Zero Amount Boundary", "sender": "ACC-101", "recipient": "ACC-902", "amount": 0, "expectedStatus": 400},
|
|
491
|
+
{"scenario": "Negative Amount Attack", "sender": "ACC-101", "recipient": "ACC-902", "amount": -150000, "expectedStatus": 400},
|
|
492
|
+
{"scenario": "Exceed Daily Balance Limit", "sender": "ACC-101", "recipient": "ACC-902", "amount": 999999999, "expectedStatus": 422},
|
|
493
|
+
{"scenario": "Invalid Recipient Format", "sender": "ACC-101", "recipient": "<script>alert(1)</script>", "expectedStatus": 400}
|
|
494
|
+
]
|
|
495
|
+
elif domain == "saas":
|
|
496
|
+
return [
|
|
497
|
+
{"scenario": "Standard Member Creation", "username": "member_valid", "role": "MEMBER", "priority": 10, "expectedStatus": 201},
|
|
498
|
+
{"scenario": "Admin Role Assignment", "username": "admin_chief", "role": "ADMIN", "priority": 1, "expectedStatus": 201},
|
|
499
|
+
{"scenario": "Empty Username Boundary", "username": "", "role": "MEMBER", "priority": 10, "expectedStatus": 400},
|
|
500
|
+
{"scenario": "SQLi Injection Probe", "username": "' OR '1'='1' --", "role": "MEMBER", "priority": 10, "expectedStatus": 400},
|
|
501
|
+
{"scenario": "Invalid Role Privilege", "username": "intruder_user", "role": "SUPER_ROOT_UNAUTHORIZED", "priority": 99, "expectedStatus": 403}
|
|
502
|
+
]
|
|
503
|
+
else: # ecommerce default
|
|
504
|
+
return [
|
|
505
|
+
{"scenario": "Valid Catalog Creation", "code": "SKU_AUTO_2026", "name": "Enterprise Quantum Server", "priority": 10, "expectedStatus": 201},
|
|
506
|
+
{"scenario": "Short Code Boundary (< 3 chars)", "code": "A1", "name": "Invalid Item", "priority": 5, "expectedStatus": 400},
|
|
507
|
+
{"scenario": "Max Length Code Boundary", "code": "SKU_MAX_CHARS_990000", "name": "Max Length Product", "priority": 50, "expectedStatus": 201},
|
|
508
|
+
{"scenario": "Empty Product Name", "code": "SKU_VALID_02", "name": "", "priority": 20, "expectedStatus": 400},
|
|
509
|
+
{"scenario": "XSS Script Body Injection", "code": "SKU_XSS_03", "name": "<script>alert('pwned')</script>", "priority": 1, "expectedStatus": 400}
|
|
510
|
+
]
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
def get_domain_spec(domain: str = "ecommerce") -> Dict[str, Any]:
|
|
514
|
+
"""Autonomous Zero-Input Domain Spec Synthesizer."""
|
|
515
|
+
if domain == "banking":
|
|
516
|
+
return {
|
|
517
|
+
"openapi": "3.0.3",
|
|
518
|
+
"info": {
|
|
519
|
+
"title": "Enterprise Banking & Fund Transfer API",
|
|
520
|
+
"version": "2.4.0",
|
|
521
|
+
"description": "Production Banking API with OAuth2, Idempotent Transfers, and Audit Queries"
|
|
522
|
+
},
|
|
523
|
+
"servers": [{"url": "https://api.banking.staging.local"}],
|
|
524
|
+
"paths": {
|
|
525
|
+
"/api/v1/auth/token": {
|
|
526
|
+
"post": {
|
|
527
|
+
"tags": ["Authentication"],
|
|
528
|
+
"summary": "Obtain Bearer JWT Token",
|
|
529
|
+
"requestBody": {
|
|
530
|
+
"content": {
|
|
531
|
+
"application/json": {
|
|
532
|
+
"schema": {
|
|
533
|
+
"type": "object",
|
|
534
|
+
"required": ["clientId", "clientSecret"],
|
|
535
|
+
"properties": {
|
|
536
|
+
"clientId": {"type": "string", "example": "bank_admin"},
|
|
537
|
+
"clientSecret": {"type": "string", "example": "SecretVault#2026"}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
"responses": {
|
|
544
|
+
"200": {
|
|
545
|
+
"description": "Token granted",
|
|
546
|
+
"content": {
|
|
547
|
+
"application/json": {
|
|
548
|
+
"schema": {
|
|
549
|
+
"type": "object",
|
|
550
|
+
"required": ["token", "tokenType", "expiresIn"],
|
|
551
|
+
"properties": {
|
|
552
|
+
"token": {"type": "string", "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.fake"},
|
|
553
|
+
"tokenType": {"type": "string", "example": "Bearer"},
|
|
554
|
+
"expiresIn": {"type": "integer", "example": 3600}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
"/api/v1/accounts/me": {
|
|
564
|
+
"get": {
|
|
565
|
+
"tags": ["Account Management"],
|
|
566
|
+
"summary": "Get Account Balance & Profile",
|
|
567
|
+
"responses": {
|
|
568
|
+
"200": {
|
|
569
|
+
"description": "Account details retrieved",
|
|
570
|
+
"content": {
|
|
571
|
+
"application/json": {
|
|
572
|
+
"schema": {
|
|
573
|
+
"type": "object",
|
|
574
|
+
"required": ["accountNumber", "balance", "currency"],
|
|
575
|
+
"properties": {
|
|
576
|
+
"accountNumber": {"type": "string", "example": "ACC-889922"},
|
|
577
|
+
"balance": {"type": "number", "example": 25000000.0},
|
|
578
|
+
"currency": {"type": "string", "example": "VND"}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
"/api/v1/transfers": {
|
|
588
|
+
"post": {
|
|
589
|
+
"tags": ["Fund Transfers"],
|
|
590
|
+
"summary": "Execute Idempotent Fund Transfer",
|
|
591
|
+
"requestBody": {
|
|
592
|
+
"content": {
|
|
593
|
+
"application/json": {
|
|
594
|
+
"schema": {
|
|
595
|
+
"type": "object",
|
|
596
|
+
"required": ["recipientAccount", "amount", "idempotencyKey"],
|
|
597
|
+
"properties": {
|
|
598
|
+
"recipientAccount": {"type": "string", "example": "ACC-990011"},
|
|
599
|
+
"amount": {"type": "number", "example": 500000.0},
|
|
600
|
+
"idempotencyKey": {"type": "string", "example": "{{$guid}}"},
|
|
601
|
+
"remark": {"type": "string", "example": "Payment for invoice"}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
"responses": {
|
|
608
|
+
"201": {
|
|
609
|
+
"description": "Transfer queued or completed",
|
|
610
|
+
"content": {
|
|
611
|
+
"application/json": {
|
|
612
|
+
"schema": {
|
|
613
|
+
"type": "object",
|
|
614
|
+
"required": ["id", "status", "transactionRef"],
|
|
615
|
+
"properties": {
|
|
616
|
+
"id": {"type": "string", "example": "TX-998822"},
|
|
617
|
+
"status": {"type": "string", "example": "COMPLETED"},
|
|
618
|
+
"transactionRef": {"type": "string", "example": "REF-AUTO-2026"}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
"/api/v1/transfers/{id}": {
|
|
628
|
+
"get": {
|
|
629
|
+
"tags": ["Fund Transfers"],
|
|
630
|
+
"summary": "Audit Transfer Status by ID",
|
|
631
|
+
"parameters": [
|
|
632
|
+
{"name": "id", "in": "path", "required": True, "example": "{{lastCreatedId}}"}
|
|
633
|
+
],
|
|
634
|
+
"responses": {
|
|
635
|
+
"200": {
|
|
636
|
+
"description": "Transfer status verified",
|
|
637
|
+
"content": {
|
|
638
|
+
"application/json": {
|
|
639
|
+
"schema": {
|
|
640
|
+
"type": "object",
|
|
641
|
+
"required": ["id", "status", "amount"],
|
|
642
|
+
"properties": {
|
|
643
|
+
"id": {"type": "string", "example": "TX-998822"},
|
|
644
|
+
"status": {"type": "string", "example": "COMPLETED"},
|
|
645
|
+
"amount": {"type": "number", "example": 500000.0}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
elif domain == "saas":
|
|
657
|
+
return {
|
|
658
|
+
"openapi": "3.0.3",
|
|
659
|
+
"info": {
|
|
660
|
+
"title": "Enterprise SaaS Tenant & User RBAC API",
|
|
661
|
+
"version": "1.8.0",
|
|
662
|
+
"description": "Multi-Tenant SaaS Management Suite"
|
|
663
|
+
},
|
|
664
|
+
"servers": [{"url": "https://api.saas.staging.local"}],
|
|
665
|
+
"paths": {
|
|
666
|
+
"/api/v1/auth/login": {
|
|
667
|
+
"post": {
|
|
668
|
+
"tags": ["Identity"],
|
|
669
|
+
"summary": "Tenant Admin Login",
|
|
670
|
+
"requestBody": {
|
|
671
|
+
"content": {
|
|
672
|
+
"application/json": {
|
|
673
|
+
"schema": {
|
|
674
|
+
"type": "object",
|
|
675
|
+
"required": ["tenantId", "username", "password"],
|
|
676
|
+
"properties": {
|
|
677
|
+
"tenantId": {"type": "string", "example": "tenant_enterprise"},
|
|
678
|
+
"username": {"type": "string", "example": "admin"},
|
|
679
|
+
"password": {"type": "string", "example": "SecretPass#2026"}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
"responses": {
|
|
686
|
+
"200": {
|
|
687
|
+
"description": "Login successful",
|
|
688
|
+
"content": {
|
|
689
|
+
"application/json": {
|
|
690
|
+
"schema": {
|
|
691
|
+
"type": "object",
|
|
692
|
+
"required": ["token", "role"],
|
|
693
|
+
"properties": {
|
|
694
|
+
"token": {"type": "string", "example": "jwt.tenant.token"},
|
|
695
|
+
"role": {"type": "string", "example": "TENANT_ADMIN"}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
"/api/v1/users": {
|
|
705
|
+
"get": {
|
|
706
|
+
"tags": ["User Directory"],
|
|
707
|
+
"summary": "List Active Tenant Users",
|
|
708
|
+
"responses": {"200": {"description": "Users list"}}
|
|
709
|
+
},
|
|
710
|
+
"post": {
|
|
711
|
+
"tags": ["User Directory"],
|
|
712
|
+
"summary": "Provision New Tenant Member",
|
|
713
|
+
"requestBody": {
|
|
714
|
+
"content": {
|
|
715
|
+
"application/json": {
|
|
716
|
+
"schema": {
|
|
717
|
+
"type": "object",
|
|
718
|
+
"required": ["email", "role"],
|
|
719
|
+
"properties": {
|
|
720
|
+
"email": {"type": "string", "example": "user_auto@tenant.com"},
|
|
721
|
+
"role": {"type": "string", "example": "MEMBER"}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
"responses": {
|
|
728
|
+
"201": {
|
|
729
|
+
"description": "User created",
|
|
730
|
+
"content": {
|
|
731
|
+
"application/json": {
|
|
732
|
+
"schema": {
|
|
733
|
+
"type": "object",
|
|
734
|
+
"required": ["id", "email"],
|
|
735
|
+
"properties": {
|
|
736
|
+
"id": {"type": "string", "example": "USR-101"},
|
|
737
|
+
"email": {"type": "string", "example": "user_auto@tenant.com"}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
},
|
|
746
|
+
"/api/v1/users/{id}": {
|
|
747
|
+
"delete": {
|
|
748
|
+
"tags": ["User Directory"],
|
|
749
|
+
"summary": "Deprovision Member (Teardown Cleanup)",
|
|
750
|
+
"parameters": [{"name": "id", "in": "path", "required": True, "example": "{{lastCreatedId}}"}],
|
|
751
|
+
"responses": {"204": {"description": "User deprovisioned"}}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
else: # E-commerce default
|
|
757
|
+
return {
|
|
758
|
+
"openapi": "3.0.3",
|
|
759
|
+
"info": {
|
|
760
|
+
"title": "Enterprise E-Commerce Core API",
|
|
761
|
+
"version": "3.2.0",
|
|
762
|
+
"description": "Enterprise E-Commerce Commerce Engine API with Auth, Search, Cart, Order, and Teardown"
|
|
763
|
+
},
|
|
764
|
+
"servers": [{"url": "https://api.staging.enterprise.local"}],
|
|
765
|
+
"paths": {
|
|
766
|
+
"/api/v1/auth/login": {
|
|
767
|
+
"post": {
|
|
768
|
+
"tags": ["Authentication"],
|
|
769
|
+
"summary": "User Authentication (Login)",
|
|
770
|
+
"requestBody": {
|
|
771
|
+
"content": {
|
|
772
|
+
"application/json": {
|
|
773
|
+
"schema": {
|
|
774
|
+
"type": "object",
|
|
775
|
+
"required": ["username", "password"],
|
|
776
|
+
"properties": {
|
|
777
|
+
"username": {"type": "string", "example": "admin"},
|
|
778
|
+
"password": {"type": "string", "example": "SecretVault#2026"}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
"responses": {
|
|
785
|
+
"200": {
|
|
786
|
+
"description": "Successful Login",
|
|
787
|
+
"content": {
|
|
788
|
+
"application/json": {
|
|
789
|
+
"schema": {
|
|
790
|
+
"type": "object",
|
|
791
|
+
"required": ["token", "tokenType"],
|
|
792
|
+
"properties": {
|
|
793
|
+
"token": {"type": "string", "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.fake"},
|
|
794
|
+
"tokenType": {"type": "string", "example": "Bearer"}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
"/api/v1/catalogs": {
|
|
804
|
+
"get": {
|
|
805
|
+
"tags": ["Catalog Service"],
|
|
806
|
+
"summary": "Search Product Catalogs",
|
|
807
|
+
"parameters": [
|
|
808
|
+
{"name": "query", "in": "query", "example": "server"},
|
|
809
|
+
{"name": "limit", "in": "query", "example": "20"}
|
|
810
|
+
],
|
|
811
|
+
"responses": {
|
|
812
|
+
"200": {
|
|
813
|
+
"description": "Catalogs search result",
|
|
814
|
+
"content": {
|
|
815
|
+
"application/json": {
|
|
816
|
+
"schema": {
|
|
817
|
+
"type": "object",
|
|
818
|
+
"required": ["items", "total"],
|
|
819
|
+
"properties": {
|
|
820
|
+
"items": {"type": "array", "items": {"type": "object"}},
|
|
821
|
+
"total": {"type": "integer", "example": 42}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
},
|
|
829
|
+
"post": {
|
|
830
|
+
"tags": ["Catalog Service"],
|
|
831
|
+
"summary": "Create Product Item",
|
|
832
|
+
"requestBody": {
|
|
833
|
+
"content": {
|
|
834
|
+
"application/json": {
|
|
835
|
+
"schema": {
|
|
836
|
+
"type": "object",
|
|
837
|
+
"required": ["code", "name"],
|
|
838
|
+
"properties": {
|
|
839
|
+
"code": {"type": "string", "example": "SKU_AUTO_2026"},
|
|
840
|
+
"name": {"type": "string", "example": "Enterprise Quantum Server"},
|
|
841
|
+
"priority": {"type": "integer", "example": 10}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
},
|
|
847
|
+
"responses": {
|
|
848
|
+
"201": {
|
|
849
|
+
"description": "Product created",
|
|
850
|
+
"content": {
|
|
851
|
+
"application/json": {
|
|
852
|
+
"schema": {
|
|
853
|
+
"type": "object",
|
|
854
|
+
"required": ["id", "code"],
|
|
855
|
+
"properties": {
|
|
856
|
+
"id": {"type": "string", "example": "PRD-998811"},
|
|
857
|
+
"code": {"type": "string", "example": "SKU_AUTO_2026"}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
},
|
|
866
|
+
"/api/v1/catalogs/{id}": {
|
|
867
|
+
"delete": {
|
|
868
|
+
"tags": ["Catalog Service"],
|
|
869
|
+
"summary": "Delete Catalog Item (Idempotent Teardown)",
|
|
870
|
+
"parameters": [
|
|
871
|
+
{"name": "id", "in": "path", "required": True, "example": "{{lastCreatedId}}"}
|
|
872
|
+
],
|
|
873
|
+
"responses": {"204": {"description": "Item deleted"}}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
def main():
|
|
881
|
+
parser = argparse.ArgumentParser(
|
|
882
|
+
description="Export OpenAPI, HAR, or Zero-Input Domain Synthesis to Postman Collection v2.1.0."
|
|
883
|
+
)
|
|
884
|
+
parser.add_argument("--spec", "-s", help="Path to OpenAPI / Swagger JSON specification file.")
|
|
885
|
+
parser.add_argument("--har", help="Path to HTTP Archive (.har) recording file.")
|
|
886
|
+
parser.add_argument("--domain", choices=["ecommerce", "banking", "saas"], default="ecommerce", help="Zero-input domain synthesizer template. Default: ecommerce.")
|
|
887
|
+
parser.add_argument("--base-url", "-b", help="Override base URL for {{baseUrl}} parameter.")
|
|
888
|
+
parser.add_argument("--output", "-o", help="Target output Postman Collection file path (.json).")
|
|
889
|
+
parser.add_argument("--env-output", help="Optional companion Postman Environment output file (.json).")
|
|
890
|
+
parser.add_argument("--ddt-output", help="Optional companion Data-Driven Testing (DDT) CSV file for Newman.")
|
|
891
|
+
parser.add_argument("--sample", action="store_true", help="Generate sample collection using domain synthesizer.")
|
|
892
|
+
|
|
893
|
+
args = parser.parse_args()
|
|
894
|
+
|
|
895
|
+
# Determine data source
|
|
896
|
+
if args.har and os.path.exists(args.har):
|
|
897
|
+
with open(args.har, "r", encoding="utf-8") as f:
|
|
898
|
+
har_data = json.load(f)
|
|
899
|
+
collection = parse_har_file(har_data, base_url_override=args.base_url)
|
|
900
|
+
active_domain = "har"
|
|
901
|
+
elif args.spec and os.path.exists(args.spec):
|
|
902
|
+
with open(args.spec, "r", encoding="utf-8") as f:
|
|
903
|
+
spec_data = json.load(f)
|
|
904
|
+
collection = parse_openapi_spec(spec_data, base_url_override=args.base_url)
|
|
905
|
+
active_domain = "spec"
|
|
906
|
+
else:
|
|
907
|
+
# Autonomous Zero-Input Synthesis (User provided no file!)
|
|
908
|
+
spec_data = get_domain_spec(args.domain)
|
|
909
|
+
collection = parse_openapi_spec(spec_data, base_url_override=args.base_url)
|
|
910
|
+
active_domain = args.domain
|
|
911
|
+
print(f"✨ [ZERO-INPUT SYNTHESIS] Synthesized complete '{args.domain.upper()}' Enterprise API Suite from scratch!")
|
|
912
|
+
|
|
913
|
+
target_output = args.output or f"{active_domain}_collection.json"
|
|
914
|
+
out_dir = os.path.dirname(os.path.abspath(target_output))
|
|
915
|
+
if out_dir and not os.path.exists(out_dir):
|
|
916
|
+
os.makedirs(out_dir, exist_ok=True)
|
|
917
|
+
|
|
918
|
+
with open(target_output, "w", encoding="utf-8") as f:
|
|
919
|
+
json.dump(collection, f, indent=2, ensure_ascii=False)
|
|
920
|
+
print(f"✅ [POSTMAN EXPORT] Successfully created Postman Collection v2.1.0: {target_output}")
|
|
921
|
+
print("🛡️ Embedded: Pre-request Nonce & Auth | SLA Tests (< 1000ms) | AJV JSON Schema Validation | Token Chaining")
|
|
922
|
+
|
|
923
|
+
# Optional Companion Environment
|
|
924
|
+
env_file = args.env_output or (os.path.splitext(target_output)[0] + "_env.json")
|
|
925
|
+
base_u = args.base_url or "https://api.staging.enterprise.local"
|
|
926
|
+
env_dict = generate_postman_environment(name=f"Synapse-{active_domain.capitalize()}-Env", base_url=base_u)
|
|
927
|
+
with open(env_file, "w", encoding="utf-8") as f:
|
|
928
|
+
json.dump(env_dict, f, indent=2, ensure_ascii=False)
|
|
929
|
+
print(f"🌐 [ENVIRONMENT EXPORT] Successfully created Postman Environment: {env_file}")
|
|
930
|
+
|
|
931
|
+
# Optional Companion Data-Driven Testing (DDT) CSV
|
|
932
|
+
if args.ddt_output or args.sample:
|
|
933
|
+
ddt_file = args.ddt_output or (os.path.splitext(target_output)[0] + "_ddt.csv")
|
|
934
|
+
dataset = generate_ddt_dataset(args.domain if active_domain in ("ecommerce", "banking", "saas") else "ecommerce")
|
|
935
|
+
if dataset:
|
|
936
|
+
with open(ddt_file, "w", encoding="utf-8", newline="") as f:
|
|
937
|
+
writer = csv.DictWriter(f, fieldnames=list(dataset[0].keys()))
|
|
938
|
+
writer.writeheader()
|
|
939
|
+
writer.writerows(dataset)
|
|
940
|
+
print(f"📊 [DDT EXPORT] Successfully created Data-Driven Testing CSV: {ddt_file}")
|
|
941
|
+
print(f"🚀 Execution Command: newman run \"{target_output}\" -e \"{env_file}\" -d \"{ddt_file}\"")
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
if __name__ == "__main__":
|
|
945
|
+
main()
|