hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits
| 1 | //! Shared helpers for the router-level test binaries (`integration`, |
| 2 | //! `persistence`, and friends). Drives an `axum::Router` in-process via |
| 3 | //! `tower::ServiceExt::oneshot`, over a **per-test pair of Postgres |
| 4 | //! databases** — control plus demo school, cloned from the shared school |
| 5 | //! template by `database::init_test_tenants`, dropped with the test. |
| 6 | |
| 7 | |
| 8 | use PathBuf; |
| 9 | use OnceLock; |
| 10 | |
| 11 | use Router; |
| 12 | use Body; |
| 13 | use ; |
| 14 | use AiBridge; |
| 15 | use Database; |
| 16 | use ModuleSet; |
| 17 | use RateLimitConfig; |
| 18 | use AppState; |
| 19 | use Metrics; |
| 20 | use ; |
| 21 | use ; |
| 22 | use ; |
| 23 | use TempDir; |
| 24 | use ServiceExt; |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | /// A well-formed id for a row that exists nowhere — the canonical ghost |
| 34 | /// parent every FK-refusal test aims at. Replaces the ULID literal |
| 35 | /// `01J8XZ0K3Q8G7X2M4N5P6R7S8T` the suites used before the UUID v7 port. |
| 36 | pub const GHOST_ID: &str = "019732e3-7b00-7000-8000-00000000dead"; |
| 37 | |
| 38 | /// A second well-formed, never-minted id, for "look this up, expect a miss". |
| 39 | /// Replaces `01ZZZZZZZZZZZZZZZZZZZZZZZZ`. |
| 40 | pub const ABSENT_ID: &str = "019732e3-7b00-7000-8000-00000000eeee"; |
| 41 | |
| 42 | /// One shared blob directory for every app in this test process. Blob names |
| 43 | /// are per-row ids, so apps never collide; the static keeps the `TempDir` |
| 44 | /// (and so the directory) alive for the whole run. |
| 45 | static FILES_DIR: = new; |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | /// A router plus a handle to its demo school's database. Tests that need to |
| 55 | /// grant roles use the handle to seed them directly — the app's only role |
| 56 | /// bootstrap path is out-of-band, exactly like production's manual SQL. |
| 57 | pub async |
| 58 | |
| 59 | |
| 60 | |
| 61 | /// [`app_and_db`] plus the registry behind it, for the suites whose subject is |
| 62 | /// tenancy itself (a second school, a suspension, the builder surface). |
| 63 | pub async |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | /// The hyphenated uuid a test label names. `demo` and `beta` are pinned to |
| 69 | /// the ids [`init_test_tenants`] / [`deployment_with`] register; a value that |
| 70 | /// is already a uuid is returned unchanged. |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | /// Where the demo school's blobs land: one directory per school under |
| 88 | /// `FILES_PATH`, created on the school's first upload. |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | /// The raw session token out of a `session=<school>.<token>` cookie value — |
| 96 | /// what a test needs when it writes a session row by hand. |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | /// A test deployment: the registry, plus the demo school's handle. For the |
| 106 | /// suites that build their own `AppState` instead of using [`app_and_db`]. |
| 107 | /// (The name outlived the in-memory engine; the shape is what the suites |
| 108 | /// bind to.) |
| 109 | pub async |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | /// The demo school's handle out of a registry. |
| 116 | pub async |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | /// The same router, with the AI bridge wired into its state. `build_router` |
| 124 | /// arms the bridge's api-read handle whenever `ai` is `Some`, so this is the |
| 125 | /// bootstrap that makes a QUIC service's reads dispatch into a real router. |
| 126 | pub async |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | /// [`app_with_ai`] plus the registry behind it, for the suites whose subject is |
| 132 | /// an AI service reading *across* schools. |
| 133 | pub async |
| 134 | |
| 135 | |
| 136 | |
| 137 | /// The one bootstrap: a fresh test deployment (control database + the demo |
| 138 | /// school), a router over it, and the demo school's handle — which is what |
| 139 | /// every suite means by "the database", since that is where users and rows |
| 140 | /// live. |
| 141 | async |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | /// The same router with the caller's instruments, so a test can read back what |
| 163 | /// the HTTP edge recorded without touching the process-global meter provider. |
| 164 | pub async |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | /// Attribute keys that would carry personal data out of the process. KVKK |
| 170 | /// analysis fixed this list: telemetry names the school and the route, never |
| 171 | /// the person, their address, or what they sent. Shared so the HTTP edge |
| 172 | /// (`telemetry.rs`) and the AI bridge (`ai_bridge.rs`) are held to one list. |
| 173 | /// |
| 174 | /// `server.address` is deliberately absent: that is our own bind address, not |
| 175 | /// a caller's. |
| 176 | pub const FORBIDDEN_TELEMETRY_KEYS: & = & |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | ; |
| 192 | |
| 193 | /// [`FORBIDDEN_TELEMETRY_KEYS`] plus the two header prefixes — any captured |
| 194 | /// request or response header is personal data by default. |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | /// A router backed by a fresh per-test Postgres deployment. |
| 202 | pub async |
| 203 | |
| 204 | |
| 205 | |
| 206 | /// Force `username`'s role, mirroring the manual `UPDATE app_user SET |
| 207 | /// role=...` bootstrap. Roles are read fresh per request, so this takes |
| 208 | /// effect at once. |
| 209 | pub async |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | /// Register (password `secret1`), promote to `role`, then log in. Returns the |
| 219 | /// session `Cookie` value. |
| 220 | pub async |
| 221 | |
| 222 | |
| 223 | |
| 224 | /// [`login_as`] in a named school. `db` must be that school's own handle — the |
| 225 | /// role is written where the user was created, which is what makes two schools |
| 226 | /// able to hold the same username independently. |
| 227 | pub async |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | /// Send one request through `app`. `cookie` is a raw `Cookie` header value. |
| 278 | pub async |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | /// Send one request with a raw body and content type; returns the raw |
| 321 | /// response (status, headers, body bytes) — for driving the file endpoints. |
| 322 | pub async |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | const MULTIPART_BOUNDARY: &str = "hezarfen-test-boundary"; |
| 352 | |
| 353 | /// A `multipart/form-data` body with a single `file` part. |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | /// Upload `bytes` as a multipart file to `uri` (no assertion). Parses the |
| 368 | /// JSON body like `send`. |
| 369 | pub async |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | /// Upload `bytes` as a file onto a personal `note` (no assertion). |
| 401 | pub async |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | /// Upload `bytes` as a file onto a course `note` (no assertion). |
| 421 | pub async |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | /// Register (password `secret1`) then log in; returns the session `Cookie` value. |
| 441 | pub async |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | /// The `items` array of a paginated list envelope (`{items, total, limit, |
| 468 | /// offset}`) — the shape every `GET` list endpoint returns. Panics if `v` |
| 469 | /// isn't such an envelope, so a test that points it at the wrong body fails |
| 470 | /// loudly. |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | /// The `total` count from a paginated list envelope. |
| 478 | |
| 479 | |
| 480 | |
| 481 | |
| 482 | /// The caller's own user id via `GET /auth/me`. |
| 483 | pub async |
| 484 | |
| 485 | |
| 486 | |
| 487 | |
| 488 | |
| 489 | /// Create a **catalog** course as `cookie` (asserts 201); returns its id. |
| 490 | /// |
| 491 | /// The catalog is the title and the subjects hung off it. What one şube teaches |
| 492 | /// is an *instance* (`POST /classes/{class}/instances`), and enrollment, exams, |
| 493 | /// sessions and homework key on that instance, never on this row — |
| 494 | /// [`taught`] is the fixture that mints the whole stack. |
| 495 | pub async |
| 496 | |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | |
| 507 | |
| 508 | /// Create a subject inside `course` as `cookie` (asserts 201); returns its id. |
| 509 | /// Every exam question must be tagged with one of its course's subjects. |
| 510 | pub async |
| 511 | |
| 512 | |
| 513 | |
| 514 | |
| 515 | |
| 516 | |
| 517 | |
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | |
| 527 | |
| 528 | |
| 529 | |
| 530 | |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 | |
| 554 | |
| 555 | |
| 556 | |
| 557 | |
| 558 | |
| 559 | // ---- the academic fixture --------------------------------------------------- |
| 560 | // |
| 561 | // The K12 remodel made the class×course **instance** the academic anchor: a |
| 562 | // şube (class) teaches a catalog course, and that pair is one `class_course` row |
| 563 | // every exam, session, homework, roster and karne keys on. A suite that needs a |
| 564 | // roster to exist therefore mints three rows, not one — and the şube is school |
| 565 | // structure, so whoever creates it holds manager+ (the course itself stays the |
| 566 | // teacher's: the catalog is teacher-owned). |
| 567 | |
| 568 | /// The bounds every fixture calendar uses: one year-wide span, fixed so two |
| 569 | /// tests cannot race a clock. |
| 570 | pub const FIXTURE_YEAR_STARTS_AT: i64 = 1_750_000_000_000; |
| 571 | pub const FIXTURE_YEAR_ENDS_AT: i64 = 1_800_000_000_000; |
| 572 | |
| 573 | /// Create an academic year as `staff` (asserts 201); returns its id. `staff` |
| 574 | /// must hold manager+. |
| 575 | pub async |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | |
| 582 | |
| 583 | |
| 584 | |
| 585 | |
| 586 | |
| 587 | |
| 588 | |
| 589 | |
| 590 | |
| 591 | |
| 592 | |
| 593 | |
| 594 | |
| 595 | |
| 596 | |
| 597 | /// The school's newest academic year, minted when it has none yet — a fixture |
| 598 | /// needs a calendar without the test having to name one. |
| 599 | pub async |
| 600 | |
| 601 | |
| 602 | |
| 603 | |
| 604 | |
| 605 | |
| 606 | |
| 607 | |
| 608 | /// Create a dönem inside `year` as `staff` (asserts 201); returns its id. |
| 609 | /// Dönem names repeat freely, so a fixture may mint one per call. |
| 610 | pub async |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | |
| 621 | |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | /// Create a class (şube) as `staff` (asserts 201); returns its id. `body` |
| 634 | /// carries everything but the name: `year`, `teacher_id`, `grade_level` |
| 635 | /// (defaulting to rung 9 when the caller does not name one). |
| 636 | pub async |
| 637 | |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | |
| 643 | |
| 644 | |
| 645 | |
| 646 | |
| 647 | |
| 648 | |
| 649 | |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | |
| 655 | /// Put `user_id` in `class` as `staff` (asserts 201). The pump enrolls them into |
| 656 | /// every instance the şube already carries, so a pumped roster row names the |
| 657 | /// şube as its `source` — [`enroll`] is the hand-placed row that does not. |
| 658 | pub async |
| 659 | |
| 660 | |
| 661 | |
| 662 | |
| 663 | |
| 664 | |
| 665 | |
| 666 | |
| 667 | |
| 668 | |
| 669 | |
| 670 | |
| 671 | |
| 672 | |
| 673 | |
| 674 | |
| 675 | /// Attach `course` to `class` as `staff` (asserts 201); returns the **instance |
| 676 | /// id** — the anchor every exam, session, homework and enrollment keys on. |
| 677 | /// `staff` needs catalog rights on the course (its creator, or manager+). |
| 678 | pub async |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | |
| 688 | |
| 689 | |
| 690 | |
| 691 | |
| 692 | |
| 693 | |
| 694 | |
| 695 | |
| 696 | /// A catalog course as one şube teaches it: the stack a suite needs before |
| 697 | /// anyone can be enrolled, examined or marked. |
| 698 | |
| 699 | |
| 700 | |
| 701 | |
| 702 | |
| 703 | |
| 704 | |
| 705 | |
| 706 | |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | /// [`taught_under`] with the caller as the şube's homeroom teacher too — for a |
| 713 | /// suite whose actor is one manager/admin account. |
| 714 | pub async |
| 715 | |
| 716 | |
| 717 | |
| 718 | /// Mint a whole academic stack for `title`: a year (reused when the school has |
| 719 | /// one), a dönem, the catalog course — created by `homeroom`, so a |
| 720 | /// creator-gated catalog route stays theirs — a şube naming `homeroom` as its |
| 721 | /// sınıf öğretmeni, and the instance the pair forms. |
| 722 | /// |
| 723 | /// `staff` must hold manager+ (a şube is school structure) and `homeroom` |
| 724 | /// teacher+; passing the same cookie twice is the one-account fixture. Naming |
| 725 | /// the homeroom teacher is what lets a plain `teacher` cookie act on the |
| 726 | /// instance, because `ensure_instance_teacher` passes for the şube's own |
| 727 | /// öğretmen as well as for manager+. |
| 728 | pub async |
| 729 | |
| 730 | |
| 731 | |
| 732 | |
| 733 | |
| 734 | |
| 735 | |
| 736 | |
| 737 | |
| 738 | |
| 739 | |
| 740 | |
| 741 | |
| 742 | |
| 743 | |
| 744 | |
| 745 | |
| 746 | |
| 747 | |
| 748 | |
| 749 | |
| 750 | /// Create an exam inside `instance` as `cookie` (asserts 201); returns its id. |
| 751 | /// `term` is the dönem the marks count into (`GET /terms`); the exam's weight in |
| 752 | /// the instance's average comes from its kind (settings). |
| 753 | pub async |
| 754 | |
| 755 | |
| 756 | |
| 757 | |
| 758 | |
| 759 | |
| 760 | |
| 761 | |
| 762 | |
| 763 | |
| 764 | |
| 765 | |
| 766 | |
| 767 | |
| 768 | |
| 769 | |
| 770 | |
| 771 | |
| 772 | |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | /// Create an exam inside `instance` from a full JSON body (no assertion) — for |
| 779 | /// exercising the scheduling fields and their validation. The body must carry |
| 780 | /// its own `term`. |
| 781 | pub async |
| 782 | |
| 783 | |
| 784 | |
| 785 | |
| 786 | |
| 787 | |
| 788 | |
| 789 | |
| 790 | |
| 791 | |
| 792 | /// One homework-create send with the subject-gate retry: a `subject_id` the |
| 793 | /// section's resolved syllabus does not carry is refused, and the writer — |
| 794 | /// who holds a right over the instance (the very gate the homework write |
| 795 | /// passed) — takes the topic onto the section's own set through the instance |
| 796 | /// door and retries once. Every other refusal comes back untouched. |
| 797 | async |
| 798 | |
| 799 | |
| 800 | |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | |
| 806 | |
| 807 | |
| 808 | |
| 809 | |
| 810 | |
| 811 | |
| 812 | |
| 813 | |
| 814 | |
| 815 | |
| 816 | |
| 817 | |
| 818 | |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 | |
| 824 | |
| 825 | |
| 826 | |
| 827 | |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | |
| 833 | |
| 834 | |
| 835 | |
| 836 | |
| 837 | |
| 838 | |
| 839 | |
| 840 | |
| 841 | |
| 842 | /// Take `subject` onto the section's own syllabus through the instance door — |
| 843 | /// the D10 gate, the same right the question and homework writers hold. |
| 844 | /// Idempotent: a subject already in the set re-answers 200. |
| 845 | pub async |
| 846 | |
| 847 | |
| 848 | |
| 849 | |
| 850 | |
| 851 | |
| 852 | |
| 853 | |
| 854 | |
| 855 | |
| 856 | |
| 857 | |
| 858 | |
| 859 | |
| 860 | |
| 861 | /// Create a homework inside `instance` as `cookie` (asserts 201); returns its |
| 862 | /// id. Tagged with `subject` (required — every homework carries one of its |
| 863 | /// course's subjects) and due at `due_at` (unix-millis; must not lie past the |
| 864 | /// 60s grace). Whole-instance audience; use [`create_homework_with`] for an |
| 865 | /// `assigned` subset. |
| 866 | pub async |
| 867 | |
| 868 | |
| 869 | |
| 870 | |
| 871 | |
| 872 | |
| 873 | |
| 874 | |
| 875 | |
| 876 | |
| 877 | |
| 878 | |
| 879 | |
| 880 | |
| 881 | |
| 882 | |
| 883 | |
| 884 | |
| 885 | |
| 886 | |
| 887 | |
| 888 | |
| 889 | |
| 890 | /// Create a homework inside `instance` from a full JSON body (no assertion) — |
| 891 | /// for exercising the `assigned` subset and the validation rejects. The |
| 892 | /// subject-gate retry applies here too; every other refusal comes back as |
| 893 | /// the server answered it. |
| 894 | pub async |
| 895 | |
| 896 | |
| 897 | |
| 898 | /// Create a lesson session inside `instance` as `cookie` (asserts 201); returns |
| 899 | /// its id. The session's teacher defaults to the caller. |
| 900 | pub async |
| 901 | |
| 902 | |
| 903 | |
| 904 | |
| 905 | |
| 906 | |
| 907 | |
| 908 | |
| 909 | |
| 910 | |
| 911 | |
| 912 | |
| 913 | |
| 914 | |
| 915 | |
| 916 | |
| 917 | |
| 918 | /// Drop `user_id` from `instance`'s roster as `cookie` (asserts 204). Deleting a |
| 919 | /// catalog course is refused while instances still teach it, so cascade tests |
| 920 | /// detach instances and empty rosters first. |
| 921 | pub async |
| 922 | |
| 923 | |
| 924 | |
| 925 | |
| 926 | |
| 927 | |
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | |
| 933 | |
| 934 | |
| 935 | |
| 936 | |
| 937 | |
| 938 | /// Enroll `user_id` into `instance` as `cookie` (asserts 200) — the roster row a |
| 939 | /// human placed, carrying no şube, so no şube sweep may take it back. |
| 940 | pub async |
| 941 | |
| 942 | |
| 943 | |
| 944 | |
| 945 | |
| 946 | |
| 947 | |
| 948 | |
| 949 | |
| 950 | |
| 951 | |
| 952 | // ---- multi-school deployments --------------------------------------------- |
| 953 | // |
| 954 | // The probes whose subject is tenancy itself — cross-school isolation, |
| 955 | // suspension, school deletion — build a deployment with more schools than |
| 956 | // the demo one. Under database-per-school tenancy there is no separate |
| 957 | // "remote" mode to exercise: production *is* this shape, and a second |
| 958 | // deployment is a second `database::init_test_tenants()` away. (The |
| 959 | // `surreal start` remote lane this section used to hold died with the |
| 960 | // embedded engine.) |
| 961 | |
| 962 | /// A deployment with its own blob directory: what the tenancy probes hold. |
| 963 | |
| 964 | |
| 965 | |
| 966 | |
| 967 | |
| 968 | |
| 969 | |
| 970 | |
| 971 | |
| 972 | |
| 973 | /// [`app_and_tenants`] with named schools created alongside the demo — where |
| 974 | /// the former `remote_deployment` probes re-point. The named schools go |
| 975 | /// through the real [`Tenants::create`], since the create path is part of |
| 976 | /// what the tenancy probes examine. |
| 977 | pub async |
| 978 | |
| 979 | |
| 980 | |
| 981 | |
| 982 | |
| 983 | |
| 984 | |
| 985 | |
| 986 | |
| 987 | |
| 988 | |
| 989 | |
| 990 | |
| 991 | |
| 992 | |
| 993 | |
| 994 | |
| 995 | |
| 996 | |
| 997 | |
| 998 | |
| 999 | |
| 1000 | |
| 1001 | |
| 1002 | |
| 1003 | |
| 1004 | |
| 1005 | |
| 1006 |