tests: add integration test platform - #1450
Conversation
Claude Code validationResult: Pass Validated the one Claude-material path in this PR — CriticalNone. Major
Minor
Notes
Checks run
|
a3b94d7 to
2a3a596
Compare
🔍 SDK Breaking Change DetectionSDK Version:
Breaking change detection uses the build of the SDK from this branch, including any incompatibities pre-existing on or merged into this branch. Check the workflow logs to confirm. |
2a3a596 to
6178c03
Compare
| masterKey: null, | ||
| privateKey: String(V2_PRIVATE_KEY), | ||
| publicKey: "cHVibGljLWtleQ==", | ||
| verifyingKey: "dmVyaWZ5aW5nLWtleQ==", |
There was a problem hiding this comment.
Exposed secret in crates/bitwarden-wasm-internal/integration-tests/vectors/accounts.ts - low severity
Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More Info
There was a problem hiding this comment.
✅ Based on your feedback, we ignored this issue because of the following reason:
Test vector
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Re-reviewed the integration-test platform after the latest round: the server emulator ( Code Review Details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1450 +/- ##
=======================================
Coverage 86.23% 86.23%
=======================================
Files 555 555
Lines 80085 80085
=======================================
Hits 69060 69060
Misses 11025 11025 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
eliykat
left a comment
There was a problem hiding this comment.
Reviewed at a high level and discussed in Slack :) Thank you for working on testing utils!
| /** | ||
| * Simulates a sync from server to client | ||
| */ | ||
| async sync(email: string): Promise<void> { |
There was a problem hiding this comment.
This will eventually be moved entirely into the sdk once sdk gains sync.
| // Quirk, the crypto sync handler writes the kdf only when the account has no master-password | ||
| // but clients always write it. |
There was a problem hiding this comment.
♻️ DEBT: Finding 1: The comment states the inverse of what the sync handler does, and of what the branch below it does.
Details and fix
crypto_sync_handler.rs:179-186 writes the KDF in the Some(master_password_unlock) arm only — so the handler writes it when the account has master-password unlock data, and writes nothing for an account without one. That is why the branch below fills the gap for masterPasswordUnlock === null, and the code is right. The comment says the opposite, so a reader reconciling it against the if will conclude one of the two is wrong; deleting the branch on that basis leaves a V2/no-master-password account with no KDF in the bridge, and LocalState.unlock then throws "no synced key material".
// Quirk: the crypto sync handler writes the kdf only for accounts that have master-password
// unlock data, but real clients read it off the profile and always write it.
if (user.masterPasswordUnlock === null) {69e685e to
a64a237
Compare
https://bitwarden.atlassian.net/browse/PM-41875
Adds a better platform for integration tests. Essentially, by emulating state + server, we get very simple to reason about and write integration tests.
Please note, the server emulation was the simplest way to get a server in place. The maintenance effort looks fairly low (especially if assisted by claude; we don't care particularly much about the code style / quality of an emulation server that is not in prod), but if in the future we decide that it is high, we can always run it against a real bitwarden-lite instance. THIS IS FUTURE WORK. However, this does mean that tests are not allowed to assert on server state.
We want to make sure to get the test shape right first, and make writing good, useful tests good first before spending effort to spin up integration testing infrastructure.
Example:
The setup for the test is the following:
These are very understandable, easy to reason about and easy to extend, compared to the unit tests we currently have.
Moving forward, the plan is to move all integration tests to this kind of model. Further, we will expand this to work on a wide array of test vectors of different cryptographic versions. This will help ensure we catch two clases of bugs that recently slipped by: