Blame
|
1 | --- |
||||||
| 2 | category: reference |
|||||||
| 3 | tags: [phase-2, testing, e2e] |
|||||||
| 4 | last_updated: 2026-03-13 |
|||||||
| 5 | --- |
|||||||
| 6 | ||||||||
| 7 | # P2-10: Phase 2 E2E Integration Tests |
|||||||
| 8 | ||||||||
| 9 | ## Overview |
|||||||
| 10 | ||||||||
| 11 | E2E integration tests for Phase 2 multi-tenancy features. These tests run against the deployed stack after `pulumi up` with all Phase 2 changes. |
|||||||
| 12 | ||||||||
| 13 | **File:** `tests/test_e2e_phase2.py` |
|||||||
| 14 | **Branch:** `feat/P2-10-e2e` (from `phase-2`) |
|||||||
| 15 | **Tests collected:** 17 |
|||||||
| 16 | ||||||||
| 17 | ## Required Environment Variables |
|||||||
| 18 | ||||||||
| 19 | | Variable | Description | |
|||||||
| 20 | |----------|-------------| |
|||||||
| 21 | | `E2E_USER_A_TOKEN` | Platform JWT for User A (wiki owner) | |
|||||||
| 22 | | `E2E_USER_B_TOKEN` | Platform JWT for User B (collaborator) | |
|||||||
| 23 | | `E2E_USER_A_ID` | User A's platform user ID (used as subdomain) | |
|||||||
| 24 | | `E2E_USER_B_EMAIL` | User B's registered email (for ACL grants) | |
|||||||
| 25 | | `E2E_BASE_URL` | Optional, defaults to `https://dev.wikibot.io` | |
|||||||
| 26 | ||||||||
| 27 | All tests skip cleanly when tokens are not set. |
|||||||
| 28 | ||||||||
| 29 | ## Test Scenarios |
|||||||
| 30 | ||||||||
| 31 | | # | Scenario | Class | Tests | |
|||||||
| 32 | |---|----------|-------|-------| |
|||||||
| 33 | | 1 | User A creates wiki | `TestCreateWiki` | 1 | |
|||||||
| 34 | | 2 | User A writes page via REST API | `TestWritePage` | 1 | |
|||||||
| 35 | | 3 | User B denied on private wiki | `TestCrossUserDenied` | 1 | |
|||||||
| 36 | | 4 | User A grants User B editor | `TestGrantAccess` | 1 | |
|||||||
| 37 | | 5 | User B writes after grant | `TestGrantedAccess` | 1 | |
|||||||
| 38 | | 6 | User A revokes User B | `TestRevokeAccess` | 1 | |
|||||||
| 39 | | 7 | User B denied after revoke | `TestDeniedAfterRevoke` | 1 | |
|||||||
| 40 | | 8 | Free tier limit enforced | `TestFreeTierLimit` | 1 | |
|||||||
| 41 | | 9 | Public wiki anonymous READ | `TestPublicWikiRead` | 1 | |
|||||||
| 42 | | 10 | Public wiki anonymous WRITE blocked | `TestPublicWikiWriteBlocked` | 1 | |
|||||||
| 43 | | 11 | MCP bearer token access | `TestMcpTokenAccess` | 1 | |
|||||||
| 44 | | 12 | MCP wrong token rejected | `TestMcpWrongToken` | 1 | |
|||||||
| 45 | | 13 | Admin panel hiding | `TestAdminPanelHiding` | 2 | |
|||||||
| 46 | | 14 | Wiki list isolation | `TestWikiListIsolation` | 2 | |
|||||||
| 47 | | 15 | Token regeneration | `TestTokenRegeneration` | 1 | |
|||||||
| 48 | ||||||||
| 49 | ## Design Decisions |
|||||||
| 50 | ||||||||
| 51 | - **Module-scoped fixtures** for wiki creation/teardown — wiki_a creates a private wiki once and cleans up after all tests. |
|||||||
| 52 | - **Unique slug per run** (`e2e-p2-{uuid}`) avoids collisions between parallel runs. |
|||||||
| 53 | - **Tenant URL helper** constructs subdomain-based URLs (`{user_id}.wikibot.io/{slug}/...`). |
|||||||
| 54 | - **Two skip markers**: `_require_tokens` (needs A+B tokens) and `_require_all` (needs all 4 env vars). |
|||||||
| 55 | - Tests use `httpx` consistent with Phase 1 E2E tests. |
|||||||
| 56 | ||||||||
| 57 | ## Running |
|||||||
| 58 | ||||||||
| 59 | ```bash |
|||||||
| 60 | export E2E_USER_A_TOKEN="..." |
|||||||
| 61 | export E2E_USER_B_TOKEN="..." |
|||||||
| 62 | export E2E_USER_A_ID="..." |
|||||||
| 63 | export E2E_USER_B_EMAIL="..." |
|||||||
| 64 | pytest tests/test_e2e_phase2.py -v -m e2e |
|||||||
| 65 | ``` |
|||||||