Two things a team ends up needing are a history of test runs, and a safe place
for browser profiles. Both live in one embedded database,
Turso, behind the turso feature. It
is off by default, runs in your process, and keeps everything in a local file;
nothing is sent over the network.
A Turso dependency needs Rust 1.90, which the crate’s rust-version (1.99)
already covers.
What you will learn
- Record test runs and results, and ask which tests are flakyPasses in some runs and fails in others.
- Read them from the command line with
sbrs report - Keep browser profiles encrypted at rest
Recording test runs#
A ResultStore keeps runs and their results. Start a run, then record each
test as it finishes:
environmentis the counterpart of Python SeleniumBase’s--database_env:stagingandproductionruns share a database but stay apart.record_outcomestores a pass, or a failure whose message is the error.recordtakes aTestResultwhen you build it yourself.- The file and its directory are created on first use. A file that is not a results database, or that a newer release wrote, is refused rather than misread.
- A store is cheap to clone, and every clone shares the database.
Ask it questions:
A test that always fails is broken, not flaky, so flaky_tests leaves it out.
Test messages are stored as written; if an assertion message can contain a secret, redact it before recording.
sbrs report#
Build the CLI with the feature, and read a database without writing any code:
Encrypted profiles#
A browser profile holds cookies, saved logins and proxy passwords, so a
profiles.json is a file anyone who can read the disk can read. A
ProfileVault stores the same documents in a Turso database with each one
sealed by AES-256-GCM under a key derived from a passphrase (PBKDF2-HMAC-SHA256,
600,000 iterations):
- Collections and ids (
profiles,p1) are stored in the clear; the documents are not. Someone with the file learns how many documents there are and how large, not what is in them. - A document is bound to its place. Copying a sealed body to another id or collection makes it fail its integrity check instead of decrypting as the wrong profile.
- A wrong passphrase is refused when the vault is opened, and the guess is never echoed. An empty passphrase is refused.
change_passphrasere-encrypts everything under a new salt in a single transaction, so a failure part-way leaves the old passphrase working.Debugnever shows the key.
What it does not do: it cannot protect a vault that is open in a process an attacker controls, because the key has to be in memory to be used, and it does not hide the number or size of documents. Keep the passphrase somewhere better than the source tree, such as the operating system’s keychain or an environment variable your deployment injects.