fix: Dont enable e2ee in test verification DM room
This commit is contained in:
		
							parent
							
								
									4cf88e2be6
								
							
						
					
					
						commit
						9abe1ed81d
					
				|  | @ -571,6 +571,7 @@ class Client extends MatrixApi { | ||||||
|     enableEncryption ??= await userOwnsEncryptionKeys(mxid); |     enableEncryption ??= await userOwnsEncryptionKeys(mxid); | ||||||
|     if (enableEncryption) { |     if (enableEncryption) { | ||||||
|       initialState ??= []; |       initialState ??= []; | ||||||
|  |       if (!initialState.any((s) => s.type == EventTypes.Encryption)) { | ||||||
|         initialState.add(StateEvent( |         initialState.add(StateEvent( | ||||||
|           content: { |           content: { | ||||||
|             'algorithm': supportedGroupEncryptionAlgorithms.first, |             'algorithm': supportedGroupEncryptionAlgorithms.first, | ||||||
|  | @ -578,6 +579,7 @@ class Client extends MatrixApi { | ||||||
|           type: EventTypes.Encryption, |           type: EventTypes.Encryption, | ||||||
|         )); |         )); | ||||||
|       } |       } | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     // Start a new direct chat |     // Start a new direct chat | ||||||
|     final roomId = await createRoom( |     final roomId = await createRoom( | ||||||
|  | @ -587,12 +589,10 @@ class Client extends MatrixApi { | ||||||
|       initialState: initialState, |       initialState: initialState, | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     if (waitForSync) { |     if (waitForSync && getRoomById(roomId) == null) { | ||||||
|       if (getRoomById(roomId) == null) { |  | ||||||
|       // Wait for room actually appears in sync |       // Wait for room actually appears in sync | ||||||
|         await onSync.stream.firstWhere( |       await onSync.stream | ||||||
|             (sync) => sync.rooms?.join?.containsKey(roomId) ?? false); |           .firstWhere((sync) => sync.rooms?.join?.containsKey(roomId) ?? false); | ||||||
|       } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     await Room(id: roomId, client: this).addToDirectChat(mxid); |     await Room(id: roomId, client: this).addToDirectChat(mxid); | ||||||
|  | @ -615,6 +615,7 @@ class Client extends MatrixApi { | ||||||
|         encryptionEnabled && preset != CreateRoomPreset.publicChat; |         encryptionEnabled && preset != CreateRoomPreset.publicChat; | ||||||
|     if (enableEncryption) { |     if (enableEncryption) { | ||||||
|       initialState ??= []; |       initialState ??= []; | ||||||
|  |       if (!initialState.any((s) => s.type == EventTypes.Encryption)) { | ||||||
|         initialState.add(StateEvent( |         initialState.add(StateEvent( | ||||||
|           content: { |           content: { | ||||||
|             'algorithm': supportedGroupEncryptionAlgorithms.first, |             'algorithm': supportedGroupEncryptionAlgorithms.first, | ||||||
|  | @ -622,6 +623,7 @@ class Client extends MatrixApi { | ||||||
|           type: EventTypes.Encryption, |           type: EventTypes.Encryption, | ||||||
|         )); |         )); | ||||||
|       } |       } | ||||||
|  |     } | ||||||
|     final roomId = await createRoom( |     final roomId = await createRoom( | ||||||
|       invite: invite, |       invite: invite, | ||||||
|       preset: preset, |       preset: preset, | ||||||
|  |  | ||||||
|  | @ -67,14 +67,25 @@ class DeviceKeysList { | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   Future<KeyVerification> startVerification() async { |   /// Starts a verification with this device. This might need to create a new | ||||||
|  |   /// direct chat to send the verification request over this room. For this you | ||||||
|  |   /// can set parameters here. | ||||||
|  |   Future<KeyVerification> startVerification({ | ||||||
|  |     bool? newDirectChatEnableEncryption, | ||||||
|  |     List<StateEvent>? newDirectChatInitialState, | ||||||
|  |   }) async { | ||||||
|     final encryption = client.encryption; |     final encryption = client.encryption; | ||||||
|     if (encryption == null) { |     if (encryption == null) { | ||||||
|       throw Exception('Encryption not enabled'); |       throw Exception('Encryption not enabled'); | ||||||
|     } |     } | ||||||
|     if (userId != client.userID) { |     if (userId != client.userID) { | ||||||
|       // in-room verification with someone else |       // in-room verification with someone else | ||||||
|       final roomId = await client.startDirectChat(userId); |       final roomId = await client.startDirectChat( | ||||||
|  |         userId, | ||||||
|  |         enableEncryption: newDirectChatEnableEncryption, | ||||||
|  |         initialState: newDirectChatInitialState, | ||||||
|  |         waitForSync: false, | ||||||
|  |       ); | ||||||
| 
 | 
 | ||||||
|       final room = |       final room = | ||||||
|           client.getRoomById(roomId) ?? Room(id: roomId, client: client); |           client.getRoomById(roomId) ?? Room(id: roomId, client: client); | ||||||
|  |  | ||||||
|  | @ -252,7 +252,7 @@ void main() { | ||||||
|       expect(req?.room != null, false); |       expect(req?.room != null, false); | ||||||
| 
 | 
 | ||||||
|       req = await client.userDeviceKeys['@alice:example.com'] |       req = await client.userDeviceKeys['@alice:example.com'] | ||||||
|           ?.startVerification(); |           ?.startVerification(newDirectChatEnableEncryption: false); | ||||||
|       expect(req != null, true); |       expect(req != null, true); | ||||||
|       expect(req?.room != null, true); |       expect(req?.room != null, true); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -119,7 +119,9 @@ void main() { | ||||||
|       client1.userDeviceKeys[client1.userID]!.masterKey! |       client1.userDeviceKeys[client1.userID]!.masterKey! | ||||||
|           .setDirectVerified(false); |           .setDirectVerified(false); | ||||||
|       final req1 = |       final req1 = | ||||||
|           await client1.userDeviceKeys[client2.userID]!.startVerification(); |           await client1.userDeviceKeys[client2.userID]!.startVerification( | ||||||
|  |         newDirectChatEnableEncryption: false, | ||||||
|  |       ); | ||||||
|       var evt = getLastSentEvent(req1); |       var evt = getLastSentEvent(req1); | ||||||
|       expect(req1.state, KeyVerificationState.waitingAccept); |       expect(req1.state, KeyVerificationState.waitingAccept); | ||||||
| 
 | 
 | ||||||
|  | @ -221,8 +223,8 @@ void main() { | ||||||
|       client1.userDeviceKeys[client1.userID]!.masterKey! |       client1.userDeviceKeys[client1.userID]!.masterKey! | ||||||
|           .setDirectVerified(true); |           .setDirectVerified(true); | ||||||
|       await client1.encryption!.ssss.clearCache(); |       await client1.encryption!.ssss.clearCache(); | ||||||
|       final req1 = |       final req1 = await client1.userDeviceKeys[client2.userID]! | ||||||
|           await client1.userDeviceKeys[client2.userID]!.startVerification(); |           .startVerification(newDirectChatEnableEncryption: false); | ||||||
|       expect(req1.state, KeyVerificationState.askSSSS); |       expect(req1.state, KeyVerificationState.askSSSS); | ||||||
|       await req1.openSSSS(recoveryKey: ssssKey); |       await req1.openSSSS(recoveryKey: ssssKey); | ||||||
|       await Future.delayed(Duration(seconds: 1)); |       await Future.delayed(Duration(seconds: 1)); | ||||||
|  | @ -241,8 +243,8 @@ void main() { | ||||||
|       // the other one has to have their master key verified to trigger asking for ssss |       // the other one has to have their master key verified to trigger asking for ssss | ||||||
|       client2.userDeviceKeys[client2.userID]!.masterKey! |       client2.userDeviceKeys[client2.userID]!.masterKey! | ||||||
|           .setDirectVerified(true); |           .setDirectVerified(true); | ||||||
|       final req1 = |       final req1 = await client1.userDeviceKeys[client2.userID]! | ||||||
|           await client1.userDeviceKeys[client2.userID]!.startVerification(); |           .startVerification(newDirectChatEnableEncryption: false); | ||||||
|       var evt = getLastSentEvent(req1); |       var evt = getLastSentEvent(req1); | ||||||
|       expect(req1.state, KeyVerificationState.waitingAccept); |       expect(req1.state, KeyVerificationState.waitingAccept); | ||||||
| 
 | 
 | ||||||
|  | @ -345,8 +347,8 @@ void main() { | ||||||
|       // make sure our master key is *not* verified to not triger SSSS for now |       // make sure our master key is *not* verified to not triger SSSS for now | ||||||
|       client1.userDeviceKeys[client1.userID]!.masterKey! |       client1.userDeviceKeys[client1.userID]!.masterKey! | ||||||
|           .setDirectVerified(false); |           .setDirectVerified(false); | ||||||
|       final req1 = |       final req1 = await client1.userDeviceKeys[client2.userID]! | ||||||
|           await client1.userDeviceKeys[client2.userID]!.startVerification(); |           .startVerification(newDirectChatEnableEncryption: false); | ||||||
|       var evt = getLastSentEvent(req1); |       var evt = getLastSentEvent(req1); | ||||||
|       expect(req1.state, KeyVerificationState.waitingAccept); |       expect(req1.state, KeyVerificationState.waitingAccept); | ||||||
| 
 | 
 | ||||||
|  | @ -375,8 +377,8 @@ void main() { | ||||||
|       // make sure our master key is *not* verified to not triger SSSS for now |       // make sure our master key is *not* verified to not triger SSSS for now | ||||||
|       client1.userDeviceKeys[client1.userID]!.masterKey! |       client1.userDeviceKeys[client1.userID]!.masterKey! | ||||||
|           .setDirectVerified(false); |           .setDirectVerified(false); | ||||||
|       final req1 = |       final req1 = await client1.userDeviceKeys[client2.userID]! | ||||||
|           await client1.userDeviceKeys[client2.userID]!.startVerification(); |           .startVerification(newDirectChatEnableEncryption: false); | ||||||
|       var evt = getLastSentEvent(req1); |       var evt = getLastSentEvent(req1); | ||||||
|       expect(req1.state, KeyVerificationState.waitingAccept); |       expect(req1.state, KeyVerificationState.waitingAccept); | ||||||
| 
 | 
 | ||||||
|  | @ -436,8 +438,8 @@ void main() { | ||||||
|       // make sure our master key is *not* verified to not triger SSSS for now |       // make sure our master key is *not* verified to not triger SSSS for now | ||||||
|       client1.userDeviceKeys[client1.userID]!.masterKey! |       client1.userDeviceKeys[client1.userID]!.masterKey! | ||||||
|           .setDirectVerified(false); |           .setDirectVerified(false); | ||||||
|       final req1 = |       final req1 = await client1.userDeviceKeys[client2.userID]! | ||||||
|           await client1.userDeviceKeys[client2.userID]!.startVerification(); |           .startVerification(newDirectChatEnableEncryption: false); | ||||||
|       final evt = getLastSentEvent(req1); |       final evt = getLastSentEvent(req1); | ||||||
|       expect(req1.state, KeyVerificationState.waitingAccept); |       expect(req1.state, KeyVerificationState.waitingAccept); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue