@@ -2235,11 +2235,11 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2235
2235
* Resolved when the cross signing master key is uploaded
2236
2236
* https://spec.matrix.org/v1.6/client-server-api/#put_matrixclientv3useruseridaccount_datatype
2237
2237
*/
2238
- function awaitCrossSigningMasterKeyUpload ( ) : Promise < Record < string , { } > > {
2238
+ function awaitCrossSigningKeyUpload ( key : string ) : Promise < Record < string , { } > > {
2239
2239
return new Promise ( ( resolve ) => {
2240
- // Called when the cross signing key master key is uploaded
2240
+ // Called when the cross signing key is uploaded
2241
2241
fetchMock . put (
2242
- " express:/_matrix/client/r0/user/:userId/account_data/m.cross_signing.master" ,
2242
+ ` express:/_matrix/client/r0/user/:userId/account_data/m.cross_signing.${ key } ` ,
2243
2243
( url : string , options : RequestInit ) => {
2244
2244
const content = JSON . parse ( options . body as string ) ;
2245
2245
resolve ( content . encrypted ) ;
@@ -2374,11 +2374,13 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2374
2374
} ,
2375
2375
) ;
2376
2376
2377
- newBackendOnly ( "should upload cross signing master key " , async ( ) => {
2377
+ newBackendOnly ( "should upload cross signing keys " , async ( ) => {
2378
2378
mockSetupCrossSigningRequests ( ) ;
2379
2379
2380
+ // Before setting up secret-storage, bootstrap cross-signing, so that the client has cross-signing keys.
2380
2381
await aliceClient . getCrypto ( ) ?. bootstrapCrossSigning ( { } ) ;
2381
2382
2383
+ // Now, when we bootstrap secret-storage, the cross-signing keys should be uploaded.
2382
2384
const bootstrapPromise = aliceClient
2383
2385
. getCrypto ( ) !
2384
2386
. bootstrapSecretStorage ( { setupNewSecretStorage : true , createSecretStorageKey } ) ;
@@ -2389,14 +2391,20 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2389
2391
// Return the newly created key in the sync response
2390
2392
sendSyncResponse ( secretStorageKey ) ;
2391
2393
2392
- // Wait for the cross signing key to be uploaded
2393
- const crossSigningKey = await awaitCrossSigningMasterKeyUpload ( ) ;
2394
+ // Wait for the cross signing keys to be uploaded
2395
+ const [ masterKey , userSigningKey , selfSigningKey ] = await Promise . all ( [
2396
+ awaitCrossSigningKeyUpload ( "master" ) ,
2397
+ awaitCrossSigningKeyUpload ( "user_signing" ) ,
2398
+ awaitCrossSigningKeyUpload ( "self_signing" ) ,
2399
+ ] ) ;
2394
2400
2395
2401
// Finally, wait for bootstrapSecretStorage to finished
2396
2402
await bootstrapPromise ;
2397
2403
2398
2404
// Expect the cross signing master key to be uploaded and to be encrypted with `secretStorageKey`
2399
- expect ( crossSigningKey [ secretStorageKey ] ) . toBeDefined ( ) ;
2405
+ expect ( masterKey [ secretStorageKey ] ) . toBeDefined ( ) ;
2406
+ expect ( userSigningKey [ secretStorageKey ] ) . toBeDefined ( ) ;
2407
+ expect ( selfSigningKey [ secretStorageKey ] ) . toBeDefined ( ) ;
2400
2408
} ) ;
2401
2409
} ) ;
2402
2410
} ) ;
0 commit comments