@@ -827,7 +827,7 @@ mod tests {
827
827
use crate :: key;
828
828
use crate :: pgp:: { split_armored_data, HEADER_AUTOCRYPT , HEADER_SETUPCODE } ;
829
829
use crate :: stock_str:: StockMessage ;
830
- use crate :: test_utils:: { alice_keypair, TestContext } ;
830
+ use crate :: test_utils:: { alice_keypair, TestContext , TestContextManager } ;
831
831
832
832
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
833
833
async fn test_render_setup_file ( ) {
@@ -1133,6 +1133,7 @@ mod tests {
1133
1133
alice2. configure_addr ( "alice@example.org" ) . await ;
1134
1134
alice2. recv_msg ( & sent) . await ;
1135
1135
let msg = alice2. get_last_msg ( ) . await ;
1136
+ assert ! ( msg. is_setupmessage( ) ) ;
1136
1137
1137
1138
// Send a message that cannot be decrypted because the keys are
1138
1139
// not synchronized yet.
@@ -1150,4 +1151,25 @@ mod tests {
1150
1151
1151
1152
Ok ( ( ) )
1152
1153
}
1154
+
1155
+ /// Tests that Autocrypt Setup Messages is only clickable if it is self-sent.
1156
+ /// This prevents Bob from tricking Alice into changing the key
1157
+ /// by sending her an Autocrypt Setup Message as long as Alice's server
1158
+ /// does not allow to forge the `From:` header.
1159
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
1160
+ async fn test_key_transfer_non_self_sent ( ) -> Result < ( ) > {
1161
+ let mut tcm = TestContextManager :: new ( ) ;
1162
+ let alice = tcm. alice ( ) . await ;
1163
+ let bob = tcm. bob ( ) . await ;
1164
+
1165
+ let _setup_code = initiate_key_transfer ( & alice) . await ?;
1166
+
1167
+ // Get Autocrypt Setup Message.
1168
+ let sent = alice. pop_sent_msg ( ) . await ;
1169
+
1170
+ let rcvd = bob. recv_msg ( & sent) . await ;
1171
+ assert ! ( !rcvd. is_setupmessage( ) ) ;
1172
+
1173
+ Ok ( ( ) )
1174
+ }
1153
1175
}
0 commit comments