Coverage / crates/hub/src/setup.rs 89.4%
42 of 47 lines run, 10 of 20 functions · run #518 on main · run missed
| 1 | //! The first administrator (oxygenhub#245). A hub with no accounts gives | |
| 2 | //! administrator to the first account registered, so that account must | |
| 3 | //! bring a one-time setup code: the one in `[registration] setup_code` | |
| 4 | //! (for automation), or else a random one this module keeps in | |
| 5 | //! `<data>/setup-code` (owner-only) and logs at start. It is never served | |
| 6 | //! over the web. Registering with it spends it; once there are accounts | |
| 7 | //! there is no code. | |
| 8 | | |
| 9 | use crateaccounts; | |
| 10 | use crateShared; | |
| 11 | use PathBuf; | |
| 12 | ||
| 13 | 301× | |
| 14 | 301× | |
| 15 | 301× | |
| 16 | ||
| 17 | /// At start: with no accounts, make sure there is a code and say where it | |
| 18 | /// is; with accounts, make sure none is left lying about. | |
| 19 | 200× | pub async |
| 20 | 200× | |
| 21 | 200× | |
| 22 | 0× | |
| 23 | 0× | |
| 24 | 200× | |
| 25 | 200× | |
| 26 | 194× | |
| 27 | | |
| 28 | 6× | |
| 29 | 6× | |
| 30 | 6× | |
| 31 | | |
| 32 | | |
| 33 | 200× | |
| 34 | | |
| 35 | 0× | |
| 36 | 0× | |
| 37 | | |
| 38 | 200× | |
| 39 | 200× | |
| 40 | ||
| 41 | /// The code the first registration must bring, if there is one. | |
| 42 | 294× | |
| 43 | 294× | |
| 44 | 294× | |
| 45 | 285× | |
| 46 | 9× | |
| 47 | 9× | |
| 48 | 294× | |
| 49 | ||
| 50 | /// Whether `given` is the setup code, compared in constant time. | |
| 51 | 94× | |
| 52 | 94× | |
| 53 | 94× | |
| 54 | 94× | |
| 55 | 958× | |
| 56 | | |
| 57 | 0× | |
| 58 | | |
| 59 | 94× | |
| 60 | ||
| 61 | /// The first administrator exists: the code is spent. | |
| 62 | 92× | |
| 63 | 92× | |
| 64 | 92× | |
| 65 | ||
| 66 | 6× | |
| 67 | | |
| 68 | 6× | |
| 69 | 6× | |
| 70 | | |
| 71 | | |
| 72 | | |
| 73 | 6× | |
| 74 | | |
| 75 | 6× | |
| 76 | 6× | |
| 77 | 6× | |