@@ -171,28 +171,91 @@ describe("Cryptography", function () {
171
171
cy . stopHomeserver ( this . homeserver ) ;
172
172
} ) ;
173
173
174
- it ( "setting up secure key backup should work" , ( ) => {
175
- skipIfRustCrypto ( ) ;
176
- cy . openUserSettings ( "Security & Privacy" ) ;
177
- cy . findByRole ( "button" , { name : "Set up Secure Backup" } ) . click ( ) ;
178
- cy . get ( ".mx_Dialog" ) . within ( ( ) => {
179
- cy . findByRole ( "button" , { name : "Continue" } ) . click ( ) ;
180
- cy . get ( ".mx_CreateSecretStorageDialog_recoveryKey code" ) . invoke ( "text" ) . as ( "securityKey" ) ;
174
+ describe ( "setting up secure key backup should work" , ( ) => {
175
+ /**
176
+ * Verify that the `m.cross_signing.${keyType}` key is available on the account data on the server
177
+ * @param keyType
178
+ */
179
+ function verifyKey ( keyType : string ) {
180
+ return cy
181
+ . getClient ( )
182
+ . then ( ( cli ) => cy . wrap ( cli . getAccountDataFromServer ( `m.cross_signing.${ keyType } ` ) ) )
183
+ . then ( ( accountData : { encrypted : Record < string , Record < string , string > > } ) => {
184
+ expect ( accountData . encrypted ) . to . exist ;
185
+ const keys = Object . keys ( accountData . encrypted ) ;
186
+ const key = accountData . encrypted [ keys [ 0 ] ] ;
187
+ expect ( key . ciphertext ) . to . exist ;
188
+ expect ( key . iv ) . to . exist ;
189
+ expect ( key . mac ) . to . exist ;
190
+ } ) ;
191
+ }
192
+
193
+ /**
194
+ * Click on download button and continue
195
+ */
196
+ function downloadKey ( ) {
181
197
// Clicking download instead of Copy because of https://github.com/cypress-io/cypress/issues/2851
182
198
cy . findByRole ( "button" , { name : "Download" } ) . click ( ) ;
183
199
cy . contains ( ".mx_Dialog_primary:not([disabled])" , "Continue" ) . click ( ) ;
184
- cy . get ( ".mx_InteractiveAuthDialog" ) . within ( ( ) => {
185
- cy . get ( ".mx_Dialog_title" ) . within ( ( ) => {
186
- cy . findByText ( "Setting up keys" ) . should ( "exist" ) ;
187
- cy . findByText ( "Setting up keys" ) . should ( "not.exist" ) ;
200
+ }
201
+
202
+ it ( "by recovery code" , ( ) => {
203
+ skipIfRustCrypto ( ) ;
204
+ cy . openUserSettings ( "Security & Privacy" ) ;
205
+ cy . findByRole ( "button" , { name : "Set up Secure Backup" } ) . click ( ) ;
206
+ cy . get ( ".mx_Dialog" ) . within ( ( ) => {
207
+ // Recovery key is selected by default
208
+ cy . findByRole ( "button" , { name : "Continue" } ) . click ( ) ;
209
+ cy . get ( ".mx_CreateSecretStorageDialog_recoveryKey code" ) . invoke ( "text" ) . as ( "securityKey" ) ;
210
+
211
+ downloadKey ( ) ;
212
+
213
+ cy . get ( ".mx_InteractiveAuthDialog" ) . within ( ( ) => {
214
+ cy . get ( ".mx_Dialog_title" ) . within ( ( ) => {
215
+ cy . findByText ( "Setting up keys" ) . should ( "exist" ) ;
216
+ cy . findByText ( "Setting up keys" ) . should ( "not.exist" ) ;
217
+ } ) ;
188
218
} ) ;
219
+
220
+ cy . findByText ( "Secure Backup successful" ) . should ( "exist" ) ;
221
+ cy . findByRole ( "button" , { name : "Done" } ) . click ( ) ;
222
+ cy . findByText ( "Secure Backup successful" ) . should ( "not.exist" ) ;
223
+ } ) ;
224
+
225
+ // Verify that the SSSS keys are in the account data stored in the server
226
+ verifyKey ( "master" ) ;
227
+ verifyKey ( "self_signing" ) ;
228
+ verifyKey ( "user_signing" ) ;
229
+ } ) ;
230
+
231
+ it ( "by passphrase" , ( ) => {
232
+ skipIfRustCrypto ( ) ;
233
+ cy . openUserSettings ( "Security & Privacy" ) ;
234
+ cy . findByRole ( "button" , { name : "Set up Secure Backup" } ) . click ( ) ;
235
+ cy . get ( ".mx_Dialog" ) . within ( ( ) => {
236
+ // Select passphrase option
237
+ cy . findByText ( "Enter a Security Phrase" ) . click ( ) ;
238
+ cy . findByRole ( "button" , { name : "Continue" } ) . click ( ) ;
239
+
240
+ // Fill passphrase input
241
+ cy . get ( "input" ) . type ( "new passphrase for setting up a secure key backup" ) ;
242
+ cy . contains ( ".mx_Dialog_primary:not([disabled])" , "Continue" ) . click ( ) ;
243
+ // Confirm passphrase
244
+ cy . get ( "input" ) . type ( "new passphrase for setting up a secure key backup" ) ;
245
+ cy . contains ( ".mx_Dialog_primary:not([disabled])" , "Continue" ) . click ( ) ;
246
+
247
+ downloadKey ( ) ;
248
+
249
+ cy . findByText ( "Secure Backup successful" ) . should ( "exist" ) ;
250
+ cy . findByRole ( "button" , { name : "Done" } ) . click ( ) ;
251
+ cy . findByText ( "Secure Backup successful" ) . should ( "not.exist" ) ;
189
252
} ) ;
190
253
191
- cy . findByText ( "Secure Backup successful" ) . should ( "exist" ) ;
192
- cy . findByRole ( "button" , { name : "Done" } ) . click ( ) ;
193
- cy . findByText ( "Secure Backup successful" ) . should ( "not.exist" ) ;
254
+ // Verify that the SSSS keys are in the account data stored in the server
255
+ verifyKey ( "master" ) ;
256
+ verifyKey ( "self_signing" ) ;
257
+ verifyKey ( "user_signing" ) ;
194
258
} ) ;
195
- return ;
196
259
} ) ;
197
260
198
261
it ( "creating a DM should work, being e2e-encrypted / user verification" , function ( this : CryptoTestContext ) {
0 commit comments