6ef4c40e29
Two-repo monorepo for an offline FUT backend inspired by SPT. openfut-core: game-independent REST API backend (Axum, SQLite, SQLx) - 19 API endpoints: auth, profiles, clubs, cards, packs, squads, objectives, SBCs, match rewards, NPC market, statistics - JSON-driven card/pack/objective/SBC data (fully moddable) - SQLx migrations, weighted pack generator, SBC validation engine - 5 integration tests passing openfut-bridge: FIFA 23 traffic proxy + reverse-engineering scaffold - Catch-all HTTP proxy with request capture to captures/ - Known-route mapper (FUT paths → Core API calls) - Placeholder responses for unknown endpoints - Admin endpoints: captures, unknown endpoint list - 4 unit tests passing cargo fmt ✓ cargo clippy -D warnings ✓ cargo test ✓ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
49 lines
1.3 KiB
Rust
49 lines
1.3 KiB
Rust
use openfut_bridge::{capture::CapturedRequest, mapper::map_to_core};
|
|
|
|
#[test]
|
|
fn test_known_endpoint_maps_to_core() {
|
|
let mapping = map_to_core("POST", "/ut/auth");
|
|
assert!(mapping.is_some());
|
|
let m = mapping.unwrap();
|
|
assert_eq!(m.core_path, "/auth/local");
|
|
}
|
|
|
|
#[test]
|
|
fn test_unknown_endpoint_returns_none() {
|
|
let mapping = map_to_core("GET", "/ut/game/fut/some/unknown/path");
|
|
assert!(mapping.is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn test_capture_serializes_cleanly() {
|
|
let capture = CapturedRequest::new(
|
|
"GET",
|
|
"/ut/game/fut/user/settings",
|
|
None,
|
|
vec![("user-agent".into(), "FIFA23/1.0".into())],
|
|
None,
|
|
);
|
|
|
|
let json = serde_json::to_string(&capture).expect("serialize");
|
|
let back: CapturedRequest = serde_json::from_str(&json).expect("deserialize");
|
|
assert_eq!(back.path, "/ut/game/fut/user/settings");
|
|
assert_eq!(back.method, "GET");
|
|
assert!(back.mapped_to_core.is_none());
|
|
assert!(back.response_status.is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn test_capture_with_response() {
|
|
let capture = CapturedRequest::new(
|
|
"POST",
|
|
"/ut/auth",
|
|
None,
|
|
vec![],
|
|
Some(r#"{"token":"abc"}"#.into()),
|
|
)
|
|
.with_response(200, Some(r#"{"status":"ok"}"#.into()));
|
|
|
|
assert_eq!(capture.response_status, Some(200));
|
|
assert!(capture.response_body.is_some());
|
|
}
|