QA-2420: add OrganizationCardCipherScene to the seeder - #8294
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #8294 +/- ##
==========================================
- Coverage 69.37% 63.71% -5.67%
==========================================
Files 2470 2470
Lines 105809 105809
Branches 9564 9564
==========================================
- Hits 73401 67411 -5990
- Misses 29970 36079 +6109
+ Partials 2438 2319 -119 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
611f279 to
1c3a2cf
Compare
Adds a standalone OrganizationCardCipherScene that seeds an org-owned card cipher encrypted with the org key and assigned to the requested collections, mirroring UserCardCipherScene for card fields and OrganizationLoginCipherScene for owner resolution and collection-aware persistence. CardCipherSeeder is unchanged. Includes a factory unit test asserting org ownership and per-field org-key decryption.
1c3a2cf to
f020dcf
Compare
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the new Code Review Details
|
| [Fact] | ||
| public void Create_OrganizationCard_EncryptsWithOrgKeyAndCarriesOwnership() |
There was a problem hiding this comment.
♻️ DEBT: This test covers CardCipherSeeder (unchanged by this PR), and near-identical coverage already exists.
Details
RustSdkCipherTests.cs:463 (CipherSeeder_CardCipher_ProducesServerCompatibleFormat) already calls CardCipherSeeder.Create with an org key and OrganizationId set, and RustSdkCipherTests.cs:245 (EncryptFields_CardCipher_RoundtripDecrypt) already asserts per-field decryption back to plaintext with that key. The only assertion here not already covered elsewhere is Assert.Null(cipher.UserId).
Meanwhile the code this PR actually adds — OrganizationCardCipherScene's org resolution, Notes/Reprompt mapping, and the collection-aware CreateAsync(cipher, collectionIds) persistence — is not exercised. Consider either folding the UserId/Brand assertions into the existing RustSdkCipherTests card test, or replacing this with a scene test in the style of test/SeederApi.IntegrationTest/Scenes/SecretsManagerSceneTests.cs, which drives scenes through POST /seed and verifies persisted rows.
Not a blocker — 21 of 23 scenes have no test today, so this is consistent with the existing bar.
There was a problem hiding this comment.
I agree with Claude Code here @awiester-bw that the test does not add value beyond what is already lower in the stack for the RustSdkCipherTests. Will you please remove the test file? Thanks!
theMickster
left a comment
There was a problem hiding this comment.
The Claude Code Comment here is the one fix to the PR that we should make. Otherwise, I'm good with the code.
| [Fact] | ||
| public void Create_OrganizationCard_EncryptsWithOrgKeyAndCarriesOwnership() |
There was a problem hiding this comment.
I agree with Claude Code here @awiester-bw that the test does not add value beyond what is already lower in the stack for the RustSdkCipherTests. Will you please remove the test file? Thanks!
🎟️ Tracking
QA-2420: https://bitwarden.atlassian.net/browse/QA-2420
📔 Objective
The seeder can create org-owned login ciphers but has no way to create an org-owned card cipher; card seeding exists user-side only. This blocks per-test seeding for the org ClientEvents card tests, whose cases view and edit a card in an org collection and need one already seeded. This adds
OrganizationCardCipherScene, mirroringUserCardCipherScenefor the card fields andOrganizationLoginCipherScenefor owner resolution and collection-aware persistence: it resolves the org, encrypts the card with the org key (OrganizationIdset,UserIdnull), and writes it to the requested collections throughCreateAsync(cipher, collectionIds).CardCipherSeederalready produces an org-key card, so it is unchanged. The reflection-based scene registration picks the scene up automatically by class name.Includes a factory unit test that seeds an org card with a generated org key and asserts ownership (
Cardtype,OrganizationIdset,UserIdnull) plus per-field decryption back to plaintext with the org key. Verified by a passing build (0 errors) and the code-review and security-review agent passes.