Skip to main content

headless_lms_server/controllers/mock_suotar/
mod.rs

1/*!
2Mock Suotar: a stand-in for the University of Helsinki Suotar API, and the test/dev control surface
3around it.
4
5Mounted at `/api/v0/mock-suotar` only when `TEST_MODE` and `USE_MOCK_SUOTAR_ENDPOINT` are both on;
6like `mock_sisu`, the gate is runtime route registration rather than `#[cfg]`. The mock writes no
7database table, and its call log holds unscrubbed fake data that must never feed `suotar_api_calls`.
8*/
9
10pub mod api;
11pub mod commands;
12pub mod control;
13pub mod default_world;
14pub mod faults;
15pub mod fixtures;
16pub mod ids;
17pub mod logic;
18pub mod scenarios;
19pub mod store;
20pub mod wire;
21pub mod world;
22
23use crate::prelude::*;
24
25/// The route cannot be reached with the flags off, so tripping this means the gate itself broke.
26pub fn assert_enabled(app_conf: &ApplicationConfiguration) {
27    assert!(app_conf.test_mode && app_conf.test_suotar);
28}
29
30pub fn _add_routes(cfg: &mut ServiceConfig) {
31    cfg.route(
32        "/persons/resolve-by-student-numbers",
33        web::post().to(api::resolve_persons),
34    )
35    .route(
36        "/enrolments/resolve",
37        web::post().to(api::resolve_enrolments),
38    )
39    .route(
40        "/enrolments/list-by-course",
41        web::post().to(api::list_by_course),
42    )
43    .route(
44        "/attainments/import",
45        web::post().to(api::import_attainments),
46    )
47    .route(
48        "/attainments/verify",
49        web::post().to(api::verify_attainments),
50    )
51    .route(
52        "/open-university-product-access-tokens/resolve",
53        web::post().to(api::resolve_product_access_tokens),
54    )
55    .service(web::scope("/control").configure(control::_add_routes));
56}