mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-15 20:05:13 +02:00
**refactor(dynamic): introduce NATS protocol emulator with publish/deliver support, enhance endpoint handling, and extend SDK compatibility for Go and Python**
This commit is contained in:
parent
a55849f1ca
commit
a12f7efc3a
7 changed files with 527 additions and 28 deletions
19
tests/dynamic_fixtures/migration/django_ops/vuln.py
Normal file
19
tests/dynamic_fixtures/migration/django_ops/vuln.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
"""Phase 21 — Django Migration.operations runtime fixture."""
|
||||
_NYX_ADAPTER_MARKER = "from django.db import migrations"
|
||||
|
||||
import os
|
||||
|
||||
|
||||
class _RunSQL:
|
||||
def __init__(self, sql):
|
||||
self.sql = sql
|
||||
|
||||
|
||||
class Migration:
|
||||
operations = [
|
||||
_RunSQL(
|
||||
"CREATE INDEX idx_"
|
||||
+ (os.environ.get("NYX_PAYLOAD") or "users")
|
||||
+ " ON users(name)"
|
||||
)
|
||||
]
|
||||
|
|
@ -395,6 +395,27 @@ fn message_handler_remaining_brokers_try_http_emulators_before_loopback() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn message_handler_nats_go_tries_real_client_before_fallbacks() {
|
||||
let spec = make_spec_with_adapter(
|
||||
Lang::Go,
|
||||
"events",
|
||||
"OnMessage",
|
||||
entry_file("nats_go"),
|
||||
"nats-go",
|
||||
);
|
||||
let h = lang::emit(&spec).expect("emit ok");
|
||||
assert!(h.source.contains("nyxTryRealNats"));
|
||||
assert!(h.source.contains("github.com/nats-io/nats.go"));
|
||||
assert!(h.source.contains("nats.Connect"));
|
||||
assert!(h.source.contains("nc.Subscribe"));
|
||||
assert!(h.source.contains("nc.Publish"));
|
||||
assert!(
|
||||
h.source.find("nyxTryRealNats").unwrap() < h.source.find("nyxFetchHttpBroker").unwrap(),
|
||||
"nats-go should try the real protocol client before the HTTP fallback"
|
||||
);
|
||||
}
|
||||
|
||||
// ── Framework-adapter assertions ──────────────────────────────────────────────
|
||||
|
||||
fn ts_language_for(lang: Lang) -> tree_sitter::Language {
|
||||
|
|
|
|||
|
|
@ -911,6 +911,9 @@ fn migration_python_harness_carries_sentinel_and_handler() {
|
|||
assert!(h.source.contains("__nyx_stub_sql_record"));
|
||||
assert!(h.source.contains("MigrationContext.configure"));
|
||||
assert!(h.source.contains("NYX_SQL_ENDPOINT"));
|
||||
assert!(h.source.contains("def create_table"));
|
||||
assert!(h.source.contains("def add_column"));
|
||||
assert!(h.source.contains("_nyx_run_django_migration_operations"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -1582,6 +1585,27 @@ fn phase_21_vuln_fixtures_confirm_via_run_spec() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn migration_django_operations_class_confirms_via_run_spec() {
|
||||
let case = RunSpecCase {
|
||||
name: "migration-django-operations",
|
||||
lang: Lang::Python,
|
||||
kind: migration_kind,
|
||||
entry_name: "Migration",
|
||||
fixture_dir: "tests/dynamic_fixtures/migration/django_ops",
|
||||
vuln_file: "vuln.py",
|
||||
benign_file: "vuln.py",
|
||||
cap: Cap::SQL_QUERY,
|
||||
};
|
||||
let Some(outcome) = run_phase21_case(case, case.vuln_file) else {
|
||||
return;
|
||||
};
|
||||
assert!(
|
||||
outcome.triggered_by.is_some(),
|
||||
"Django Migration.operations fixture must Confirm via run_spec; got {outcome:?}",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn phase_21_benign_fixtures_do_not_confirm_via_run_spec() {
|
||||
for case in RUNSPEC_CASES {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue